Input protection to uC ADC. - Page 1
Forum section: electronics / projects

author: towlerg
author_rank: Contributor
timestamp: September 04, 2018, 02:17:08 pm
content: I'm hoping someone can help with a general input protect curcuit. Vdd of 5V with protection upto say 20v. Protection should be against steady DC and rapid spikes. Having got a general cuircuit i would like to know what additions (if any) would be required for an automotive environment. In the ideal world the protection would have no impact on the output uptill 5v , or atleast a calculatable difference.A little background, I'm using a curcuit posted by Hero999, which gives a 0 to 5v output for a 10 to 15v input (yes, I'm working with a lead acid battey). I haven't tested with physical hardware yet (I no longer trust breadboard) as this is part of a larger project but in sim it is amazingly linear, from 10 to 15v it overreads by 0.003v. As I'm only interested in 2 decimal places and I'll do a bit of averaging, it is perfect.Thanks in advance, George

author: xani
author_rank: Frequent Contributor
timestamp: September 04, 2018, 02:56:37 pm
content: You need to withstand transients of far more than 20V for automotive. Googling "car power protection circuit" should net you few application notes. AN2689 from ST for example.

author: Ian.M
author_rank: Super Contributor
timestamp: September 04, 2018, 03:46:51 pm
content: The things to be looking for in a linear ADC input circuit, starting from the input terminal, are:Series resistance that can withstand the maximum input transient that is probable within the design life of your product - possibly as part of a potential divider if input scaling is also required.Clamping that does *NOT* dump current into the ADC or MCU supply rail, and can withstand the max current the input resistor can pass on a worst case transient.For low frequency signals: low pass filtering by capacitance to (local) Gnd after the input resistor.Buffering to meet the input impedance requirements of the ADC - as this is usually an OPAMP, its often possible do do further scaling and/or offsetting or other signal conditioning at the same time.An ADC with sufficient headroom between its full scale input voltage and its abs. max. input voltage for the clamping to operate cleanly. i.e. the clamping circuit's leakage current with the ADC input voltage between 0 and full scale shall not cause a significant voltage offset across the input resistor (or at the input potential divider tap compared to unloaded).Post a link to Hero999's circuit (preferably the post its attached to) and post your implementation. If its a popular SPICE package, post the sim file + any custom models. Then the exerts can pick it apart and either explain its constraints to you or offer improvements.

author: towlerg
author_rank: Contributor
timestamp: September 04, 2018, 04:47:04 pm
content: Hero999's curcuithttps://www.eevblog.com/forum/projects/mesuring-a-12v-lead-acid-battery/msg1644677/#msg1644677I use Proteus 8.8 to sim.

author: Ian.M
author_rank: Super Contributor
timestamp: September 04, 2018, 06:25:31 pm
content: What a *lovely* circuit!(*NOT*)You might get away with that for monitoring a lead acid battery in a low voltage solar installation, or other benign application like the backup battery in an alarm system or even a UPS but in an automotive application, with high amplitude fast transients on the +Batt supply it will fail disastrously.What's worse, as the TL431 used to offset the voltage has a minimum operating current of 1mA (to guarantee regulation) the input impedance is low, making it difficult to protect by clamping.Consider what happens when its hit by a 0.5us to 1us risetime exponential impulse, of pulsewidth 50us, peaking at between 37V and 112V, with a 2 ohm source impedance (ISO 7637-2:2011 Pulse 2a), which isn't - by far - the worst thing that can happen in an automotive environment. Depending on the peak voltage, and the nature of any clamping you have on its output its likely that the BC547B and/or the TL431 will fail shorted. If the BC547B fails, both will probably explode.Find a copy of ISO 7637-2 and of ISO 16750-2 online somewhere and look at the specs of the transients one's automotive device is expected to survive. If you want to sim, LTspice XVII has built-in models for sources that generate these transients (see]).Also, simming a TL431 is rather suspect, as the official T.I. SPICE model is known to be somewhat deficient, and the generic model bundled with various simulators including PSPICE is basically crap (see).

author: Ian.M
author_rank: Super Contributor
timestamp: September 04, 2018, 07:31:34 pm
content: Here's my take on an OPAMP based offset and scaling circuit for 10V to 16V in and 0V to 5V out that does *NOT* need a negative rail or >5V for the OPAMP.The input is differential so voltage drop across the battery ground strap etc, can be eliminated. The common mode rejection ratio is dependent on how well each pair of resistors is matched. Unfortunately it needs six precision resistors. A lower accuracy version could be made by combining R6 and R4. Use a low voltage true rail to rail I/O OPAMP.It actually starts at fractionally over 10V, but not by enough to matter for practical use. Range and offset can easily be adjusted in the sim by varying the relevant resistors as they are parameterised.Protection would be added at the OPAMP inputs. Neither go outside the range +1.8V to +4.4V, so low leakage diode clamping to ground and to a 4.7V Zener held biassed by a 100K pullup to +12V should be sufficient.LTspice sim attached.

author: towlerg
author_rank: Contributor
timestamp: September 05, 2018, 12:55:04 pm
content: Ian, thanks for your input and the obvious effort you have gone to.A number of questions come to mind. Sorry to ask you to dot the t's and cross the i's but I'm just a programmer, my knowledge of analog electronics is pretty much zero.What is .lib opmap.sub?What would be an approprial op amp?The 83.5k resistor you have specified is E192, is it possible to use a E96 alternate?The zener and the 100K pullup would be in serial?Which way round are the diode and the zener?George

author: Ian.M
author_rank: Super Contributor
timestamp: September 05, 2018, 02:37:47 pm
content: .lib opamp.subis a SPICE .lib command. It loads the component library file 'opamp.sub' into the sim, which is LTspice's model for an ideal OPAMP. If you aren't using LTspice you'll probably have to do something different, maybe to your SPICE program's 3 terminal OPAMP symbol to point it at an appropriate model. The one thing that's 99% certain is you wont need to load a LTspice specific file with .lib!For the OPAMP, it depends on what's available, how accurate you want it and how much you want to pay. I could spec a gold plated Burr-Brown (now part of T.I.) part, but you wouldn't be happy. Try a TLV2371 if your supplier stocks it cheaply enough.For the resistors, it depends how accurately you want to expand a particular part of the input voltage range to the output range of 0V to 5V. Also, if you keep the differential input, resistor matching is more important. E192 will be 0.5% or better. You are trying to maintain 0.1% accuracy to get a 3 significant figures result. E96 is typically 1% so if you go down that road you'll have to do per-unit calibration, and allow enough excess range that worst case tolerance variations don't take the output to the rail close to but inside the limits of your desired input range.You cant afford more than about 50 nA leakage + bias current if you clamp at the OPAMP inputs. For single ended input, (-in above grounded), you only need to clamp OPAMP +in. For differential input, clamp both +in and -in. Each needs a series pair of low leakage diodes, anode to ground, middle to input, and cathode to the (shared) Zener cathode, so they are reverse biassed in normal operation. Connect the Zener anode to ground, and pull up its cathode towards +12V via a 100K resistor. Its probably a good idea to put 100nF decoupling in parallel with the Zener to improve the clamping's transient response. Depending on the OPAMP's abs. max. input voltage range limits, and its behaviour at them, I'd also probably add somewhere between 1K and 10K directly in series with each OPAMP input pin, between the OPAMP abd the rest of the circuit to prevent excessive input current when the clamping is active. Read your OPAMP datasheet carefully to see if that's needed.

author: ogden
author_rank: Super Contributor
timestamp: September 05, 2018, 03:19:22 pm
content: Quote from: towlerg on September 04, 2018, 02:17:08 pmLevel shifting for battery application?So your circuit does not even handle overdischarged battery voltage of 9V? Just get better ADC and use simple divider 0..15V -> 0..5V.

author: Zero999
author_rank: Super Contributor
timestamp: September 05, 2018, 03:32:57 pm
content: Quote from: Ian.M on September 04, 2018, 06:25:31 pmCome on, it's not that bad.What's wrong with a simple series resistor and zener diode on the output? That will be fine, so long as the circuit it's feeding isn't too low impedance.QuoteThen use a better reference than the TL431 which can work at much lower bias currents.Quote from: Ian.M on September 04, 2018, 07:31:34 pmYes the op-amp method is a better way to do it, at the cost of more complexity. Those resistor values can probably be optimised further.If an op-amp with internal protection diodes is used, then there's no need for any external zener diodes.Quote from: ogden on September 05, 2018, 03:19:22 pmWhy is that important? If the voltage is below 10V, then the battery is dead and needs replacing. Whether it's 6V, 8V or 9V is irrelevant.

author: ogden
author_rank: Super Contributor
timestamp: September 05, 2018, 03:48:51 pm
content: Quote from: Hero999 on September 05, 2018, 03:32:57 pmAre you absolutely sure?AFAIK 8.4V is still tolerable voltage for 6-cell (12V) lead acid battery under load. Indeed it will degrade if left in such deep discharge, especially at higher temperatures, but it is FAR from dead.https://batteryuniversity.com/learn

author: Zero999
author_rank: Super Contributor
timestamp: September 05, 2018, 03:56:44 pm
content: Quote from: ogden on September 05, 2018, 03:48:51 pmI would replace a battery if it got down to that voltage. You might be right that it could still have some life left in it but how much? At that voltage it's highly likely one of the cells has failed short circuit.By the way, I forgot to say that I agree with your other statement about using an ADC with more bits and a potential divider. It's certainly the simplest method and if the resistors are a high enough value, then no extra protection is needed, as the internal ESD protection diodes will do the job, although a capacitor would be needed to charge/discharge the ADC's sample and hold capacitor.

author: Ian.M
author_rank: Super Contributor
timestamp: September 05, 2018, 04:08:34 pm
content: @Hero999,Even 100V of transients will blow your original circuit into orbit. Yes there are things you can do to improve it, but up-stream input protection with a beefy TVS diode and a polyfuse will probably cost more than the OPAMP circuit + clamping diodes and a Zener. However I would use your circuit for easy offsetting of an analog voltmeter, with no stabilised low voltage rail available to run OPAMPs. A cap across the TL431 section will save it from most transients *IF* a higher voltage transistor is used in the current sink, and if the transients are bad enough to bend the needle, who cares if the offsetting circuit survives!Of course the resistor values can be optimised - its a tradeoff between accuracy, excess output range, input impedance and cost - which is why I parameterised them. Conceptually, its just the standard differential amplifier circuit, except In+ is from a potential divider between Vbatt and Vref_5V, and In- is from a matched potential divider between the battery negative terminal and local ground, so it can be optimised analytically if you don't want to SPICE it.However its a good point that you can use an OPAMP that has internal clamping diodes - provided the +5V supply rail can cope with the worst case current that the input divider can dump into it, without rising significantly. If not, pop goes your MCU and anything else on the +5V rail.

author: ogden
author_rank: Super Contributor
timestamp: September 05, 2018, 04:42:54 pm
content: Quote from: Hero999 on September 05, 2018, 03:56:44 pmI agree with you that 8.4Vopen circuit voltagemeans it is most likely dead. If battery is there then you would want to measure it'svoltage under loadas well, right? In high load conditions it is ok to reach 8.4V. When load is off, then voltage will jump back to over 11Volts or so. Excerpt fromrandomly googledsealed battery datasheet attached.

author: Zero999
author_rank: Super Contributor
timestamp: September 05, 2018, 06:14:05 pm
content: Quote from: ogden on September 05, 2018, 04:42:54 pmI didn't realise the battery voltage dropped that low, under heavy loads. I suppose it's not surprising. In that case I agree, it might be beneficial to measure lower voltage, than 10V, but it depends on what the battery is being used for or when the measurement will be taken.Quote from: Ian.M on September 05, 2018, 04:08:34 pm100V? What the heck? The original poster was talking about 20V tops. I still doubt a polyfuse and a massive TVS diode are needed. A transistor, rated to 150V or so and adequate current limiting on the MCU input will do for 120V surges.I doubt the circuit I posted is the weakest link here. It's possible the MCU's power supply is not up to scratch and will fry the MCU and everything else, long before this circuit will.

author: max_torque
author_rank: Super Contributor
timestamp: September 05, 2018, 06:38:06 pm
content: Here's the rather important facts that need to be known before anyone can actually suggest a suitable input circuit:1) Limits for current drawn from the battery, esp when measurement device is "off"2) Sampling rate required3) Resolution required (how many bits is your ADC?)4) Accuracy required (inc tempco!)Depending on the answers to those questions the "Input circuit" could be anything from a pair of resistors right up to a massively complex active circuit with clamping and compensation etc!

author: Ian.M
author_rank: Super Contributor
timestamp: September 05, 2018, 06:42:15 pm
content: @Hero999,Quote from: towlerg on September 04, 2018, 02:17:08 pmAs I said earlier, your TL431 circuit is OK for relatively benign environments, just add a series resistor on its output + clamping at the ADC input. However, I don't think anyone would describe an automotive 12V supply as 'benign'.I agree that the MCU's power supply is probably the weak link at the moment, but the O.P. hasn't asked about that yet.

author: Zero999
author_rank: Super Contributor
timestamp: September 06, 2018, 07:51:53 am
content: Quote from: Ian.M on September 05, 2018, 06:42:15 pmOh I agree.I think all of the protection should be at the input of the 12V to 5V power supply. There's no point in doing the same thing twice!

author: Ian.M
author_rank: Super Contributor
timestamp: September 06, 2018, 08:22:26 am
content: Quote from: Hero999 on September 06, 2018, 07:51:53 amPossibly, unless the combo of the protection circuit, the supply wiring resistance and the various load currents involved cause a big enough voltage offset to be significant.The O.P.'s trying for two decimal places, so that's a basic resolution of 10mV. While avoiding the basic fallacy of confounding resolution with accuracy, that still indicates the desired accuracy is likely to be better than +/-50mV, or there would be little point in having two places of decimals.That's one of the reasons I chose to present the differential input version of the single supply OPAMP level shifter, so it could be used to vastly reduce (and theoretically eliminate if all resistors were perfectly matched and the OPAMP was ideal) the error due to voltage drops in the vehicle wiring loom, at the expense of having to run dedicated sense wiring to the battery terminals.