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? I don't remember the exact diameter of a bicycle wheel, but let's say the circumference is 9 feet. (60 mile/hour)(5280 feet/mile) -------------------------------- = 10 rotation/sec (9 feet/rotation)(3600 sec/hour) The hard part will be gracefully dealing with slow speeds as the periods become infinite. The easiest way to measure period is with a CCP module in capture mode. Your input frequency is so slow that you can use a 32768Hz crystal on timer 1 and keep the PIC asleep between captures. Since you don't need one part in 3000 resolution (assuming top speed of 10Hz as above), you can use the prescaler to give up some resolution on the fast end and get more range at the slow end. You still have to deal with overflow, but it all can be done. Below some speed you just don't display a value. ******************************************************************** Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products (978) 742-9014. Gold level PIC consultants since 2000. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist