Thanks Bob. Now I know your secret method lol: ________________________________ From: Bob Blick To: Microcontroller discussion list - Public. Sent: Mon, February 14, 2011 10:16:55 AM Subject: Re: [PIC] RPM measurement question On Mon, 14 Feb 2011 09:48 -0800, "Andre Abelian" wrote: > this is for VW bug engine. 2 coil pulses per revolution. > counting 1 minute makes no sense so my question is how fast I should > count=20 > pulses to determine RPM? another words > lets say RPM shows 1000 revolution per minute if break it down will be=20 > in 1=20 > second 16.666 revolution so > should I count for 1 second and expect 16 or 17 counts?=20 Hi Andre, There are two ways to do it.=20 The hard way is to measure the time period between coil pulses. You can get an immediate and accurate measurement of RPM that way but it requires division. The other way is to count the number of coil pulses within a fixed time period and then multiply them by a constant (different constant depending on number of pulses per revolution and how long your time period is). This is easy but not instantaneous and not super accurate. I usually use the second method. But I also do a trick. I use 1/4 second as the time period and store one second's worth of them (four counts) in a circular buffer. Normally I sum the buffer and use that to display, four times per second. But I always compare the two most recent counts and if the difference between them is greater than (some amount, experiment), then I only use the new count.=20 So the display updates four times per second always but normally it is the average over the last second. For rapidly changing RPM it is the most recent 1/4 second. Now you know my secret method :) Cheerful regards, Bob --=20 http://www.fastmail.fm - The professional email service --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist =20 --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .