Go Down

Topic: Bicycle Gear Indicator (Read 2839 times) previous topic - next topic

bill2009

Hi, I'm quite pleased with how well this worked out.  It's a proof of concept for a motorcycle gear indicator that I want to make.  It's driven by reed switches sensing the pedal arm and wheel rotation driving interrupts into an Arduino RBBB.  It quite successfully tracks gear changes on my mountain bike.




I've posted a writeup on MS Live because it seems easier to host the pics.  Have a look if you're interested http://cid-6648e3bd665ceac9.spaces.live.com/blog/cns!6648E3BD665CEAC9!128.entry?&_c02_vws=1

AlphaBeta

Cool!

Be sure to post updates :)

koyaanisqatsi

Wow, I really like this!  I'm working on a bicycle-related project with my Arduino too, and was considering adding a speedo and cadence display (basically reinvent the wheel on cyclo-computers) to help fill up IO pins.  To know the gear would be very cool too!

You should have much better luck with a hall effect sensor.  It's output should be a clean pulse, even at very high rates.  The tach sensor in almost all engines these days is a hall effect sensor that monitors a magnet embedded in the crankshaft, camshaft or distributor.

Just be careful not to put your motorcycle wheel out of balance with the magnet!   :o
What about elevensies? Luncheon? Afternoon tea? Dinner? Supper?

bill2009

The reed switches work fine at the 1-2 pulses/second but they are bouncy I'm a bit worried about the 20-30 wheel revs a second the MC will do.


I ordered an Optek OHN3019U Hall Effect Sensor from Jameco to try as a replacement for the wheel reed switch.  I'm pretty impressed. In a typical three lead package you get the whole deal: The Hall element, a linear amplifier, a threshold amplifier, and Schmitt trigger, along with an onboard regulator allowing it to run on a range of voltages.  It's also wicked fast with operation up to 200 KHZ - So I could handle speeds up to just under one Million MPH.

Trying it out on a proto-board it seems much more sensitive than the reed switches, with the same magnets it reacts at almost 1/2 in. vs 1/8 in for the reed switches.  The down side is that it means running three conductors out along the MC swingarm vs. two for the reed switches.  One of those leads would be VCC so if something goes wrong I'd risk the power supply.  The reed switches are just connected to inputs and pullups so if they short there's no big deal.

For the moment I'm going to stick with the reed switches.  If I run into a speed or geometry problem on the motorcycle I'll know what I can do with the hall effect sensor.
http://www.jameco.com/webapp/wcs/stores/servlet/ProductDisplay?jameco_page=42&langId=-1&productId=1871908&catalogId=10001&freeText=OHN3019U&storeId=10001&search_type=mfgr&ddkey=http:StoreCatalogDrillDownView

I'm interested in your comment about the tach being driven by a hall-effect sensor.  The wiring diagram shows it coming from something called the "igniter" which sounds exciting but I need to look into voltages and waveforms,

What's your overall project?  If my fabrication and coding skills were up to it I'd be doing a whole control panel display for the motorcycle.

Justin


koyaanisqatsi

The igniter is part if the ignition system - it's the spark timing/trigger portion.  Makes sense on a motorcycle since their engines don't have a lot of the stuff that car engines do.   It's probably not a hall effect sensor then.  Couldn't say what the output of that will be.

My project is a bicycle headlight driven by a hand-made alternator and a very small battery pack (to cover when you're stopped at a traffic light).  One of my primary goals is extreme efficiency in all areas possible to reduce the load on the rider.   I'm using the Arduino to control and display the alternator's output, the LED's temperature and output and the battery charging systems.  Since I have so many IO pins to play with, I later decided to make it an entire dashboard with distance, speed, cadence - and now the current gear.   ;)

http://www.chesterfamily.org/Projects/BikeGenerator/

It's sort of evolved from other projects that I wanted to improve upon.
What about elevensies? Luncheon? Afternoon tea? Dinner? Supper?

skumlerud

Quote
If my fabrication and coding skills were up to it I'd be doing a whole control panel display for the motorcycle.


One of my long term projects is exactly this. The goal is to replace the entire wiring loom (except the engine management) with a couple of Arduinos to control all lights and monitor and log the state of the brakes, engine, suspension etc. There will also be a graphical LCD displaying some of this data, it will probably not replace the current speedo/tacho though. I have prototyped large portions of this project, but so far I haven't done anything on the bike. That will have to wait atleast until next winter.

skumlerud

Quote
The reed switches work fine at the 1-2 pulses/second but they are bouncy I'm a bit worried about the 20-30 wheel revs a second the MC will do.


I think the hall effect sensor is a much better choice. And it's not necessary to read the speed of the rear wheel - many modern bikes has a hall sensor in the primary sprocket cover and a magnet on the sprocket.

bill2009

Quote
And it's not necessary to read the speed of the rear wheel - many modern bikes has a hall sensor in the primary sprocket cover and a magnet on the sprocket.


I guess not my triumph since the speedo is analog. I'm looking at the rear sprocket to mount the magnet with a switch or sensor on the swingarm or chain guard.  The front sprocket is another thought for the sensor though.  It would shorten the wiring be solidly located and under cover.  It could be doing 50-75 revs per second so a divider might be needed there too.

What will your display look like?

skumlerud

Quote
I guess not my triumph since the speedo is analog.


If this is a fairly new Triumph I would expect the speedo to have an electronic pick-up. An old one will for sure have a mechanical pick-up at the front wheel.

Quote
I'm looking at the rear sprocket to mount the magnet with a switch or sensor on the swingarm or chain guard.  The front sprocket is another thought for the sensor though.  It would shorten the wiring be solidly located and under cover.  It could be doing 50-75 revs per second so a divider might be needed there too.


The hall sensor you posted a picture of would give a clean signal, and I don't see any problems in hooking this up to one of the external interrupt pins on the Arduino. In the interrupt handler you store the time since the last interrupt in an array, and whenever you need to know the current speed you use the average time between interrupts to calculate speed.

Quote
What will your display look like?


That is not decided yet. I have a graphical LCD display (KS0108) that I'll use, but I have not decided how the GUI should look like yet.

bill2009

#10
Mar 26, 2009, 05:11 pm Last Edit: Mar 26, 2009, 09:20 pm by bill2009 Reason: 1
Version 2 with High Speed Dual Processor  

I don't know if this is the first bicycle with two separate arduino microprocessors but it's certainly the first on my block!


Because the target platform for this project is my motorcycle I wanted to use this prototype to try out a few things. The first version worked very well at the speeds you see on a bicycle - 60-120 rpm pedaling and 100-150 wheel rpm. I needed to know whether the arduino could handle the motorcycle calculations at 7000+ engine rpm and 1000-1500 wheel rpm.


I decided to use a separate sanguino processor board which I had handy to boost the pedalling speed by a factor of 50 and to mount two extra magnets on the rear wheel so the wheel sensor would see 3 pulses for each rpm. This let me get the tach rpm to wheel rpm for 2nd, 4th, and 6th gears on the bicycle to be roughly the same as the ratios for 1st, 2nd, and 3rd gears on the motorcycle. For example pedaling 60 times a minute on the bicycle in 2nd gear its wheels are going around 95 times a minute. In my simulation this would look to the arduino like 3000 engine rpm and 285 wheel rpm which is a bit like the motorcycle going 20mph in 1st gear. I wasn't trying for accuracy, just the same range of numbers.

As it happened, I couldn't get the wheel magnets placed evenly enough to provide decent results so I ended up just multiplying the wheel rpm by 3 in the arduino code. I could see that it was having no trouble at all dealing with the "engine" pulses even at a simulated 8500 rpm so I don't see any problem moving to the motorcycle.


The Arduino board is much the same as the original.  The de-bouncing hardware for the pedal sensor is gone because the signal from the sanguino booster is clean.  The de-bouncing hardware for the wheel sensor has been replaced by a resistor and capacitor required for the hall effect switch.  I also changed out the smaller red radio shack led display I'd been using for a larger bright green one from Jameco.

The code for the sanguino was a bit tricky.  There's an interrupt routine that calculates the time between pedal revolutions and a main loop that calculates 1/50th of that time then continuously issues pulses that length. So if the pedal goes around once a second the sanguino divides 1000 msec by 50 and starts issuing 2 msec pulses every 20 msec.  I ran into some odd problems with the timing because the arduino delay() function adds more-or less 1 msec to each execution - I ended up unrolling the delay() function into my own code.  Thanks to JCW and Mekon83 on the arduino forums for giving me enough knowledge to be dangerous (the code for both the sanguino and arduino are posted below).


The code for the Arduino stayed pretty much the same with interrupt routines logging the events in a table that is copied out periodically by the main loop.  I made the table larger and I had the tach input log an entry every 10 interrupts and the wheel input every time.  I also changed the gear ratio calculation to be based on tach rpm/wheel rpm rather than the reverse. Any other changes were minor or cosmetic.

Conclusions - Things I learned
  • The arduino had no trouble at all with the interrupt rates.  My table never got more than half full even with the booster pumping out 8-9000 events a minute (150/sec).
  • 9V batteries suck.  Each of these boards went through a couple of them in development.
  • Even the brighter green LED isn't bright enough for daylight use and the wiring is a hassle. I think the MC version may come to use an array of 5 discrete leds - one for each gear.  If I use Charlieplexing to drive them I can stick the RBBB under the MC tank and run just a 3 conductor lead up to a little display on the handlebars.
  • I now see this as entirely practical for the MC with very little hardware required.  I'll either tack the few extra components onto an RBBB or wire it up from scratch on perfboard.

Next Steps
Obviously I've actually got to get poking at the motorcycle pretty soon but I do want to try a couple of things first.  
  • Find out what the tach pulses look like on my bike or plan to use inductive input from the spark plug leads.
  • Figure out how to run the RBBB or similar power supply in what I'm told is a noisy MC electrical environment
  • Get a persistent bluetooth connection working so I can debug the motorcycle with my laptop by the roadside.


Again the writeup pics and code are hosted on a windows live blog at http://cid-6648e3bd665ceac9.spaces.live.com/blog/cns!6648E3BD665CEAC9!154.entry?&_c02_vws=1

Addendum
1) The original version of this project got a writeup on the make magazine blog which I thought was great. http://blog.makezine.com/archive/2009/03/arduino_bicycle_gear_indicator.html?
2) We are heading home from our winter hideaway so i had to return the mountain bike i was using as my test mule.  As I was making the 16 km trek it occured to me that it would, in fact, be nice to know what gear I was in!  Maybe there is some point in the bicycle version after all.

Go Up