In response to a couple of repies I got, here is what I'm using to calculate RPM from a tach pulse input using the CCP module. I am using a 20MHz xtal on a 16F8xx processor. CCP1 is set up to trigger on the leading edge of the pulse. CCP1 increments on every instruction cycle, or 5M times per second. I get 50 pulses per revolution of the engine. ([pulses_per_sec]/[numer_of_teeth]) * 60 = RPM. Pulses per second is derived from 1/[pulse_length] where the pulse length is in seconds. Since CCP1 counts at a rate of 5MHz in my case (20MHz clock / 4), I have to divide the pulse length by 5,000,000 - OR - make things simpler and do this: RPM = ((1/([width]/[clock])/[teeth]) * 60 = ((1/(width/5M)/50) * 60 = (1/width) * 6M = 6M/width I guess all the above would be obvious to a math whiz, which I'm not, so it took me a while to figure out just exactly how simple that could be made. Now, since I want to smooth out any jitter in the tach pulse signal, I average out the most recent 20 pulses. I have a CCP1 interrupt function that populates a 20-element array with the value of the CCP1 capture register. Once that array is full, I average the values in the array and use that number as the pulse width. You could adjust or eliminate this based on how many teeth you have on your tach pickup, how fast you want it to respond to changing RPM, etc. Now whenever I want to caculate RPM I average the array elements, then divide that into 6 million and cast the result as a long integer. while(!tach_good) // Wait for array to fill ; for(x=0;x<20;x++) { // Average pulse widths period += (float)tach[x]; } period /= 20; calctmp = 6000000 / period; //Calculate engine RPM from timer period rpm = (long)calctmp; // Cast this to long int for RPM display Now bear in mind I have not yet *tested* this code, but I think the theory is sound and the calculations seem to work. I think any number of pulses per revolution and any clock frequency can be accomodated, it will just change the "magic number" from 6M to something else. Of course, if anyone has a better idea I'm more than happy to listen! Dale --- The most exciting phrase to hear in science, the one that heralds new discoveries, is not "Eureka!" (I found it!) but "That's funny ..." -- Isaac Asimov -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body