Go Down

Topic: help for motorbike gear indicator (Read 2476 times) previous topic - next topic


Jan 20, 2011, 04:25 pm Last Edit: Jan 20, 2011, 04:26 pm by monsterfactory Reason: 1
hello I'm making a gear indicator for my motorbike.
the ratio is engine pulses / wheel sensor pulses.
so I have 2 arrays, minratio[gear] and maxratio[gear],they hold the min and max values of the ratio for the gears. for example for the 1st gear minratio[1] = 10, maxratio[1] = 13 ,2nd gear minratio[2] = 13, maxratio [2] = 15 and so on.
I thought to do something like: if (ratio < maxratio[1] && ratio > minratio[1] ){gear =1;}.... but it seems (it's) a sloppy way of coding...any hints are really welcome!thanks in advance!  


For any given gear, there should only be one actual ratio.  Why do you have a min and max ratio for each gear?


yes it's true, but due to the gears play, i get different values of ratio every update. I read how many wheel pulses i get, when the engine reaches 100 pulses, and then do the ratio math. the number of wheel pulses are slightly different for the same gear, but they are in a restricted range.


So, store the "expected/ideal" gear ratio in your array.

Take your actual reading, calculate it's adsolute deviation from each of your ideal gear ratios, and select the one with the smallest deviation as the gear you are in.  So long as there is no overlap, the smallest deviation will always be the gear you are in.


Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131