> For my next project, I want to initiate some action when my car exceeds > approximately 10mph. The "speedo" sensor is some kind of > proximity switch on > the output end of the gearbox/diff. So, the output it a 12v ish > square wave, > of frequency proportional to speed. My multimeter measures the > frequency at > about 20 Hz at 10mph. What model/year is the car? > So, to measure this frequency, my idea is to use the CCP, in capture mode, > with an appropriately prescaled timer. My Capture ISR will increment a > counter each time the CCP event fires, if the timer represents a (period) > shorter than 40ms (ie, faster), and, when the counter gets to an > appropriate > number, perhaps 20 ish, I'll inititiate the other code. Idea of using the > counter is to filter out any bounces or other muck in the line. > > Leading to my first question- does this plan seem like a workable > idea? I've > not much experience with a) pic and b) the automotive envorinment. Everything sounds good here, remember though that the automotive environment is BRUTAL when it comes to noise, you are already considering noise on the signal line, expect noise on EVERY other line as well, especially power. > Secondly, is the question of how to interface the 12v square > signal with the > pic? I'd thought of using an optoisolator, but is there a better, > or simpler > way of protecting the pic from a) getting 12v not 5v and b) any > dirty spike > type things? I think I need a relatvely high impedance, because the signal > goes into the ECU, so if I steal too much of it, I may make the car rather > ill. The opto-isolator WOULD be the "safest" way to go, however I agree with you, taking that much current from the line might cause problems (it probably wouldn't but I wouldn't chance it myself). I have done something similar and I used the "high impedance" idea, a 1M resister going into the PIC I/O. The protection diodes on most PIC I/O pins SHOULD protect you enough. This technique is OK for a one off/personal project, however if you are going into volume I'd recommend other techniques (i.e. an NPN transistor). TTYL -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu