Dear All
I have some old code i use to calaculate vehicle speed in mph from a pulsing speed sensor.
Code:
CheckSpeed: 'Pulsin measures VSS pulse. In no pulse in the timeout, result will be 0
pulsin VSS,1,Local 'Measure length of a VSS pulse in 5us (8mhz) units (Timeout 0.32768s)
if Local = 0 then JumpSpeed 'If Local = 0 pulsin has timed out and vehicle is moving at < 1.5mph
Local = Local / 11 'Divide Local by 11 to enable results to fit into 16 bit Integer Maths
ActualSpeed = (7908 / Local) + 1 'Returns Speed in mph accurate to 1 mph Approx!
I am constrained by the 16 bit maths but am sure there will be a better way with the pbpro maths experts to code my formula. The code above works but is a bit inacurate and I end up adding 1mph on at the end to get it something like right. Any ideas please.
ASFAIK the VSS speed sensor outputs around 4000 pulses per mile
Bookmarks