Op amp behavior in voltage regulation - Page 1
Forum section: electronics / beginners

author: derGoldstein
author_rank: Regular Contributor
timestamp: July 01, 2016, 10:12:24 pm
content: I've been watching some of Dave's old videos on linear power supplies (#90, #221) because I wanted to use an op amp and a mosfet to do linear voltage regulation. In EEVblog #221 he mentions that if you were to create a setup like in reg1.png (attached), you'd have a very hard time getting it to work consistently. In that circuit, the op-amp is used as a non-inverting amplifier to drive a darlington transistor.Why would this create a problem? Wouldn't the op amp continuously adjust its output so that its two inputs match? Is it because it will start oscillating or the output would be very noisy?In the second attached image (reg3.png) I hooked up the op-amp's output to the gate of a low-side mosfet, and the inverting input to its drain. The goal was the same, to regulate voltage. I didn't know what would happen here so I wired it up on a breadboard. The resulting behavior depends on the load, but usually when the voltage at the non-inverting input approaches ~11V, the mosfet turns on completely and instantaneously. It then remains that way until such time as the voltage at the non-inverting input goes down to almost 0V, at which point it shuts down. It's a bit like hysteresis except less stable.I think I'm misunderstanding how op amps function... In both scenarios the op amp can adjust its output to a voltage/current which would make its two inputs match, but it doesn't. Why?

author: MosherIV
author_rank: Super Contributor
timestamp: July 01, 2016, 11:05:04 pm
content: HiI am not 100% sure why the first circuit would not work. Looks OK to me.It might oscillate because the op-amp has very high gain and might go unstable while reacting to loads but you have a cap, which I am guessing you put in to steady the output voltage but actually if you adjust the value, is actually acting as a filter on the negative feedback.Try looking at Dave's 2nd video on building a precision 1Amp current source. He does not go into how to calculate the filter value but you can see what effect not having it does.I used a similar circuit as a electronic load and it seemed to work OK for me without the filter, but then I was using a 741The 2nd circuit will definitely not work correctly.The circuit is trying to maintain the voltage across the FET and not your load.An Op-amp will set it's output to be the difference between the 2 inputs. Hence if you join the output to 1 input, the output will be the difference between the 2.Your circuit is more complex than just trying to control the difference between the 2 inputs, you are trying to adjust with a external influemce - your output load. The op-amp is in open loop mode which means it will apply full gain until it meets equibibrium, it is this that causes instability.Try, op-amp with both inputs to ground - the output should near 0vremove one input from ground and let it float (not attached) - the out will either go to full rail +v or -V (or 0V if you are running in single rail) - why because the op=amp has applied full gain.You can control the gain but that is not appropriate in this application.

author: derGoldstein
author_rank: Regular Contributor
timestamp: July 02, 2016, 12:49:40 am
content: Is the first circuit (with the darlington) considered closed-loop because the op amp output can flow back through the transistor's output?The reason I thought the second circuit could work is because I thought it would rely on the same principal as a circuit using an op-amp and a mosfet to regulate current (attached). I'm crap at analog so I probably misunderstood. Is there any way to use an op amp to control a low-side mosfet to regulate the voltage across the load? Or will I have to use a high-side mosfet and use its output as feedback?

author: Audioguru
author_rank: Super Contributor
timestamp: July 02, 2016, 12:54:02 am
content: The lousy old LM358 dual opamp (and the LM324 quad) have crossover distortion if they do not have a fairly high load current. Then at certain input voltage settings the output voltage will jump up and down as the output crosses over.

author: danadak
author_rank: Super Contributor
timestamp: July 02, 2016, 02:13:56 am
content: The first circuit is closed loop beause the OpAmp output, if it changes by delta Vthen the inverting input also changes, in this case by delta V since you have fullfeedback, not a fractional amount of feedback. Stated another way this circuit usesall its G to force Vout to be equal to Vin+ of the OpAmp.Regards, Dana.

author: danadak
author_rank: Super Contributor
timestamp: July 02, 2016, 02:18:44 am
content: The second circuit. as Vgs is increased, Vds drops, fed into invertingOpAmp input that increases Vgs, so you have + feedback, so are gettingthe latching effect where output is driven to one rail or the other. Swapthe input connections on the OpAmp.Regards, Dana.

author: Audioguru
author_rank: Super Contributor
timestamp: July 02, 2016, 02:31:11 am
content: Another problem with the lousy old LM358 is that it is slow. Its slew rate cannot change its output fast enough for negative feedback to eliminate its crossover distortion.Loading its output causes one of its output transistors to be in class-A eliminates its crossover distortion.

author: derGoldstein
author_rank: Regular Contributor
timestamp: July 02, 2016, 03:42:39 am
content: danadak:I swapped the two inputs and now it no longer has the hysteresis characteristic. Instead the gate voltage remains very low until the pot is turned up to the maximum, at which it either goes up to ~4V, or up to ~10V, seemingly at random.Any way it's done, linear regulation will always just turn the excess energy into heat, right? I could generate a PWM to switch the mosfet on and off to get a particular average voltage, and the efficiency will the same as if I modulated the mosfet's gate to control the voltage? It just seems like doing that will require additional components to achieve the same result...

author: bson
author_rank: Unknown
timestamp: July 02, 2016, 04:29:07 am
content: In the first circuit the op-amp's output will be two diode drops above the non-inverting input. At 11V you're probably hitting its maximum output signal level and get latchup. This is a clue to the potential problem with it: any transient event (or short, or inductive switched load), that will temporarily overload it can cause it run itself into latchup.(Or maybe latchup isn't a technically correct term for this slow recovery.)

author: Connoiseur
author_rank: Regular Contributor
timestamp: July 02, 2016, 06:54:18 am
content: Quote from: derGoldstein on July 02, 2016, 03:42:39 am1) At what point in the circuit do you want voltage regulation? Don't measure the output between gate and ground. It is bound to be different from the required value. MOSFET does not conduct until the (gate) threshold voltage is reached. Once the gate voltage exceeds the threshold value you have drain current.Your circuit design regulates the voltage with reference to the POSITIVE RAIL AND NOT THE GROUND. Therefore you should probe across the load.2) PWM is a good solution if the power required is more, however it will increase BOM and complexity considerably.3) No efficiency will be (almost always) higher in case of switching regulator.

author: MosherIV
author_rank: Super Contributor
timestamp: July 02, 2016, 08:40:48 am
content: Hi"Is the first circuit (with the darlington) considered closed-loop because the op amp output can flow back through the transistor's output."The op-amp is in close loop mode because the output is fed back into the input.This can be with negative feedback, by joining the op to the negative input (note: this is most stable).It can also be with positive feedback, by joining the op to the positive input BUT this is highly unstable."Is there any way to use an op amp to control a low-side mosfet to regulate the voltage across the load?"The first circuit you used should also work for FETs. FETs of any type are slightly harder to get right because the way they work compared to transistors. They are controlled by gate voltage instead of base current.(I just realised why Dave suggested using the darlington, in case the op-amp does not have enough current output to drive the transistor base current. This is highly dependant on the transistor and the application)"I swapped the two inputs and now it no longer has the hysteresis characteristic. Instead the gate voltage remains very low until the pot is turned up to the maximum, at which it either goes up to ~4V, or up to ~10V, seemingly at random."Of course this will not work, you using positive feedback now. It will make the op swing more and more in one direction due to positive feedback. It oscillates because when it is at full swing, noise on the - ip suddenly makes the op go jn the opposite direction and the op will go to the opposite end."linear regulation will always just turn the excess energy into heat, right?"Yes, the way this circuit work is by turning the transistor/fet into a variable resistor by turning the device partially on. The tran/fet MUST be heat sinked.

author: Dave
author_rank: Super Contributor
timestamp: July 02, 2016, 10:06:44 am
content: There's more to opamp stability than just providing a negative feedback path. Unfortunately, it isn't a subject that is simple enough to cover in a Fundamentals Friday video.Quote from: MosherIV on July 02, 2016, 08:40:48 amIt won't be stable without high-frequency compensation.Quote from: MosherIV on July 02, 2016, 08:40:48 amNot highly unstable, it simply won't work.Quote from: MosherIV on July 02, 2016, 08:40:48 amA MOSFETisa transistor. It's simply one of the many types of transistor. The transistors that you're referring to as simply 'transistors', are bipolar junction transistors (BJT). The latter are not really controlled by the base current, but it's a simplification that people like to make because at lower currents, the base current is proportional to the collector current.Quote from: MosherIV on July 02, 2016, 08:40:48 amNo, no, no. There are many issues with that circuit, but having positive feedback isn't one of them.

author: Circlotron
author_rank: Super Contributor
timestamp: July 02, 2016, 11:33:05 am
content: The first circuit should work just fine. Any crossover distortion in the opamp should have no effect because the opamp output never crosses over! While the cct is supplying current to a load the opamp only ever tries to pull up the base of the transistor it is feeding.The second circuit has positive feedback because the output from the mosfet drain is inverted compared to the gate but still gets fed back to the (-) input of the opamp same as the first cct. As danadak says, swap the opamp inputs.

author: Dave
author_rank: Super Contributor
timestamp: July 02, 2016, 12:32:42 pm
content: Quote from: Circlotron on July 02, 2016, 11:33:05 amYeah, no.Check out the attachments. The first image shows a circuit without compensation, the second one with compensation. I couldn't be bothered to wait for the entire simulation to go through on the first one, because the oscillations make the sim incredibly slow, but you can see what's going on there.

author: danadak
author_rank: Super Contributor
timestamp: July 02, 2016, 01:20:12 pm
content: There are several problems trying to use a power MOSFET like you show -1) First this circuit, if it worked would be a current source not a V source.2) MOSFET has huge Ciss, the LM358 cannot drive C loads like that w/ooscillation, as can be seen in the attached sim. In fact this is aggravated byMiller effect when MOSFET is in linear region.3) The LM358 is not RRIO, so that is a major limitation on dynamic range controland allowable input CM range signals.4) Violating the input CM range some OpAmps experience phase reversal oninput to output. I do not know if the LM358 exhibits this.https://www.fairchildsemi.com/application-notes/AN/AN-9010.pdfhttp://www.infineon.com/dgdl/mosfet.pdf?fileId=5546d462533600a4015357444e913f4fRegards, Dana.

author: derGoldstein
author_rank: Regular Contributor
timestamp: July 02, 2016, 03:41:52 pm
content: Quote from: Connoiseur on July 02, 2016, 06:54:18 amI measured the voltage across the load.Quote from: Connoiseur on July 02, 2016, 06:54:18 amThat's one of the reasons I'm trying to find a simpler solution. If I use PWM I'd need an oscillator and a comparator along with the op amp and voltage reference.Quote from: Connoiseur on July 02, 2016, 06:54:18 amI meant when comparing different linear regulators. SMPS will be much more efficient, but I don't require that efficiency here and I want to avoid the additional complexity.Quote from: MosherIV on July 02, 2016, 08:40:48 amBut in the first circuit it's a high-side switch, which means (in the case of a mosfet) I'd need to drive it 10V higher than it's source. Since I'm not using a PWM I wouldn't be able to use a bootstrap either.That's why I asked about driving a low-side mosfet. I can use a darlington like in the first circuit but then the voltage drop will be higher (~1.5V).I think I could get this done with a fairly cheap microcontroller (attiny13) driving a low-side mosfet. I'd feed the mosfet's drain into an ADC, and use a PWM output (as a DAC, not directly as a PWM drive) to drive the gate. When the voltage increases beyond a certain value it'll decrease the pulse-width, and if it goes under a certain value it'll increase the pulse-width. I'd need a logic-level mosfet to directly drive it from the MCU.But that requires and entire additional microcontroller that will need programming... Even if it's relatively cheap and only 1 component, the added complexity is significant.

author: danadak
author_rank: Super Contributor
timestamp: July 02, 2016, 08:21:38 pm
content: If you look at a Cypress PSOC, you would drag and drop a PWMonto a schematic. Configure it, f, DC, etc.. Same for an A/D.Then start it in code, both have simple 1 line APIs to do this, andwith a simple loop look at A/D load V value and write back to PWM tocorrect for load changes. Maybe 10 lines of code max.Then if you want to be clever use DMA engine and do this all in HW.All while using processor for other "stuff"The PSOC has all the HW you will need, Vref, A/D, PWM, DMA, evenhas a digital filter block if you want to filter the A/D feedback values.Also has OpAmps, Comparators, logic elements, LUTs, for other tasks.USB, I2C, UART, One Wire, CAN, LCD......tons of stuff, see attachment.Again most code written for you to manage all the HW elements, you justuse the API calls in C or assembler. Tons of videos, cheap boards, someArduino footprint compatible.Look at PSOC 4, 4M, 5LP for starters.Regards, Dana.

author: MosherIV
author_rank: Super Contributor
timestamp: July 02, 2016, 08:22:10 pm
content: Hi"That's why I asked about driving a low-side mosfet."As various people have explained, trying to use the circuit with the mosfet in 'low side' will not do what you want it to do.The op-amp is measuring the voltage across the mosfet and trying to maintin the voltage at the mosfet source (top of mosfet)What you actually want is to regulate the voltage across your load.That is why the mosfet MUST be 'high side' as you call it.There is NO WAY to make the circuit regualte the voltage across the load if the op-amp is measuring the voltage across the mosfet.Why must it use a mosfet?What kind of load/power/current will the circuit provide?Bear in mind that it does not matter whether a mosfet or bjt is used, either must dissapate the same amount of power.To summarise, the first circuit is the only one that will stand a chance of what you want - voltage regulation.

author: bson
author_rank: Unknown
timestamp: July 02, 2016, 09:04:01 pm
content: How about starting with an integrated adjustable voltage regulator instead of trying to make your own based on an op amp (which would make a dandy error amplifier, but there's more to regulation). Something like (warning: 10 minute schematic whip-together) this below. Rs is a sense resistor that determines the response of Q1 to offload the LM317. (Ignore the Q1 symbol, I couldn't quickly find a generic one for an enhancement mode device, but obviously it needs to be an enhancement mode power MOSFET.)

author: derGoldstein
author_rank: Regular Contributor
timestamp: July 02, 2016, 09:34:51 pm
content: Quote from: MosherIV on July 02, 2016, 08:22:10 pmNot necessarily that circuit in particular, just a circuit that controls a low-side mosfet in order to regulate voltage across the load.Quote from: MosherIV on July 02, 2016, 08:22:10 pmThe reason I'm trying to get a mosfet to do this, specifically a low-side one, is that I'm already using a low-side mosfet to regulate current, and I'd like to be able to regulate both voltage and current using the same switch to reduce the the voltage drop to a minimum. I could do it with an MCU, but I'm trying to find out if there's an analog way of doing it.Circuit reg4 (attached) would be able to regulate just the voltage. By adding a sense-resistor (reg5) it should be possible to regulate both voltage and current (CC/CV).What I'm working on here in particular would be used to charge lithium-ion battery packs. Up to a current of 1A you have a lot of options, but go up to 4A and you're left with very few, usually quite expensive ICs.

author: MosherIV
author_rank: Super Contributor
timestamp: July 02, 2016, 10:15:50 pm
content: Hi"The reason I'm trying to get a mosfet to do this, specifically a low-side one, is that I'm already using a low-side mosfet to regulate current, and I'd like to be able to regulate both voltage and current"I am affraid that it is impossible to regulate both volts and current at the same time.Ohms law says that.You can regulate the current (constant current) but the voltage must be the variable to regulate for a varying load.You can regulate the volts (constant voltage) but the current must be the variable to regulate for a varying load.You can regulate the voltage and current BUT the load MUST be the variable.Are you trying to emulate a bench power supply with constant voltage and current limit?

author: derGoldstein
author_rank: Regular Contributor
timestamp: July 02, 2016, 10:43:04 pm
content: Quote from: MosherIV on July 02, 2016, 10:15:50 pmYes, that's what I meant. I just see these circuits referred as CC/CV.Basically, while the current is lower than a certain point the voltage is kept constant. When the current goes over that point then the voltage is modulated to keep the current constant. This is also how you'd charge lithium-ion batteries (you can charge a lithium-ion cell by setting a bench power supply voltage to 4.2V and set the current limit to whatever the cell can handle).I think this is the simplest circuit I've found that'll do that:http://forum.allaboutcircuits.com/blog/a-16-16v-1-67a-constant-voltage-constant-current-lab-psu.480/Could anyone comment on how stable/practical that circuit is?

author: MosherIV
author_rank: Super Contributor
timestamp: July 02, 2016, 11:20:36 pm
content: HiSo, you are trying to emulate a bench psu.They are actually constant voltage with a current limit, not constant current.Charning LiIon batteries with bench psu is very dangerous, use a dedicated LiIon charger. They do a number of things: timer cut off, constant current then constant voltage charging. They usually use dedicated charge controller devices.The simplest to follow design for a linear psu that I know of is this onehttp://www.microsyl.com/index.php/2010/03/31/bench-power-supply-0-25v-0-5amp/It uses 2 op-amps, one for cv and one for current limit. They are ORed together so that the cv normally controls the power transistor, when the current limit is reached, the other op-amp takes over because it pulls the op voltage down to the set current.The cv op-amp measures the output voltage.The current limit op-amp measures a high side current shunt (resistor) via a special device. Op-amps cannot directly measure the drop of high side shunts.Hope this helps. Do ask questions if you have any querries.