Blog

Remote control car speedometer V2

Mar 29, 2009
Category:Electronics Arduino 

After my semi successful prototype of my remote control car speedometer project using a reed switch, I'm back with version 2, this time using a hall effect sensor.

The same principle applies as before, there is a magnet on the wheel that passes the sensor each revolution allowing the speed to be calculated. However the hall affect sensor is quite different from a reed switch. The reed switch is either on or off depending on whether it's been activated by a magnetic field. The hall effect sensor gives an analogue output measuring the strength and polarity of a magnetic field. This required a rewrite of the software, including a calibration function, and I also added some goodies while I was there.

I used my strip board Arduino SD card writer for the main board for this project. I designed it with this project in mind so it already has three connectors to allow the hall effect sensor to be connected.

Calibration only needs to be done once, unless any of the hardware is changed or replace, and is performed by holding down the button whilst powering up the device. The magnet must be away from the sensor during this process. This takes a reading and stores the value to the ATmegas EEPROM. This is our baseline value, and as the wheel rotates and the magnet passes the sensor the current reading will stray from this baseline value, and we log the milliseconds taken since the last rotation to the memory card. There is a bit more maths and logic involved to try and reduce false readings, but I won't go into details here.

If the card is not present or failed to initialise the LED will flash constantly signifying a problem. Once the system is initialised the LED will flash once every time the magnet passes the sensor, and will also be logging this information to the card.

Before the card is removed the button must be held down until the LED is constantly lit, this flushes (writes) any data that has not yet been written to the card, much like un-mounting/ejecting your USB stick or memory cards before removing them from the computer.

The other goodies I mentioned is a race and driver selector. Pressing the button will mark the end of the current race and the beginning of the next race. The number of times the button is pressed in succession indicates which driver will be racing next. When reading the data into the computer this allows the data to be split into separate graphs for each race and they can also labelled with who was racing. An example follows of the results of me testing this functionality...

Race #Driver #Race Time (Secs)Top Speed (MPH)Avg Speed (MPH)
1 1 5.80 4.89 4.47
2 2 12.16 7.21 5.49
3 3 11.61 4.82 3.14
4 1 3.23 4.09 3.77


The graphs have been omitted, but this data table would be accompanied by four graphs, one for each race.

Time for a road test....

car with speedo

I mounted the device to the car, wired it up and power it on, and it initialised fine. I had a spin up and down the road and came back, pressed the button to start a new race with another driver number and had another spin, I did this several times with various different driver numbers and then flushed the buffer to the card. I took the card out and put it in my computer expecting to see quite a few different race graphs. I was only shown two races and graphs, one looked a complete mess and the other didn't really have much data on it at all. Here is the messy graph...

graph

Not a lot of use, and I'm fairly sure it wasn't doing 700 mph. After a bit of an investigation I found the cause was electromagnetic interference from the car's motor or speed controller interfering with the readings from the sensor, also possibly interfering with the data being written to the card. I tried mounting the board in a grounded tin but that did not seem to help much. What seem to help most was moving the board away from the cars electronics and also twisting the hall effect sensors output signal wire with the ground wire. I also shortened the wires as much as possible.

Finally I got a sensible graph of me doing top speed, and here it is...

graph

The points that look like they're in the wrong place, being much lower than the points around them are because a reading is missed every time a sector is written to the SD card. I'm sure this anomaly can probably be hidden in the software somehow, but are not overly concerned with this at the moment.

Still a fair bit of work to do, but a definite improvement on the first version which was unable to measure my top speed. Occasionally I seem to get no, or random data on the card and also my average speed calculation is far from accurate, but all things that I think have relatively easy solutions.

I guess I need to find some other drivers now and we can do some time trials and compare results :)


Comments