I intend to make a ludicrous bicycle computer, which will do silly things like:
Rear wheel circumference at 60psi: 2m 4cm (readings were 2m14, 2m04, 2m06, 2m04.5)
Assuming that the wheel of my bike as a circumference of 1m, and that I reckon the practical upper limit for my bike is 50mph (~80kmph)1) then I can expect my bike wheel to do about 20 rotations per second. In order to sample this effectively, I should be sampling at 40Hz.
However, I won't have an analog measurement from the wheel. I will have a pulse once per rotation. I can configure the board to fire an interrupt on this pulse (by catching the rising edge, for instance). I can also connect one of the PWM modules to an interrupt and use it to generate my reference clock.
So I can have a tick()
interrupt fired at 40Hz, providing an accurate reference signal, and another interrupt fired for each rotation of the wheel. By counting ticks between wheel rotations I ought to be able to work out my speed fairly accurately.
A “sub”2) is approx. 6 inches. 30mph = 44 feet/s = 88 subs/s: Great Scot!