Monday, February 1, 2010

Arduino + XBee + Wii Remote

Woot!  Our Wii Remote controlled robot!  I'll write up the details soon.

ULN2803a is a sink!

Keeping true with the title of this blog, I fought with a ULN2803a over the weekend.  I was attempting to create a simple mood light with my daughter.  We were able to quickly construct a mood light using a small RGB LED from SparkFun.  It was fun, but didn't look like a mood light.  The plan going into the project was to use a ULN2803a Darlington array to drive three 3-watt LEDs and place the resulting circuit in a frosted light globe.  I fiddled with the 2803, reading and fiddling until finally I figured I was much to stupid to use this relatively simple device.  I looked at circuits but it just wasn't clicking.  So, I decided to shelve the 2803 and merely place a white ping-pong ball over the RGB LED.  The results were actually quite nice and it makes a very cool night light.

However, I am nothing if not persistent (check my other blog to read all about my all about my adventures with persistence).  So, after getting KK her coffee, I did a bit more reading and finally figured out that the source of my boneheadedness was a sink!  Huh?  The 2803a (and several of the related devices) are current sinks not sources!  Basically, the load (LED) needs to be hooked into the high side of the load voltage with the low side (i.e., negative) hooked into the ULN2803a.  Duh!  What was throwing me for a loop was the fact that the high load voltage source is also hooked into the 2803.  I just kept thinking that the device would output the load voltage level (in my case 9 volts).  But I kept reading near zero at the outputs.  Only after looking at the device schematic for the umteenth time did it dawn on me that the purpose of the common hookup was to supply the built-in protection diodes a path to dissipate reverse current spikes.

I quickly hooked this all together to make a sizable mood light.  The schematic is here.  And a quick video is here.

Sunday, January 31, 2010

Connection XBee Series 2 (AKA ZB Pro/ZNet) to an arduino

My goal was to have two xbee series 2 modules communicate to each other in a two way configuration.  I found the the various instructions on the internets to be confusing and hard to follow (but then again, I am no Rocket Surgeon).


My first mistake happened before I even got out of the shoot.  From what I have read, the series 1 xbees are way easier and probably better suited for this task.  But that is not what I ordered.  sigh.


My second mistake was only ordering one communication cable (intending to use my Arduino for the other side of the communication).  The cable is way useful and easier to use and works with the X-CTU (the xbee configuration utility) without any additional monkeying around.


Nevertheless, I am nothing if not determined (yes, I am slow as a frozen turkey when it comes electronics, but I do eventually get the job done).


Here is my setup:

Step 1: Configure the XBees
  • Grab the XBee control software (X-CTU) from Digi
  • Plugin one of the modules using the USB to TTL-232 cable and set it up to be the Coordinator (ZNET 2.5 Coordinator AT)
  • When first starting, setup the xbees to send and receive from any other compatible ZNET device (running at the same frequencies, etc) by setting
    • Destination Address High (DH) to be zero (0), and
    • Destination Address Low (DL) to be FFFF.
  • Pick a PAN ID (it doesn't matter, just so long as you use the same id on both xbees)
  • Write the configuration changes to the xbee (at the point, I hooked up this xbee to my arduino running the sample soft serial program in the NewSoftSerialLibrary).
  • Plugin the second xbee module into the USB to TTL-232 cable and set it to be an End Device (ZNET 2.5 ROUTER/END DEVICE AT)
  • Set the DH and DL as above
  • Set the PAN ID to the same id as above
  • Write the configuration to the device
  • Now use serial terminals to send packets between the modems. (I like putty, but the built-in terminal emulators in arduino and the X-CTU programs will work as well).
Finally, the blinky lights on the xbee adapter kits can tell you about state of the xbee modules.  You really want to see the green LED blink constantly.  The red LED will light to indicate when data is being received (as far as I know).

And there you have it.

The resources which I found useful in this little endeavor: