By Chris Bruner
My goal in this is to learn about motor drivers, distance sensors, and have a platform that I can use for experimentation.
To that end, I preformed a frontal lobotomy on a remote control hummer. The car was originally around $20, so even if it went up in flames I wouldn’t be out that much (initialy).
The first step was to take the outer body off. Then snip snip the brains are out. The mechanics of the car seem to be really well designed, the electronics not so much.
Next is upgrading the battery to a lithium-ion battery instead of the double A’s. I’ve done this with other projects. I use the VPX’s which are a 7 volt battery used in home power tools. They are no longer in production, so I snarfed up the last available from Home Depot. They are great because I’ve got a charger made for them, they are relativily small, and they don’t put out enough voltage to make me want to wear rubber gloves.
The next step was put in a motor controller, as well as an arduino. Both were bought from solarbotics. The motor contoller (a fun little project in itself) is mounted above the battery, and the arduino above that. The motor controller has LEDs that show the direction of the motor and when the motor is turning, and the motor controller can control two motors, so 4 lights in total. These got attached to the outer body.
The next thing added is a distance sensor. This is the first sensor added and where the software starts. My first project with my new platform was to make it stay a certain distance from whatever is in front of it. Through experimentation, I’ve found that I need to have a delay in the loop, otherwise the poor thing just sits there nervously shaking, decisions happening faster then it can react. I then tried from memory adding PID code, which gave it a rather agressive stance. It would run at an object, slow down, then back away from the object, over and over. I believe that I’m getting closer. wikipedia has some psudocode for PID controller
previous_error = setpoint - process_feedback integral = 0 start: wait(dt) error = setpoint - process_feedback integral = integral + (error*dt) derivative = (error - previous_error)/dt output = (Kp*error) + (Ki*integral) + (Kd*derivative) previous_error = error goto start
That i’m going to try soon.
One problem that I noticed was that the usb connected to the Arduino was affecting the readings, so I could get things nicely tuned on a stand with the Arduino attached, but as soon as I disconnected the PC and ran strictly off battery power, the settings changed.
To that end I’ve added a bluetooth addapter. I’m excited about this, because I realized that I can do some major cpu programming on my laptop and the little Arduino only has to handle the I/O. I’d like the whole thing to be autonomous, but for now this is good. Maybe my next one will lug around a laptop.
The blue tooth adapter works fine on the Arduino, but getting the laptop to talk to it ended up being rather difficult. Finally got a device to work at /dev/rfcomm0 and if I cat’d that device I’d get all the data that the Arduino was spewing out. (Distance measurments and so on).
A trick I discovered the hard way is programming the Arduino can’t be done while the Bluetooth is online. Another switch to come for easy Bluetooth disconnect.
At this point, the RC Car has:
I’ll do more updates as I progress.