Wednesday, February 24, 2010

Lego RC with Xbee


I've had a conundrum for a while. How to control my RC projects with a ready-made, swappable controller and power board. Many of my recent projects are Lego based, but some are not. My objectives were:

CONTROLLER:
Dual Analog
Dials
Buttons
Toggle
Extra outputs to allow expansion (serial to LCD screen)
Vibration
9V Powered

MOTOR SHIELD:
More outputs than other motor shields
Use XBee devices.
No tunneling
Hot swappable without reconfiguration
Make as an Arduino shield (to avoid reprogramming)
Servo Outputs
PWM (analog motor) outputs
Digital Outputs
Outputs should be amplified
Integrated trimpots and switches for easy configuration
Technics (Lego) hole compatibility

I set off designing the controller board first. I ordered some components from Sparkfun and got the rest from my local electronics store (Elliot Electronics for those of you in Tucson). Some of the components are from DigiKey as well

I based this design on the atmega 328 surface mount board. I built it from the ground up as a non-shield design, but it's basically an arduino without the USB interface.

Normally I use BatchPCB available through Sparkfun.com to make my PCBs, but this time I tried PCB-Pool. That's why the board looks different.

The output from this board (over XBee) will always be the same. Short packets sent out in API mode to whatever remote device is attached to the other Xbee unit. For convenience sake, I used the Xbee API mode library located here : http://code.google.com/p/xbee-arduino/
Thanks Andrew!!!!


After I got the code working all Peachy-like. I started on the other end of the project. The motor shield



I figured by using some clever programming, i could leverage the existing servo and PWM outputs into a ton more. Using a shift register and some switch logic, I expanded the outputs enough to get:
4 PWM Motor Ports
4 Digital Output Ports
4 Servo Ports
TX and RX unaffected on pins 0 and 1
an enable port (pin 13) to avoid startup jittering

So far I haven't had a chance to mount it into an actual project, but I've got a couple projects at the house waiting to be powered up. As you can see in the video, though. The outputs work great, and using the Power Functions Kit and some Servo brackets (mindsensors.com). I can get more devices attached than by using NXT!

1 comment:

Aaron, Vicki Tunell said...

You are so great. I can't wait to see your tank all powered up at home. Love you

Vicki