Wednesday, February 07, 2007
Computer Controlled RC Car
Computer Controlled RC Car on Vimeo
After working on this project all night, I've finally managed to control the RC car with my computer! I bought this cheap car from a local toy store a few days ago. I didn't go for high-end cars because, apart from being expensive, they use analogue signals to give precise speed and direction control. Cheap cars have a digital controller that uses switches for controlling left/right/forward/backward movements, and not potentiometers.
The first step was to modify the car's controller so that it could be interfaced with my computer. The buttons on my car's controller simply push down upon some micro-switches on the board, closing the circuit for controlling forward/backward/left/right movements. After identifying the 0 V ground and the active (control) points on the controller, I soldered wires to each of those points.
The next step was to build a circuit for connecting the car's controller to my computer's parallel port. My circuit is really simple as I didn't use relays. I only used four BC547 transistors as switches. These transistors, in effect, ground the controller's active points when they get a signal from the computer's parallel port.
I connected my computer's parallel port to the car's controller using this circuit and it worked right from my first attempt! The software for controlling this car is fairly simple and it allows me to control the car with the arrow keys on my keyboard. I want to share a little tricky problem which I had encountered while testing the program. When my computer tried sending two commands at the same time, like turn right and move forward, the car behaved unpredictably. Sometimes it obeyed the computer's command, and sometimes it just moved forward without turning at all. My first guess was, that something was wrong with my circuit. I tested the circuit a couple of times but it seemed to be working perfectly. I almost gave up on it until it occurred to me that my computer's parallel port was sending two signals (one for forward/backward and the other for left/right) at the same, exact time. The car's controller was unable to handle two commands together. When humans control the car with its controller, they normally don't press two buttons exactly at the same time. So, I modified my program and put some delay between all possible combination signals (like left + forward or right + backward etc) and it worked! So, now the sequence of commands for making the car move forward and left is something like: [left] -> [delay] -> [forward].
I really enjoyed working on this project. I'm really looking forward to using this car in my future projects! I plan to attach a wireless camera on the car for some extra fun. However, I don't have a wireless camera at this moment. I really hope I get a nice and cheap wireless camera soon or make a wireless link for my good old webcam. Anyway, I hope you found this project interesting. I'd love to hear your comments and ideas. Feel free to contact me if you're planning to build your own computer controlled RC car and have questions about it.