Electronics > Beginners
Sensing 12v line with 5v MCU
digsys:
--- Quote from: magic ---Sure, but a transient could blow the opto, couldn't it? Particularly one of reverse polarity. :-//
With a CMOS gate, I would think a 1M 1kV series resistor plus the IC's built-in protection diodes should be good enough. And with, say, 10pF input capacitance, that's still less than 1ms delay.
I have seen a car component which monitored engine RPM by sensing the ignition switch (peak voltage ~200V). In front of some IC there was only an RC filter with 300k series resistance and some unidentified capacitor. It worked for years and never failed.
--- End quote ---
Sure ... what you can "get away with" and what is ADR compliant (ADR=Australian vehicle design rules) are completely "different' animals !! All countries have
vehicle safety / wiring standards that are similar, especially IF they want to export.
They don't have electrical safety standards for no reason. HECK, I've seen 100s of products eg that are just a diode, resistor and led, wired STRAIGHT off the
mains !! Yeah they work, and are sold everywhere, but would you seriously use one? Same goes for vehicle electronics.
"Because it works" is not good advice to present to beginners or anyone.
I've repaired / designed vehicle electronics for 30+ years, currently spending the last several weeks on EV electronic controls. I've also had 1,000s of repairs
over that time and seen even the "best practice" designs fail on not "dotting the last i". I send the reports to the manufacturers.
Sure, the opto could "blow up", but it will cause a LOT less damage than "blowing up" a micro, that "may" also be in charge of OTHER safety functions !!
I'm not in any way having a go .. this is a a sore point. We should aim to direct users to the "best path approach", at the very least.
Ian.M:
Unless you have it in writing from the MCU manufacturer that currents up to a specified limit may flow through the internal protection diodes during normal operation without adverse effects to other device parameters, on a modern MCU, its unwise to rely on the internal protection diodes for normal operation of your circuit. e.g. see Microchip TB3013 for some of the issues that can occur. This is *NOT* hypothetical: over on the Microchip forums, there have been several reports of internal oscillator frequency shifts of 40% or more with less than 1mA flowing through a protection diode.
Long time constant capacitive filtering and an input that doesn't have a Schmitt trigger characteristic has its own problems. Normally they aren't electrical, though in low power designs the increased current consumption of the input gates due to an input voltage that spends too long in the transition region may be an issue, and I would be very suspicious of their possible behaviour at the top end of the MCU's permitted temperature range. However your code *MUST* cope with multiple random transitions due to noise at every actual signal transition. It would be a really *BAD* idea to use the input for an edge triggered interrupt, unless the ISR deferred re-enabling the interrupt for a time greater than the RC time constant. Its well worth reading Jack Ganssle's mini-series on debouncing.
You also have to consider the sensing thresholds on the 12V side of the input protection network. A typical CMOS input will have logic thresholds near 30% and 70% of Vcc, with the actual transition somewhere between them. If you scale a 12V input down to logic levels with a potential divider, the percentage thresholds scale as well, so, assuming the divider ratio is chosen for 14V in, Vcc out, to best match the MCU logic levels to the 12V signal levels in a running vehicle, anything below 4.2V will be seen as logic '0', and anything above 9.8V will be seen as logic '1'. This applies as long as your input protection network doesn't rely on clamping to reduce the signal to logic levels.
If you use the simple opto input circuit: Opto-LED + series resistor on the 12V side and Opto-phototransistor to ground and pullup resistor to Vcc on the logic level side, the thresholds are a *LOT* harder to predict. They are determined mainly by the CTRR of the optocoupler, which is not a tightly controlled parameter and varies widely from device to device and with temperature and ageing. One approach to fixing this is to add a Zener in series with the LED to 'hold off' any significant current through it below the Zener voltage to guarantee the worst case transition wont be at an inconveniently low voltage. Another less accurate method is to feed the LED with a potential divider so that the voltage across it is below Vf for inputs below 4V or so.
The problem of transients has already been touched on - most opto LEDs have a peak pulsed If of typically an order of magnitude greater than their continuous rating, and if one follows the typical design practice of not exceeding 50% of the continuous rating in normal operation, that will permit the optocoupler to survive brief positive going transients up to around 250V if its setup for 14V input. However the permissible reverse bias on the LED is typically quite small, and although catastrophic avalanche breakdown is fairly unlikely, repeated negative going transients can degrade the LED's efficiency, reducing the CTRR. Its therefore advisable to protect it with an anti-parallel diode.
Protection against Load Dump transients is a whole different matter - worst case, your input circuit (and device PSU) can have to cope with a transient lasting half a second or so that peaks at over 100V. Power dissipation in your protection network during the surge is a significant issue. Fortunately modern vehicles tend to have load dump clamping at source to protect their ECU and other electronic systems, so unless your device is particularly high value, it may suffice to design it so it wont fail before the ECU does, and accept that you may get a few warranty claims from unlucky classic vehicle enthusiasts!
mariush:
You could do with it a resistor and a temperature sensor or a PTC/NTC resistor or even a diode ... connect the resistor between voltage and ground with a value picked in such a way that the resistor would heat at some reasonable value like 80-100 degrees C (you probably want something above 60 degrees or so, whatever's high enough not to get false positives when car's parked for hours under the sun or whatever)
Measure temperature sensor, resistor value in case of ptc/ntc , voltage drop on the diode
This way you don't care about transients reverse voltage whatever, downside is constant small power consumption and heat on the resistor (but you have a mosfet or transistor or something to disconnect the resistor and then you'd have to deal with delay of a few seconds or so from connection time to when it would safe enough to assume resistor got hot enough to measure)
David Hess:
An optocoupler is the safest way because it also removes the need for a ground connection preventing a ground loop.
Your first example with the low impedance divider and zener is good also but should include RF suppression capacitors across the zener diode and at the microcontroller input pin.
floobydust:
I'm sensing the grounded switch contact. Then you don't have to worry about what voltage the input swings up to. This is a common technique in automotive, industrial PLC's etc.
It can withstand several 100's V surges and moderate ESD.
Use a Schottky diode for low-voltage MCU's and it ends up limited +ve voltage surge rating due to the diode's low PIV rating.
Typical levels are 12V vehicles +100V and -150V spikes max., 24V trucks are +200V and -600V spikes max.
OP may have relay-coil inductive spikes present which will stress the blocking diode.
Opto-couplers aren't considered great for automotive environments, I'm not sure exactly why. Very few achieve automotive qualifications like AEC-Q100, 101.
I recall it was aging and CTR degradation from temperature swings. I don't see them used in cars. Electric cars will surely change this.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version