All, Put more magnets or whatever on the wheel so you increase the frequency at lower speeds. So for instance, instead of 1 magnet (trigger), have 4 or 6 or 8 or 10 or whatever. Then in software, even at low speeds, the frequency will be high enough that the period between triggers is short enough to be measured easily. You can calculate the speed from the new frequency. Jim ----- Original Message ----- From: "Olin Lathrop" To: "Microcontroller discussion list - Public." Sent: Sunday, August 16, 2009 8:06 AM Subject: Re: [EE] How to generate a 1000 Hz pulse? (and PIC timers) > 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 > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist