Microcontroller circuit to sense bicycle RPM

This is the place for any magazine-related discussions that don't fit in any of the column discussion boards below.
Post Reply
donwilson
Posts: 5
Joined: Sat Jan 07, 2006 1:01 am
Location: Joplin, Missouri
Contact:

Microcontroller circuit to sense bicycle RPM

Post by donwilson » Sat Jan 07, 2006 8:47 pm

Hi Everyone, I am building a simple stationary excercise bike from an old bicyle. I have the magnet and sensor from an old bicycle odometer and speed computer. The magnet attaches to one of the spokes and the sensor is mounted on the frame to detect the magnet each time it passes. I think the sensor is just a coil but I'm not sure if there may be something else to it. I would like to read this into a microcontroller such as the Atmel ATMEGA16 provide a display such as an LED bar graph and chart progress. I am thinking I might be able to pass a current through the sensor and use the A/D on the microcontroller to read the voltage change. If anyone has done something similar to this or has any advise I would appreciate it. Thanks, Don

User avatar
Chris Smith
Posts: 4325
Joined: Tue Dec 04, 2001 1:01 am
Location: Bieber Ca.

Re: Microcontroller circuit to sense bicycle RPM

Post by Chris Smith » Sat Jan 07, 2006 9:31 pm

If you only want a simple bar graph to increase with speed as your representation, no MC needed.

Just charge a cap with the value of each pulse, and send that to the bar graph [VU] for a voltage increase.

As each pulse comes in the voltage in and draw out is about the same at sub standard speeds, thus no lights are on.

As the speed or pulses increase, the voltage or current pulses increase, but the drain remains the same which raises the over all voltage, and the Bar Graph shows it accordingly.

Figuring out the voltage ratio for in and out can be done with trimming pots and caps.

User avatar
philba
Posts: 2050
Joined: Tue Nov 30, 2004 1:01 am
Location: Seattle
Contact:

Re: Microcontroller circuit to sense bicycle RPM

Post by philba » Sat Jan 07, 2006 10:02 pm

to answer your direct question. It's possible it's a coil, reed switch or a hall effect device. If there are only 2 wires, it is most likely a coil or a reed switch. 3 wires would be hall effect. I'm guessing you are right about the coil.

You can determine if its a coil or a reed switch by measuing the resistance with and without the magnet. If the device is open in one case and shorted in the other, it's a switch. If the resistance is the same in both cases, it's a coil.

You should be able to pick up the induced voltage from the coil and pass it into a comparator. No need to pass current through the coil. The other comparator input can come from a pot configured as a voltage divider so you can adjust sensitivity. You should set up the comparator as schmitt trigger. Feed the output of the comparator into a digital input pin on the micro - it will be a nice clean pulse. You might be able to use the on chip comparator of the atmega though you wont have as much control over the sensitivity. I think you want a schmitt trigger - at very low speeds, noise can be a factor in false pulses. If you have a scope, take a look at the pulses coming off the coil.

<small>[ January 08, 2006, 02:15 AM: Message edited by: philba ]</small>

donwilson
Posts: 5
Joined: Sat Jan 07, 2006 1:01 am
Location: Joplin, Missouri
Contact:

Re: Microcontroller circuit to sense bicycle RPM

Post by donwilson » Sun Jan 08, 2006 6:50 am

Thanks Philba. It is just two wires. I was wrong about it being a coil. I just now connected a meter in ohms and it is open when the magnet is not present and about .5 ohms when the magnet is present. It must just be a reed switch. I thought a switch would wear out too quickly. Anyway, that makes it very easy to interface.

Chris thanks, but I want to use a micro since I want to experiment with some programming such as adding a timer for endurance. In a search of these posts I also found something about connecting a generator to a bicycle and it creating a lot of pedaling resistance under load. I wonder if I could find a suitable generator and make the resistance controllable from the microcontroller by increasing or decreasing the load, possibly with a series of Christmas tree lights. The more lights on the greater the load on the generator and pedaling resistance.


Don

User avatar
Chris Smith
Posts: 4325
Joined: Tue Dec 04, 2001 1:01 am
Location: Bieber Ca.

Re: Microcontroller circuit to sense bicycle RPM

Post by Chris Smith » Sun Jan 08, 2006 1:02 pm

Don

A small bank of Fets make a great load for your generator. You basically short them out to ground, and by adjusting the gate, the resistance changes in a linear fashion.

Fets can handle large loads for their small size and all you need is a good heat sink to keep them steady.

Many load dummies for test equipment use this approach because of its linear load, cost, and simplicity of design.

<small>[ January 08, 2006, 01:06 PM: Message edited by: Chris Smith ]</small>

rshayes
Posts: 1286
Joined: Tue Mar 04, 2003 1:01 am
Contact:

Re: Microcontroller circuit to sense bicycle RPM

Post by rshayes » Sun Jan 08, 2006 7:25 pm

Reed relays (which used reed switches as the contacts) were often rated for 10 million operations. With a 24 inch wheel, this works out to be over 10,000 miles. Even a poor switch should last several thousand miles.

Keep the voltage down to a few volts and the current below a milliamp or two and you should have no problems.

<small>[ January 08, 2006, 07:27 PM: Message edited by: stephen ]</small>

User avatar
philba
Posts: 2050
Joined: Tue Nov 30, 2004 1:01 am
Location: Seattle
Contact:

Re: Microcontroller circuit to sense bicycle RPM

Post by philba » Sun Jan 08, 2006 8:07 pm

even inexpensive reed switches are rated for a min of 100M operations. At 100 rpm, average, that translates into 16K hours. Not as good as a hall effect device (or a coil) but incredibly easy to work with. Make sure you debounce the switch, though.

One thing that bugs me is you are seeing .5 ohms, this seems high unless it has a small current limiter built in. it should work anyway.

I think you don't need a generator - just get a decent permanent magnet motor. it will act as a generator. I'm not sure how big the motor will need to be, though.

donwilson
Posts: 5
Joined: Sat Jan 07, 2006 1:01 am
Location: Joplin, Missouri
Contact:

Re: Microcontroller circuit to sense bicycle RPM

Post by donwilson » Wed Jan 11, 2006 6:29 am

Thanks everyone, I have the bar graph working now using an Atmel ATMEGA16L microcontroller. It is a lot of overkill so far. I'm using less than two percent of the program space. I'm using the INT0 interrupt input and software debouncing to make sure a certain amount of time passes before it will accept another input as valid. I have the internal pull up enabled and I have 150 ohm resistor in series with the reed relay to ground. I have measured the current flow when the magnet is present as 0.1 mA. Would it help the reed switch life to also have a capacitor in the circuit?

I looking for a motor or generator and FETs now to try the variable loading. This should make it possible for me to create multiple modes such as steady resistance, greater resistance over time, and hill simulations.

Don

User avatar
philba
Posts: 2050
Joined: Tue Nov 30, 2004 1:01 am
Location: Seattle
Contact:

Re: Microcontroller circuit to sense bicycle RPM

Post by philba » Wed Jan 11, 2006 7:59 am

while the rest of us are yacking away about trivia, old don here is getting stuff done. sounds great, congrats.

Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests