Saturday, August 22, 2009

Bicycle Speedometer Project

Here's a new project I've been thinking about building: a bicycle speedometer.

At it's core, it's just a simple reed switch hooked up to a PIC microcontroller's CCP module (in capture mode) which measures the period of the turning of the wheel. Based on the period data, the microcontroller then calculates the speed and displays the information to the user on an LCD screen. Now, to dive in deeper...

This project can, of course, remain as simple as a mere speed measuring device or can be expanded into a full bicycle computer which maintains trip logs (time, distance, speed, keeping track of rest breaks), control headlights based on ambient light and so on.

The main speed measuring module consists of a reed switch mounted on one of the front forks. A strong magnet shall be placed on one (or more) of the spokes. Every time the wheel turns, the magnet will pass the reed switch and close the circuit, sending a signal to the microcontroller. The microcontroller is then interrupted by the event and the CCP module then measures the period. To compute the speed of the bicycle, only the circumference/diameter of the wheel and the period must be known. Although only one magnet is required, more can be placed to allow for greater accuracy. On the PIC's side, an appropriate external crystal shall be used with the CCP's timer to allow for millisecond timing. With the appropriate crystal, the CCP can then measure the period (in milliseconds) of the wheel to produce very accurate speed readings. Readings can be presented to the user every 1 second, for example. The LCD can be of HD44780 type or this or this or one of the graphic LCDs at Futurlec. The LCD should be small and readable yet consume as little power as possible. The microcontroller itself will be in sleep mode most of the time to conserve power.

A real time clock and SD card (via SPI interface) can also be added to the project to allow for data logging and to add a simple real time clock. The RTC will maintain time via a "backup battery" and the SD card would be written to every now and then.

The entire computer could be powered by batteries. But since the computer consumes less than a few mA at most, a solar panel is also possible. Or it would also be possible to use the energy generated by the bicycle and store it in capacitors.

As for the core of the computer, any PIC would do for such a relatively computationally non-intensive job. However, I was thinking of using the dsPIC33FJ128GP802 :)

3 comments:

  1. I've heard of a few "open hardware" PIC-based bicycle speedometers.
    Perhaps we can combine our ideas to make one (or a few) really good designs that turn out better than anything any one of us could put together alone.

    http://opencircuits.com/vehicle

    ReplyDelete
  2. I have also been thinking about a PIC chip based odometer/speedometer since i can program the wee beasties. I propose accumulating wheel rotation pulses for about 5 seconds to smooth out minor variations, use a table lookup instead of complex conversions and perhaps a solar cell for basic power. Will keep you posted.
    Larry Self mself36@yahoo.com

    ReplyDelete
  3. Hi, has anyone got any information on how to create a wireless speedometer for a bicycle?

    ReplyDelete