# Scaling a car's injector pulses to count and time them?

What would be an efficient way to reshape a car's injector pulses to digital 0-3.3V pulses, so a microcontroller can count and time them? The waveform can be seen on this page under "Example waveform".

This question might be considered a duplicate of Efficient spike detecting Microprocessor or DSP architecture but none of the answers is really clear for me. I wonder if the transistor solution works with Vb >> Vc. The flip-flop solution misses the voltage scaling stage.

Requirements:

• the circuit must present a high impedance to the coil (arbitrarily set at > 1Meg)
• must correctly detect pulses between 5 and 150Hz
• should survive common faults (wire disconnected and reversed polarity)

Assumptions:

• voltage spike amplitude is not constant, and can go anywhere from 30V to 120V (again, somewhat arbitrary).
• voltage spike duration is not constant, and can go anywhere from 200us to 4ms (again).
• Processor is likely to be an Atmel SAM D20 or D21 (3.3V).
• Supplies available: automotive 12V, not regulated; 5V, regulated, 3.3V, regulated.
• the microcontroller has edge-triggered interrupts and input-capture mechanisms

A solution based on the signal levels instead of the spikes could also be acceptable, assuming that it works with a high voltage anywhere between 9 and 16V.

One simple solution would be a 1Meg resistor in series and a 3.3V zener (or even a 3V one, or maybe a shottky diode to Vcc), but the high-value resistor (and thus low current) means that we're in an area that is often overlooked in diode datasheets. In a previous case, I had conduction in an IC's protection diodes, causing incorrect behavior in other parts of the IC. I'd like to make sure that this doesn't happen. I'm also not sure whether the input-compare can deal correctly with such an high input impedance.

Thanks

• Is there any reason why the resistor has to be 1Meg? AFAIK, the fuel injectors in a car have a very low resistance, usually in the tens of ohms (even the high impedance ones). I think the Zener diode idea with a lower valued resistor would work well. – tangrs Oct 10 '16 at 22:26
• @tangrs: it's more a preference than anything else. I have a limited understanding of the circuit, and it's a good overall protection against wiring error too. Thanks for your feedback. – jmr Oct 10 '16 at 23:00

That's not real hard, assuming the coil voltage is a rectangular (or even trapezoidal) waveform.

simulate this circuit – Schematic created using CircuitLab

This will not respond to 30 volt pulses of less than about 100 usec, although it will respond to somewhat shorter 120 volt pulses. R2 keeps the circuit well-behaved if disconnected, and D1 protects against reverse polarity.

The only possible problem is the relatively slow rise and fall times (about 20 usec), but if this is an issue, add another transistor with an emitter resistor of 5k, and get rise and fall times of 2 or 3 usec. Alternatively, add a Schmitt trigger such as a 74C14 and get rise and fall times of 10 nsec or so.

EDIT - So how do you get 5 nF for C1? Use $$\frac{dv}{dt} = \frac{i}{C}$$ $$\frac{\Delta v}{\Delta t}=\frac{i}{C}$$ $$C = \frac{i\Delta t}{\Delta v}$$ At low capacitor voltages, all the current through R1 goes to charging C1, and at about 0.65 volts the transistor base-emitter junction will begin to conduct and turn on the transistor. At 30 volts, 1M produces 30 uA, so $$C = \frac{i\Delta t}{\Delta v} = \frac{3 x 10^{-5}\times 10^{-4}}{.7}=4.6x10^{-9} = 5 nF \text{(close enough)}$$

• Thanks for this. I see your point about the slow rising time - if you input a slow(ish) ramp, the output triggers progressively while the input is between 5 and 10V. Given the input waveform in the link above, my simulation shows that if the stable 12ish volts plateau is lowered to around 8V, the output during that plateau changes, which means that only the output's rising edge time is reliable. I'm assuming that the same change could be obtained if using another 2N3904 with different Vbe characteristics. Still, this design has a lot of potential, and I must experiment more with it. – jmr Oct 11 '16 at 2:53
• @jmr - No "different Vbe characteristics" required. Try adding a second 2N3904, grounded emitter, base to current output, collector to 3.3 via a 1k resistor. Look at the collector as with the current circuit. Even better, try a 74HC14 as I suggested. And what do you mean "12ish volts plateau"? No such thing for this circuit and the input range you mentioned. If you're getting something like that you're doing your simulation wrong. – WhatRoughBeast Oct 11 '16 at 4:07
• Here's my LTSpice circuit (source). Here's my normal simulation, with the normal voltage at 14V. If I lower it to 6V, I get this. So the circuit's output is high when input is below ~6V, low when input is above ~8V, and a logical undefined for a small range between these. That works, even if not triggered by the spike. My concern is if I build 10 of these, how variable (in width and in position) will be the undefined range. – jmr Oct 11 '16 at 15:51
• If posible, could you explain how you selected the 5n value for C1? Thanks. – jmr Oct 11 '16 at 15:52
• @jmr - See edit. – WhatRoughBeast Oct 11 '16 at 19:47