Monthly Monday Microcontroller Madness: Motors!


After speaking to a few folks that expressed an interest in the MMMM workshop, it became apparent (a) most folks were newbs who want to learn the basics and (b) everyone wants to control motors.  Excellent!  We’ll do that.

Although motor control is potentially a vast and complex topic, with highly specialized branches, the basics are fairly easy to learn — and they’ll take you pretty far.   So … we’ll be prepared to present the following items:

  • DC motors
  • H-bridge circuits — these let puny microcontrollers run fairly powerful motors
  • Stepper motors — just a little more complex to program than DC motors and they use H-bridge circuits too
  • Quadrature Encoders — these are a  simple and accurate way to read the position of something

We’ll also try to discuss some organizational items — like the logistics of future workshops and the use of the MMMM GitHub, so that we can build up assets collectively, share them with the world and manage changes and contributions in a free-and-easy-but-organized way.

If you are coming , please bring:

  • Yourself — If you’re a newb, welcome — If you’re an MCU Yoda, then attend you must and wisdom to newbs impart
  • Some ideas
  • A laptop if you have one
  • You may want to install VMWare Player or VMWare Fusion before you arrive
  • An MCU development kit if you have one or …
  • Some money if you don’t.  We’ll have some development kits that you can buy.  Plan on at least $10 for the kits and some parts that you can use for small learning projects.
  • A bread-board if you want to build some live circuits to keep.  We’ll have breadboards to loan, but if you want to take one home, it has to be one that arrived with you.
  • That’s about it — see you all Monday.  To whet your appetite, there is some prototype code below for reading a quadrature encoded position detector (not really elegant enough for a final effort, but it’s a start).  We’ll have you writing stuff like this in no-time.

    Continue reading “Monthly Monday Microcontroller Madness: Motors!”

    DIY Scratch I/O Board Using Arduino

    Scratch Project that I used to test the DIY Scratch Sensor Board

    I downloaded Scratch to play with it after a presentation on E-Textiles at UPenn back in April.  I found it kind of interesting, and I was particularly interested in the “Scratch Sensor Board“, which provides a way to send physical signals into Scratch scripts and have Scratch respond to them.  It’s a pretty simple protocol, and I filed away “build a Scratch sensor board” as one of those projects that I might do … someday.  Well, nothing like being stuck at home during a major weather event to crank up the boredom level to the point that ya gotta do something.  So, courtesy of Hurricane Irene, here’s a DIY Scratch Sensor written as an Arduino Sketch.

    This sketch uses information that you can download here.  You may need to use the Scratch Board Watcher to get things cooking 100%.  For example, this is how I learned that the sense of the Button input is inverted.

    /* 
    This code emulates a Scratch Sensor board
    */
    
    // --- sends serial bytes corresponding to a signal with value given by "data"
    //     coming from the channel designated by "channel"
    //     data is in the range 0 .. 1023 inclusive and generally gets mapped to the range 0 .. 100 by Scratch
    void sendScratchData(int channel, int data);
    
    int buttonPin = 2;   // Change this if you want to use some other pin for the Button input. Just don't use pins 0 or 1.
    int ledPin =  13;    // LED connected to digital pin 13. I used this just to monitor the request/response traffic
    
    void setup() {
      pinMode(buttonPin, INPUT);
      pinMode(ledPin, OUTPUT);   
    
      // Set baud rate expected by Scratch sensor:
      Serial.begin(38400);
    }
    
    void loop()
    {
      int inByte;
      // if we get a valid byte, send the scratch data
      // Technically, we should check that the value is a 0x01 byte,
      // but, meh ...
      if (Serial.available() > 0) {
    
          // toggle the LED so that we can see the request/response activity
          // this is optional, really
          digitalWrite(ledPin, ~digitalRead(ledPin));
    
          // get incoming byte:
          // we really should test the value, but meh++
          inByte = Serial.read();
    
            sendScratchData(0,analogRead(0)); // Resistance "D" is mapped to Analog 0
            sendScratchData(1,analogRead(1)); // Resistance "C" is mapped to Analog 1
            sendScratchData(2,analogRead(2)); // Resistance "B" is mapped to Analog 2
            sendScratchData(3,digitalRead(2) * 128); // Button is mapped to Digital 2
            sendScratchData(4,analogRead(3)); // Resistance "A" is mapped to Analog 3 
            sendScratchData(5,analogRead(4)); // light is mapped to Analog 4 (signal is inverted)
            sendScratchData(6,analogRead(5)); // sound is mapped to Analog 5
            sendScratchData(7,0); // slider did not map slider, but any analog input could be moved here.
            sendScratchData(15,4); // version info The current version is 4
      }
    }
    
    void sendScratchData(int channel, int data){
       byte highByte;
       byte lowByte;
       data = data & 0x3FF;
       highByte = 0x80 | (channel << 3) | (data /128);
       lowByte = data & 0x7F;
    
       // --- send the data
       Serial.write(highByte);
       delayMicroseconds(400);
       Serial.write(lowByte);
       delayMicroseconds(1000);
     }

    Philadelphia Geek Fest


    Hive76 desecrates the Philadelphia Folk Fest Logo

    Friday was a bust — weather was bad and I unexpectedly got stuck at work.

    Saturday was, by objective measures, not a good day.  We had almost no traffic at our spot and one of Matt’s giant QR posters went missing sometime during the day.  But it was a good day .. for whatever unfathomable reasons.  Matt and Chris showed up with a RepRap  and had live 3D printing demos for hours.  We ended up giving away a plastic octopus to some jewelry vendors that we met at random when they parked on my lawn.  The solar weenie roast worked reasonably well (film to come) and we got an MSP430 POV working to display the message “HELLO ARLO”  (film of this on the way as well, you can find source code here).  Matt and Chris used the UV flashlight and the glow-tape pad to design the 5×5 fonts that we used for the POV — it was ingenious.  They would draw the character and when I saw it, I was able to work out the hex codes in my head.  We also used the fresnel lenses to turn ordinary LED flashlights into blinding search beams — when you take even a small light source and focus it to a beam, it’s shockingly bright over surprising distances.

    Sunday — who knows — things are fluid

    I think we’ll try to do this next year, but with a bit more preparation .. and Matt suggested maybe we can get on the fairgrounds proper to do our thing, which I think is a fine idea.

    We will be on this corner

    Cellulose Some, and You Win Some

    I have a new obsession — microbial cellulose.  I have been meaning to experiment with this stuff ever since I read Fermented Frocks, the New Couture.  Recently, my sister’s room-mate was discarding a kombucha culture, long past its prime, and I knew I had to have it — despite the fact that was about the closest thing to two gallons of pure biohazard that I have ever laid eyes on.  I peeled a few layers from the decrepit SCOBY that was floating in the middle of the rancid kombucha, and dried them into tough, leathery, translucent “paper” (see the photo with the “paper” covering a CD for perspective). After that, I was hooked — smell be damned — and after some research, I was really hooked.

    Microbial "paper" formed by peeling a layer from a kombucha "pellicle" (a.k.a. SCOBY)
    Microbial "paper" formed by peeling a layer from a kombucha "pellicle" (a.k.a. SCOBY)

    Continue reading “Cellulose Some, and You Win Some”

    Hive76/UArts Special Event, “Artisanal Technology”, April 23rd at UArts

    Hive76 and The University of the Arts have teamed up for this one, and we managed to persuade Leah Buechley to bring a bit of the MIT Media Lab to Philly in the form of a special presentation titled “Artisanal Technology“.  Showtime is April 23, 11:30 A.M.  The location is 5th Floor, Terra Hall (211 S. Broad).

    Leah Buechley demos some atrtistic options with the LilyPad, using Boulder's Pearl Street Mall as her canvas

    In Leah’s words, “This talk proposes an alternate model for the production, distribution, and consumption of consumer electronics that emphasizes diversity, small scale production, and thoughtful consumption.  I will raise and discuss several questions, including: what kind of technologies can be artisanaly produced–crafted in small batches?  what benefits might society reap from artisanal technology? what benefits might we expect as designers and manufacturers? what tools need to be built to support an artisanal technology ecology?

    You can get tickets here.  Admission is free and seating is limited, so we expect the event to fill up quickly.  If you are interested in attending, get your tickets ASAP.

    The talk is inherently cross-disciplinary, and we have done our best to recruit some of the more colorful members of the Philly creative community to attend.

    We are hoping to have some displays in the room that give a sampling of High Low Tech, Philly Style.  If you have some work that you’d like to display, please feel free to leave a comment — we’ll see what we can do.

    Thanks, and hope to see you there!

    TIWrap makes your LaunchPad steak house handle like an Arduino bistro

    We whipped up a Wiring-ish wrapper for the MSP430 a while back in order to simplify the task of porting Arduino libraries for use with MSP430 microcontrollers.  It turns out, we weren’t the only ones that thought of it.  PJ spotted a post on Hack A Day where someone unveiled something remarkably similar, and that post resulted in at least two other folks besides us posting their similar ideas — so there are at least four of these wrapper libraries out there.

    Naturally, we’d like to think that ours is the best of the bunch, and the best named too — TIWrap.  Seriously, though, we seem to be genuinely different in that that we have bundled in actual libraries ported from Arduino, such as the HD44780 and MAX7221 libraries.  There are some piezo buzzer libraries and we expect to add some Charlieplexing utilities soon.  You can get a copy of TiWrap here.

    The demo above is a “Fancy Flashlight” concept proposed by Matt Torbin.   It’s just one MSP430, two LEDs, a button and a bit of code which you can find in the TiWrap examples.

    And in case the title left you puzzled …

    The Kids are Alright

    This is probably just shameless nepotism under the guise of “DIY video”, but this video by my son Levi had me rolling.  The video camera, computer and editing software were great investments, in my book.

    If you elect to watch, give it at least 30 seconds …

    Tiny Terminal Using MSP430 and HD44780 Display

    We have dozens of these HD44780-based LCD displays — now we just gotta make some use of them.  Here’s an experiment using an MSP430 to create a display that can be written to using serial data.  The displays actually have chips in them that can send the data as a differential signal (a la RS422), so it should be possible to send the serial over great distances if needed. The displays are also waterproof and have a six key membrane keyboard built in.  With the addition of a $1 MSP430, the setup turns out to be a pretty sweet building block …

    A preliminary version of the HD44780 library for MSP430s is available here.

    ICM7228 Libraries in Development

    Here’s a video of a preliminary version of PJ’s ICM7228 library for Arduino.  The 7228 is an LED driver chip that is particularly suited to driving 8×8 LED matrices.  We have a lot of these chips at the Hive, and plenty of 8×8 displays as well, so we’ll see what gets created as a byproduct of the library.