> -----Original Message----- > From: Hulatt, Jon [SMTP:jhulatt@MONSTEREUROPE.COM] > Sent: Tuesday, September 23, 2003 3:15 PM > To: PICLIST@MITVMA.MIT.EDU > Subject: [EE:] (automotive) frequency trigger > > Repost, this time with a colon in the topic tag. > > > Hi all, > > 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. > > 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. > Yes, this seems like a reasonable method to implement this, if you are happy to use a PIC with a CCP module. 20Hz is slow enough that you could easily measure this purely in software if you wanted to. I have recently used a small PIC to de-restrict my Japanese import MR2 by intercepting the signal from the speedo head to the ECU. The PIC had to measure the incomming pulse and generate an output pulse at the same frequency up to a maximum limit, beyond which the output frequency remained at this maximum. You are welcome to the code if you wish, although it does not use the CCP module. > 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 simplest method would be to clamp the 12v signal using a resistor and a zener. Some filtering would be required to help prevent any noise problems. The problem with an opto-isolator is that the LED within the device will typicaly require a few mA drive current which may not be available from your high impedance signal. A PIC's input pin has a very high impedance (typical CMOS inputs > 10E6 ohms), so you can use a relatively high value resistor before the zener clamp to limit the maximum current. The zener will also help protect against negative noise spikes. If noise is a big problem them consider using a comparator with hysteresis to clean up the signal instead. Regards Mike ======================================================================= This e-mail is intended for the person it is addressed to only. The information contained in it may be confidential and/or protected by law. If you are not the intended recipient of this message, you must not make any use of this information, or copy or show it to any person. Please contact us immediately to tell us that you have received this e-mail, and return the original to us. Any use, forwarding, printing or copying of this message is strictly prohibited. No part of this message can be considered a request for goods or services. ======================================================================= Any questions about Bookham's E-Mail service should be directed to postmaster@bookham.com. -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu