Sunday, December 18, 2011

Traction Control Part 1.1 - Monitoring Wheel Speed

The Atmega328 microprocessor at the heart of the Arduino is able to process 16 million operations per second.

The wheels or my test car running at full speed turn 68 times per second.

The Arduino is able to perform around a quarter of a million operations in the time it takes for my radio controller car wheel to rotate once.

Given these numbers I was confident of being able to monitor the speed of all four wheels, however I wasn't so sure of how to electronically sense the mechanical movement of the wheels. There are several challenges here -

1) I can't add anything to the wheel which upsets the balance, so no metal or magnets.
2) I have very little room to work with between the wheel and the wheel hub so have no option to add beam breakers to the wheel.
3) The front wheels need to turn freely in order to steer so I cannot impede their movement and cannot rely on a constant angle between the wheel and the sensor.

The solution I chose was to use pairs of infrared emitter and detector diodes.

  • Cheap
  • Easily Available
  • Non-invasive
  • Side facing design

The 'side facing design' means that the light is emitted and detected through the side of the diode, in our case this is an advantage as the diodes are very slim in profile and as the leads exit at the bottom this allows us to mount the diodes lying flat. The diodes are 2mm tall when mounted this way leaving around 10mm between the wheel hub and the wheel.

Most IR Sensor circuits rely on 'beam breaking' where an object passes between the emitter and the detector - breaking the beam. This is not an option in my case due to the small amount of space available and the amount of vibration present in the wheel and the hub.

One idea I had was to try sensing reflectance instead, to do this I initially set up a circuit with both the IR Emitter and Detector facing out from a prototype board. I then fixed a small strip of white tape to one of my tyres. At low speeds I was able to detect the white tape passing the in front of the sensors and count the revolutions per second. At this stage I was not concerned about higher speeds as the design was far from optimal.

The next step was to develop a package for the IR pair that could be mounted in the car between the wheel and the steering hub.


To do this I first trimmed the leads of the diodes and soldered on some flexible wire which I could later route around the car. I also used a layer of heat shrink to protect the wire joint from electrical shorts and mechanical wear.

Next I used double sided tape to mount the diodes to a square of styrene which I then glued to the wheel hub.



You should be able to spot the sensor mounted to the steering hub in the center of the picture below.


To ensure the best quality data I needed a sharp transition from reflecting to non-reflecting. To achieve this I sprayed the inside of the wheel satin black and then mounted a strip of 'bare metal foil'. This is an aluminum foil that has an adhesive on one side, its usually used for adding metal details to small 1/32 and 1/43 model cars and for this reason is exceptionally thin and therefore light enough not to upset the balance of the wheel.


On the other end of the sensor wires I soldered individual header pins allowing me to easily plug the sensors into my prototyping board.


Note that as I used a common ground wire for the two LEDs reducing my connetions from four to three.

I have made and mounted a set of sensors for both front wheels and now that I have proved the concept will eventually make sets for the rear wheels in order to monitor traction at all four corners.


Next up - connecting to the Arduino and writing the software, here is a preview -

Monday, December 12, 2011

NPN Transistor Sketch (P2N2222AG) using PWM

We are now going to build a simple circuit to test out the P2N2222AG transistor in the sparkfun inventor's kit. You can also buy this transistor from RS-online.

Here are the components that you will need.
  • 1 x Arduino UNO
  • 1 x Breadboard
  • 1 x P2N2222AG transistor
  • 3 x LEDs  (1 x Red LED, 2 x Yellow LEDs)
  • 3 x 330 ohm Resistors
  • Wires to connect it all together.
Here is the Fritzing sketch:






We will use Pulse width modulation (PWM) to fade the LEDs in and out. 
Load the "Fading" example into the Arduino. (File>Examples>Analog>Fading)



I used this sketch to help me understand how electricity flowed through the transistor by disconnecting a wire here and there. I am not sure if this is advisable, so do this at your own risk. If you are an electrical engineer, feel free to comment. Please let me know if this is "risky" business.
I have had no formal training in electronics, so don't blame me if your arduino, or transistor blows up !
But from what I understand, I cannot see any harm in disconnecting wires with this particular circuit.
Please note, that I would disconnect the power to the arduino before modifying the wires.

Tuesday, December 6, 2011

What can I do with an RC Car and Arduino ?

One of the strengths of the Arduino is the ease with which it can be interfaced with inputs (sensors) and outputs (motors, servos, LEDs, speakers etc, etc, etc)

In the coming weeks I hope to be able to build the following radio controlled car based projects

1) G-Force Logging - use an accelerometer connected to the Arduino to measure acceleration and deceleration and log this data to an SD Card.

2) Traction Alarm - use infra red sensors to measure the speed of the wheels and sound an alarm or flash a visual signal whenever the speed of one wheel exceeds the other by a given percentage

3) Training Mode - It would be nice to have a button to push to put a car in training mode, this would limit the power to 25 or 50% allowing me to pass the controls to my kids and then easily return the car to full power when I get the controls back

4) Traction Control - This is really a combination of 2 and 3 with a lot of extra work required. The circuit from 2 would be used to detect wheelspin and the circuit from 3 would be used to manage the power being requested from the motor. With some experimentation it should be possible to create a program to vary the motor power based on the degree of wheelspin detected and the amount of power being requested by the driver. It would also be nice to combine this with 1) to be able to log acceleration with and without traction control.

5) Traction Contol with Brake Force Control - Assuming that 4) can be made to work, the next logical step is to add active brake by using the same principle to detect a wheel locking and automatically reduce the brake force.

6) Yaw control - Yaw is movement in the left to right axis, like the fishtailing that rear wheel drive cars produce under hard acceleration. It is possible to sense this using a gyroscope and have the car automatically correct by steering into the skid.

7) Active Torque Distribution - In a twin motor car it should be possible to send power to which ever axle is generating the most grip

And now a quick look at some cars

Rear Wheel Drive Tamiya F103 GT with HPI Zonda Bodyshell


Front Wheel Drive Tamiya M03 with Kamtec Beetle Bodyshell


This final car is a front wheel drive car joined to a rear wheel drive car, it was an interesting project and very fast, much faster than the two donor cars.

Custom 4WD Twin Motored Car

Unfortunatley as fast as this car was, the handling was too unpredictable. The rear of the car was built from a Tamiya M04 a car with notoriously bad handling. Getting this car to handle will require Active Torque Distribution at the very least.