LM358 Op-Amp in inverting config with single supply and below negative input? - Page 1
Forum section: electronics / projects

author: tinfever
author_rank: Regular Contributor
timestamp: July 17, 2022, 11:54:52 pm
content: I'm trying to figure out how I might monitor a -12V rail voltage using the ADC of a microcontroller. One option would be to use an LM358 to invert the voltage and scale it to the microcontroller input range (like 0-3V). Is it acceptable/not dangerous/good design practice to use an LM358 in this manner with a below-negative-rail input and a single 0 to +12V supply?I'm concerned because technically I think this would violate the input voltage range on startup, as the inverting input would be at -12V, although theoretically as long as the phase of the output is correct, I think it would still work since the feedback would cause the input to stabilize at "virtual ground" of 0V?The datasheet does say "If either input more than 0.3 V below V– then input current should be limited to 1 mA and the output phase is undefined." which isn't confidence inspiring. However, TI also has an app note "Inverting op amp with inverting positive reference voltage circuit" (https://www.ti.com/lit/SBOA261) doing pretty much the same thing, using an TLV9062 Op-Amp though.The simulation with the LM358 works but I'm guessing the mentioned phase-reversal issue probably means I shouldn't rely on this circuit, at least with this specific Op-Amp?

author: shakalnokturn
author_rank: Super Contributor
timestamp: July 18, 2022, 12:08:56 am
content: Sorry for avoiding the question but wouldn't just using an appropriately weighted voltage divider between -12V rail to monitor and whatever positive rail or reference you have around then do the rest in software be simpler?Add protection zeners or other diodes if power up conditions may be risky for the μC.

author: John B
author_rank: Frequent Contributor
timestamp: July 18, 2022, 12:10:01 am
content: With a supply voltage of 0-12V, the most output range you'll get is ~0V - 10.5V. You must also keep the inputs within the allowable common range.You'll need to generate a negative supply rail. A 7660 charge pump or similar will provide plenty of current for this application. You can divide your input voltage from -12V down to -3V using a resistor divider, then invert the signal. You'd only need a negative supply rail just less than the -3V.Edit: I was thinking the input voltage had to be slightly above the negative rail, but I checked a few datasheets and they seem to say that ground at the input and negative supply should be ok

author: David Hess
author_rank: Super Contributor
timestamp: July 18, 2022, 12:24:56 am
content: Phase reversal at startup would cause the output to rise to maximum, which would pull the inverting input to ground ending the phase reversal problem, so there is nothing to worry about.

author: tinfever
author_rank: Regular Contributor
timestamp: July 18, 2022, 12:57:30 am
content: Quote from: shakalnokturn on July 18, 2022, 12:08:56 amThat would indeed be simpler! But where's the fun in that?I'd considered that too but was perplexed/curious if inverting it with an LM358 would even work. Whether or not it's the simplest design decision.Quote from: John B on July 18, 2022, 12:10:01 amIt sounds like I can't be clever by inverting the negative voltage without a negative supply rail, but scaling the input negative voltage down so I can use a part like the 7660 is a good idea!I think if I wanted to be really sneaky, I could actually tie the negative supply rail to the -12V rail that I'm trying to monitor. Thus, the input will never be below the negative supply rail.This creates a new problem: what if the input is positive? In that case the output would track the input. This creates two issues: 1) If the negative supply rail is 3V, the output will also be 3V, which would be indistinguishable from a valid -12V input. 2) If the negative supply rail is at 3V, the non-inverting input is technically violating the acceptable input range. I think, since the -12V rail being monitored is the output of an inverting buck-boost supply, it really shouldn't ever be positive, and it really shouldn't be positive with a low impedance, I can just use a diode to clamp that and be pretty safe.This just a thought experiment at this point but I think it would work.Simulation attached. Red line is input voltage, blue line is output voltage.

author: tinfever
author_rank: Regular Contributor
timestamp: July 18, 2022, 01:11:29 am
content: Quote from: David Hess on July 18, 2022, 12:24:56 amIsn't that how it normally works? If the Op-Amp starts with non-inverting input (0V) > inverting input (-2.4V assuming output starts at 0V), doesn't that cause the output voltage to rise in an ideal Op-Amp? So wouldn't phase reversal just be the output doing the opposite and staying stuck at the negative supply rail of 0V?

author: floobydust
author_rank: Super Contributor
timestamp: July 18, 2022, 01:23:10 am
content: For subtleties about the LM358 seeTI Design Guidelines for Devices with LM324/LM358 Cores

author: David Hess
author_rank: Super Contributor
timestamp: July 18, 2022, 02:04:13 am
content: Quote from: tinfever on July 18, 2022, 01:11:29 amAs far as I know, phase reversal for the 358/324 can only cause the output to go to the positive supply, so in this application with an inverting amplifier, it does not matter because it will be self correcting.If the 324/358 was configured as a follower, and the non-inverting input was pulled below the negative supply, then the output would go positive potentially causing problems like latchup if it was within the feedback loop of another amplifier.

author: Kleinstein
author_rank: Super Contributor
timestamp: July 18, 2022, 06:14:28 am
content: The inverting circuit should be OK, as long as the input resistor is large enough. So the input current should not go beyond 1 mA. One would normally choose a sufficient resistors (e.g. > 15 K) anyway. If worried (e.g. ESD or inductive kick-back) one could add 2 back to back diodes to ground and 2nd resistor as an exrta layer of protection, a little like in the circuit shown with 1 diode.With the non imverting input fixed to ground one would not leave the common mode range - so no phase inversion to worry about. The phase inversion can happen when both inputs leave the common mode range.

author: magic
author_rank: Super Contributor
timestamp: July 18, 2022, 07:33:05 am
content: Quote from: David Hess on July 18, 2022, 02:04:13 amYou may be right, but it's a very thin ice you are standing on.In TL072, if the input stage stops driving the second stage, the second stage goes up as you'd expect. In LM358, if the input stage stops driving Q10, its active load Q6 will cause the second stage (Q11, Q15) to pull the outputdown.To keep the output up, the current mirror Q8,Q9 must be actively sinking at least the base current of Q10, even if Q3 is completely cut off.Therefore Q2 collector must be at least Vbe(Q8) above ground.Q2 emitter must be at least at Vbe(Q8)+Vcesat(Q2).Q2 base must be at least at Vbe(Q8)+Vcesat(Q2)-Vbe(Q2), which is approximately ground potential.Now, if you pull Q1 base one diode drop below ground (you can't pull it lower because its BC junction forward biases) it looks like a crapshoot if the various Vbe and Vcesatof different transistor types will align just right to keep Q2 out of saturation and feeding the mirror. In particular, the outcome may depend on the exact amount of current you pull from IN- and perhaps on temperature.Maybe it's designed to work alright, or maybe at least some vendors did it so, but I dunno. TI datasheet quoted by the OP doesn't inspire much confidence. IMO it's not a great idea to use LM358 that way. As for TLV9062, it's a CMOS opamp, so 100% guaranteed to use a different internal circuiteditI suppose one could put a Schottky diode between IN- and ground for peace of mind.

author: Zero999
author_rank: Super Contributor
timestamp: July 18, 2022, 08:58:21 am
content: Just use a few resistors. No op-amp necessary.

author: Terry Bites
author_rank: Super Contributor
timestamp: July 18, 2022, 11:43:37 am
content: TI have a handy guide for single supply circuits for just this sort of thing.

author: tinfever
author_rank: Regular Contributor
timestamp: July 19, 2022, 06:10:11 pm
content: Very interesting! Thank you all!It sounds like the consensus is:- It wouldprobablywork- Actually implementing the original circuit in a product using a LM358 may not be a good idea- It'd be a much better idea to use an op-amp with a datasheet that doesn't mention phase reversal, and has a statement like "Input pins are diode-clamped to the power-supply rails. Input signals that may swing more than 0.5 V beyond the supply rails must be current limited to 10 mA or less." under the Absolute Maximum Ratings. Then one would just need to make sure the resistors are large enough.- Using a Schottky diode on the IN- to GND, with a large enough resistor on the input, could be used to clamp that input to within 0.3V below V-, if I really wanted to use a LM358.- Using a resistor divider is a much more logical solution overall

author: MikeK
author_rank: Super Contributor
timestamp: July 19, 2022, 09:08:09 pm
content: If the micro is only doing this job there's no reason why you can't power it from the -12V/GND source. With regulation of course. The micro just wants Vdd to be 5V higher than Vss (3.3V if that's what you're using).

author: magic
author_rank: Super Contributor
timestamp: July 19, 2022, 09:17:58 pm
content: Quote from: tinfever on July 19, 2022, 06:10:11 pmThat would work, but you better change "doesn't mention phase reversal in the datasheet" to "doesn't have phase reversal"Off the top of my head: TL072, anything4558, NJM2068, NJM4580/RC4580, LM4562, OPA2107 - all have it, none warns about it.Another fine trap is opamps which advertise lack of phase reversal, but actually have it when their absolute maximum ratings are exceeded. For example, when the negative supply disappears, protection diodes internally route negative rail current to one of the input pins, the input pin becomes 0.7V less than the negative rail, the chip goes bonkers, but this is more than the permitted 0.3V/0.5V or whatever so it's never supposed to happen and the vendor doesn't feel like warning you. I have seen a report on DIYAudio forum of some Texas Instruments CMOS opamp being like that.