| March Break 2011 - Robot Challenge
R/C robots are fine but I like autonomous robots best. For this March Break I'm hoping to host a "Build You Own Robot" party for my son and his two friends. I've built small robots in the past so I thought I would challenge myself to come up with an easy to build, cheap robot "kit" plus code. I have two and a half weeks.
First I surfed the web looking for cheap servos. When modified for continuous rotation, servos make great robot motors. They contain their own driver electronics, are easy to control from a microcontroller and they are geared for greater torque. I found a great deal at hobbypartz.com. The T-Pro Mini Servo SG-90 9G Servo was available for $2.77 US each. Modifying them for continuous rotation takes about 10 minutes. Not too hard.
For the "brain" I decided to use the PIC18F1320. I had a bunch of these lying around looking for a problem. The PIC18F1320 can run using an internal 8MHz clock so this helps reduce the overall part count. It also sports numerous timers, three digital ports that can trigger interrupts (great for switches), plus a six channel, 10bit A/D convertor. For power I used a 4-cell AAA pack. The design works with both rechargable LiMH as well as straight alkalines.
I wanted the robot to be able to perform several classic actions. Line following is a fun behaviour and amenable to racing. Secondly I thought that a mini-sumo-like mode would be fun. Lastly, if time permits, a follower mode would be nice. I've included a mode switch so that toggling between modes will be easy.
Line following requires at least one downward facing sensor. I used a simple red LED to provide light plus a phototransistor (Everlight EL-PT204-6C) to measure the reflection. The LED is fed directly from the PIC digital output. The PIC18F1320 digital lines are current-limited to 25mA eliminating the need for a series resistor. When the sensor faces a white surface, light is reflected back towards the phototransistor which conducts and the voltage drop across the serial 47K resistor is about 3.4V. When over a thick black line, the phototransistor sees less light and conducts less. The voltage drop across the resistor decreases to around 1.9V. An easy different to measure with the PIC's A/D.
For sumo behavior a forward facing sensor is needed to hunt for the opponent. The downward facing sensor will be used to keep the robot in the ring. I used an ultra-bright red LED to provide light and another phototransistor to look for reflections. The ultrabright LED needs more current than the PIC can deliver so I used a PNP transistor to turn the LED on and off. When the controlling digital I/O line is high, the current is off. When it's low, the LED shines. Looking into a void, the voltage drop at the sensor is near 0V. Facing a white card the voltage drop is 4.5V at 2cm, 2.8V at 4cm, and 1V at 6cm.
To guard against changes in ambient lighting, both sensors measure first with the LED's off and then again with the LED's on. The difference between these two readings is used to determine actions.
Finally, a couple of collision sensors (switches) could prove to be fun. So far I haven't used these as bumpers but rather as input switches for calibration mode.
I had the PIC microcontroller, LEDs, and phototransistors "in–stock" in my parts drawer. The servos I ordered from HobbyPartz.com. Most of the remaining parts were scavenged from old boards. I collect these from the local electronics recycle dock here at the University.
Learning from past projects I decided to eliminate as many wires as possible by mounting everything directly onto a PCB and to use that as a chassis. So that the board would be easy to make I decided on a single sided design that I could make via toner transfer.
Next Section: Building The Bot