This project started with the tiny Solarbotics GM10 motors that just needed to be used for something. I figured it had to be small so I went for a basic bot that used just a PICAXE 08M chip for logic and a SN754410 motor driver.
The 08M only has about 256 bytes of code space which is about 220 lines of Basic at most. That doesn't seem like much but the PICAXE chips already have firmware to support a bunch of stuff like servos, I2C and more. Still, it was a bit of a challenge to get some decent behaviour out of a little chip.
An infrared sensor was added so the bot could see things to avoid and some LED's show the direction of the motors. That lead to a soldering mess :(
No prizes for appearance here! A piece of perf board was used for the chassis cut to size with a hack saw. On top I added a SN754410 motor driver chip and a PICAXE 08M using dip sockets so they could be replaced if need be. The SN754410 datasheet recommend EMF protection diodes but it's cheap anyway so I have skipped those.
A stereo socket and supporting resisters where added so the PICAXE chip could be reprogrammed in situ and a power switch added on the other side because pulling batteries out is a pain.
At the front is a Sharp GP2D120 infrared sensor which has a range of 4-30cm. It has a 10uf electrolytic capacitor soldered between the power and ground lines as this helps stabilise the voltage. Sharp recommend that somewhere.
Green and red LEDs are on both sides, wired to the motor connections with current limiting resistors in line. Because they are diodes they will only light up when the power is the right polarity making it easy to show direction. Joining to the motor connections also makes the LEDs shine in proportion to the motor power.
Also on the top are some transistors to do some sneaky tricks to get forward and reverse motor control from the 08M, some motor noise suppression caps and the half the batteries.
All the electronic components where soldered in first then the big bits where added.
It's all held together with gooey glue goo. Bostick hot glue - my favourite.
Underneath it gets messy. I jammed another two AAA batteries, a ball caster and hot glued the motors in place. It got quite confusing trying to ensure the circuit was correct.
This schematic was drawn after the robot was built so it may be a little wrong. It also explains why soldering little jumper wires everywhere became a bigger mess than I though. Click for a bigger view.
"PICAXE Programmer, Logic, Power"
The motor driver requires two pins for direction control of each motor and since there aren’t many output pins on the Picaxe 08M a little trick is played to control the motors. Q1 & Q2 each form an inverter logic circuit so when Pin4 goes high MA1 is high and MA2 is low and vice versa, similarly for Pin2 and MB1, MB2. This gives direction control for both motors from just two pins on the Picaxe. To stop the motors and provide speed control both motors are enabled via the only PWM output pin on the 08M. From only three pins we now get full speed and direction control of both motors.
The stereo socket is wired up to enable the PICAXE 08M to be programmed on the board.
Two LEDs are use for each motor. When the current switches direction the appropriate LED will light up because they are diodes. C1 & C3 are used to suppress motor noise.
The code for the robot is just a simple state machine implemented as a if-else and switch-case construct. I've attached the code as a file.
The code reads the value from the Sharp sensor using the readadc function then determines what should happen based on the value. It will either go forward, veer left or right or go backwards.
Sometimes the robot would get stuck or caught on something. A counter is used that is reset when the robot does something like change direction. If nothing has happened for a while the counter will trigger the "get out of trouble" manoeuvre involving some full power reverse and wiggling.
Here’s the complete list of parts for reference:
- 2 x Solarbotics Gear Motor 10 (GM10)
- 2 x GM10 Wheel
- 4 x AAA NiMh batteries. Bought at the supermarket
- 1 x Sharp GP2D120 IR Distance Sensor (4-30cm)
- 1 x 3 Pin JST cable for sharp sensor
- Veroboard cut to size
- 4 x AAA pcb mount battery holders
- 1 x Pololu 3/8” metal ball caster
- 1 x PICAXE 08M Chip
- 1 x SN754410 motor driver
- 1 x 3.5mm stereo audio jack
- 1 x Miniature DPDT Panel mount switch
- 2 x Red LED (Motors Back)
- 2 x Green LED (Motors Forward)
- 1 x Yellow LED (Power)
- 2 x 712 PNP Transistors
- 2 x 0.1uf Ceramic capacitors
- 5 x 330 ohm 0.25W resistors
- 7 x 10K ohm 0.25W resistors
- 1 x 22K ohm 0.25W resistor
- 1 x 10uf electrolytic capacitor