solarwind wrote: > To get accurate speed readings for my bicycle speedometer project, I > have to count how long it will take the wheel to turn rather than how > many times it has turned in x seconds. I want a 1 second speed update > rate so to go about it, I need to count how many milliseconds it takes > for the wheel to spin once. That way, I can get an accurate speed > reading. > > So, I need some way to generate and count a 1000 Hz pulse. How would I do that? > No you don't... really. To get the speed of your bike you need to know the circumference of your wheel.... and the rpm of the wheel. Yo get the RPM you need to know the 'period'. With the RPM you have to multiply by the circumference to get the speed. Easy. Now, you want to get the RPM, and, you do not need a 1kHz anything to do that. You use the CCP module in 'capture' mode of your PIC on a 16 bit timer with a scaled to an appropriate prescalar so that you can get any reasonable rpm for the wheel, with an overflow interrupt on the timer to indicate the wheel is 'stationary' (or nearly so). Use an RC filter to 'debounce' the reed relay, and then check for impossible changes in the PIC too. You can use a crystal for the pic with a 'nice' frequence like 4.194304MHz to get a good 1second interrupt using a standard 16bit timer and interrupt on overflow with a good prescalar. That Crystal will also make the RPM calculation somewhat easier. Rolf -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist