This is the second part in a howto series about building a relatively cheap robot out of a radio controlled car and an embedded microcontroller such as the Basic Stamp.
In part 1, I glossed over how to interface a microcontroller with the drive and steering systems on a typical, cheap RC car. Today, we'll be looking at the circuit in a little more detail. I've also added the simple BS2 program that I used in the demo video from the previous article.
The H Bridge
The h-bridge is a simple circuit that you can make to control power to a motor from a low power circuit such as the logical IO from a microcontroller.

Here you can see the circuit I used in my project. I/O A and I/O B connect to the I/O pins on the Basic Stamp (BS2). The +6V is the positive terminal on the RC car battery, and at the bottom VSS connects to the BS2 ground and is also grounded to the negative terminal on the battery.
Here's how it works. When A and B are both off, the PNP transistors at the top of the circuit will allow current to flow, but the NPN transistors at the bottom will not. Similarly, when A and B are both on, the situation is reversed with the NPN transistors being on and the PNP transistors not allowing current to flow. In either scenario, there is no path for electricity to get from the battery to ground.
Now if I/O A is on and B is off, the NPN pair at the bottom left and the PNP pair at the top right will both be open. This creates a circuit that allows the current to flow through from the top-right, through the motor, and down the bottom-left, and down to ground. This causes the motor to spin in one direction. Raising pin B and dropping pin A has the opposite effect, causing the motor to spin the other way.
The h-bridge effectively gives us 3 states: off, forward, and backward. On your car, you can use one of these circuits to control the drive motor, and another h-bridge to control the steering motor.
Components Used
R1, R2, R3 and R4 are all 1K resistors. In my setup, Q5, Q6, Q9 and Q7 are all smaller signal transistors. You can probably get away with whatever you can find at your local electronics store.
The important thing is that Q1, Q2, Q3, and Q4 can pass enough power to meet the demands of your motors. The spec you are looking for is the collector current (Ic). 3A should be quite sufficient for most cheapo RC motors. These will be the transistors with the attached heatsink. I used the TIP31 and TIP42 models that I found at the local Radio Shack.
You'll notice that all the transistors are paired up. These are called Darlington Pairs. It allows a low current source, such as the BS2 IO, to amplify its current with one transistor, and use that output to saturate the higher power transistor which is used to drive our motor.
Caution
In this circuit, it is very important that the BS2 ground (VSS) and the battery ground (-6V) are connected. Also, the I/O pins cannot be floating, so you should have the battery disconnected if the BS2 is not running. Otherwise it will only take a few seconds to smoke your transistors.
A Note On Making Schematics
This is the first schematic I've ever made, so please pardon any sloppiness or common newbie errors. If you've never done this before and you're interested in making a schematics, I recommend trying Eagle. I used the freeware Mac version and was pretty happy with it.
Other Ideas
If you're lucky in your hunting you may find PNP and NPN Darlington Transistors in a single package. Grab those and swap them out for the pairs above and you'll save yourself some wiring.
Robogeek also informs me that the LMD18200 is a pretty fantastic h-bridge on a single chip. It can provide 3A continuous with a 6A peak and you can avoid all the messy wiring. Wicked! I ordered 5 samples from National and they sent them free of charge and even sent me a thank you letter. How cool is that? I'm looking forward to trying these out and I'll make sure to report back.
Programming
At this point, we've got ourselves a fully functional robot platform. You'll need to add sensors, etc. to make this more autonomous, but you should have everything you need to drive a car around under the control of a teeny microcontroller.
Attached is the program I used for my demo. As you can see, there's nothing magic here. There are a few routines to turn the motors on and off, do a 2 point turn in place, etc. The main routine ties a few of these together to make the robot drive around a little bit.
Get Busy
I'm really excited to see other people make these. I'm working on a GPS guided version, but there are a lot of other possibilities as well. This is basically a nice little platform that you can use as a starting point for any mobile robot project.
Make sure to tell us your ideas in the comments. If you're working on an r/c car robot yourself, let me know about it and we can add it to the series.
Trackback URL for this post:
http://www.blogcadre.com/trackback/686
from MAKE: Blog on November 14, 2005 - 7:44am
Here's part two of Jason's HOW TO make a robot car - "This is the second part in a howto series about building a relatively cheap robot out of a radio controlled car and an embedded microcontroller such as the Basic Stamp." Link.