[-img src=Vue32 sch spd.png: missing =-]
The vehicle has magnetic speed sensors on all four wheels. A magnet and a coil are used to sense a metal gear’s 42 teeth. The wheel’s diameter is 0.55m. The sensor’s output is a sine-like waveform whose voltage and frequency are proportional to speed.
To convert the sensor’s output to 3.3V digital pulses, we use a precision full-wave rectifier followed by a comparator. V(vin) is the simulated input voltage, with noise, V(vrec) is the output of the rectifier and V(vout) is the logic output. The pulses are captured with the PIC’s Change Notification peripheral. A 800ns timer measures the pulse width and the value is converted to kilometers per hour according to the following equations. To get additional precision while using fixed point numbers, 1.0kph is represented as 10.
1kph/3.6 = 0.277m/s
C = piD = pi0.55m = 1.729m/turn
(0.277m/s)/(1.729m/turn) = 0.160 turn/s
42 poles * 0.16 turn/s = 6.75Hz