nik wrote: > > A 4 stroke/4 cyl engine has 2 ignition pulses per 1 crankshaft > revolution. > If this is so then whats the technique behind counting RPM with a PIC. > I need some ideas only. Please don't discuss HW or other. >=20 > I've gone as far as thinking the RPM will have to be fed to a CCP pin > as input. I understand how the CCP will be setup but can't quite get > the idea of how exactly to count RPM and say if that's sorted out, > display it (this part is not a concern right now). Broadly, there are two basic approaches to measuring frequency (which is what RPM is). You can measure the period (time) between successive pulses and derive the frequency from that (frequency being the inverse of period), or you can count the number of pulses that you see in a given time. You'd feed the pulses into a CCP pin if you were going to use the first method - using the CCP in capture mode, to capture (measure) the period between successive pulses. However, the second method (counting pulses) is much more common, is easier to implement and has the advantage of averaging out variations between pulses. To so that, you would feed the pulses into a timer input, such as T1CKI, with the timer (TMR1 in that case) configured as a counter. Meanwhile, another timer, configured as a timer (incrementing at a steady rate derived from an oscillator or the PIC's instruction clock), keeps trac= k of time. When this timer overflows, you see how many pulses have been counted by the "counter" timer. You then reset the count and repeat. For example, if your timer overflows after 1 sec, and you have counted 200 pulses, that's 200 Hz and therefore 100 revs/sec =3D 6000 rpm. You still n= eed some maths to scale the result like that, but it's not as hard a inverting the period. Hope that helps! Cheers, David www.gooligum.com.au --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .