On Wed, 18 Jul 2001, Gary Neal wrote: > Hello, > > 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'm using PIC Basic Pro to program my PIC. I'm thinking about counting > the number of pulses over a specified amount of time (measured using > TIMER0) and converting to rpm. Of course I'll have to do some averaging > and stuff like that. Extreme accuracy is not important. +/- 5% would be fine. > I'm assuming putting a 70Vp-p signal to one of the digital I/O pins would > be bad? How do I get around that? Just a simple voltage divider? What's > the voltage range the I/O pins can handle and still register as a HIGH or LOW? > Any comments on potential pit falls or better ways to do this would be > appreciated. Yeah, a 70V pk-pk signal into a PIC pin would be a bad thing. It has been proposed that you could get away with this by using a large series current limiting resistor, but I wouldn't do it on a dare. What's the lower limit of signal amplitude? If it varies from, say, 2 to 70V, a rsistive divider would only work above a certain RPM when the amplitude got high enough. A divider will reduce small signals just the same as large ones. I'd look at something like a Zener and resistor arrangement to clip the signal, or maybe some sort of op amp AGC thing that one of our more analog-oriented bretheren could recommend. You can figure RPM just fine using a timer and counting pulses during a known time period, or measuring the length of a pulse. I used the second method, with a very nice filtering method suggested (IIC) by Olin Lathrop. Look in the list archives back earlier this year for a thread about filtering... I'll look for the subject line if you have trouble finding it. Works great, uses very little memory and code space. Ihave some code to do the job, but it's C... I could post more of the details if you like, not sure how much good it would do for your particular application. Dale -- A train stops at a train station. A bus stops at a bus station. On my desk I have a workstation... -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.