Bruce has a nice pulse measurement example using CCP1 interrupts. This might give you a head start, although it was written for a PIC18F242. It is well commented. This could replace the pulsin part of your code, so that your speed detection is much more accurate. http://www.picbasic.co.uk/forum/cont...-DT-Interrupts (the second code example uses Darrel Taylor's Interrupts.)