mattcarr wrote:Peter I will have a go for you.
we know that there are 4550 pulses per mile traveled and
you are reading the pulses per second
s = speed in MPH
x = pulses per second
s = (x*3600)/4550
Should give pulses per hour divided by pulses per mile to give you a mile per hour figure.
so for a 60mph reading you would be reading about 76 pulses per second.
Let me know what you think.
Thanks Matt for the idea above, the actual calculation has to fit into 16bit maths (0-65535) so I'll have to scale that down, by dividing both sides of the equation by 10.
So it becomes Speed Mph = (X*360)/455
The maximum pulses per second the 16 bit speed maths can stand is 180 which equates to a speed of 142 mph, fast enough for me. If you exceed 142mph the speedo will be incorrect/overflow (read low) during that second. Fat Chance
Now we need Distance in feet travelled in that second.
Distance ft per second = (X*528)/455
To keep a running total of feet travelled
Distance = Distance + (X*528)/455
When Distance = 5280ft (1 mile) increment odometer and start again.
The maximum pulses per second the 16 bit distance maths can stand is 124 which equates to a speed of 98mph, fast enough for me. If you exceed 98mph the distance will be incorrect/overflow (read low) during that second. That won't be a problem for me in the Insight, I rarely go above 60mph
The odometer will display 0-65535 miles with 1 mile resolution.
Now I have the formulae the calculations can be adjusted to suit any sensor providing 5v pulses. A potential divider could also be used on the BMS Master Speed Sensor input to scale down a 12v sensor to the voltage reqd.