> I'm relatively new to the PIC scene. I want to use a PIC16F870 to measure > the rpm of a rotating shaft (0-15,000rpm). There is a passive speed sensor > in the shaft that puts out a sine wave whose frequency is proportional to > shaft rpm. The amplitude of the signal increases with increasing > speed. The max. voltage of this signal is 70V peak-peak. I've done this sort of thing a few times before. First, you have to decide what the minimum shaft speed you need to detect is. That tells you the worst case voltage and frequency of the sine wave you have to deal with. It also tells you how long you have to count pulses for to get to the desired accuracy (5% in your case). If this time is too long, then you need to measure period and invert. This is actually pretty easy with the CCP module in capture mode. All my tachometer-like applications have ended up doing it this way. You get quicker and more accurate updates which are also easy to filter without requiring much memory. Anyway, back to the pulse. The sensor is probably a coil, which will have an open circuit output voltage proportional to the frequency. The worst case is the low frequency end when the signal is smallest. Design the circuit to have enough gain to create a 0-5V square wave from the signal at the smallest incoming amplitude. There is always noise, so use hysterisis, which gets you the square wave output for free. I would set the hysterisis to be about 25% to 50% of the minimum signal size, depending on how confident you are that you really know what the minimum will be accross part variations, temperature, etc. Since your signal has an amplitude proportional to f, you can apply a simple passive single pole filter with 1/f rolloff at or slightly above the minimum frequency. This will help with noise immunity at the higher frequencies because the hysterisis will stay a roughly constant fraction of the signal amplitude. You also want to avoid overdriving the opamp or whatever. ******************************************************************** Olin Lathrop, embedded systems consultant in Littleton Massachusetts (978) 742-9014, olin@embedinc.com, http://www.embedinc.com -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.