# interfacing with a cam sensor on my truck

I'm trying to figure out the best way to interface with the cam sensor on my truck to pick up RPM. The cam sensor is a signal generator type it pulses 4 times per rotation I have rectified the signal and used a capacitor to smooth out the pulses. Right now i have it hooked up to the analog pin on the arduino and am getting a good reading at idle. The problem is that at idle i get a 600 to 700 reading and if go over 3,000 RPM i think i might fry the analog pin due to the fact the sensor is putting out more than 5 volts at higher RMP's. Maybe there is a much better way of reading this sensor?

Why not read the pulses direct?

well yeah i guess i could do that just don't know how I'm still new with all this stuff. I have a pretty good understanding of electronics but I still am not really good with writing code yet.

Check out the LM393 comparator: it has an open-collector output, so you can run it off a supply higher than 5V without that high voltage getting into your Arduino input.

You can also set the “input high” threshold to something other than the standard CMOS digital logic level if that’s useful: just change the resistors in the voltage divider customarily used to set the “reference” input so the output goes active at 1V, 5V, or whatever works for your situation.

It’s much easier than using an analog input to decode what are nominally square waves, very cheap, and adds a little protection from nasty noise spikes. If something has to die from high voltage, it’s better to have it be a 50 cent part than a \$5 one

Be sure to ground the inputs on the unused comparator: opamps tend to turn into noise generators if you don’t.

Here's a 393 circuit (untested) for such a purpose. Note that the 2nd half of the 393 is not shown, pullup resistor is internal in the uC, and in this case the 393 is running from 5v.

http://quub.robgray.com/documentation/docs/quub-ion-count.pdf

Rob