Can anyone help me improve this? - Page 1
Forum section: electronics / projects

author: void_error
author_rank: Frequent Contributor
timestamp: June 19, 2015, 01:07:58 pm
content: Looks like I've got an unstable mess here with no idea how to fix it. I'll zip the simulation files if needed. Also, it's the first time I use LTspice.

author: Kleinstein
author_rank: Super Contributor
timestamp: June 19, 2015, 02:43:24 pm
content: The circuit looks like a want to be voltage regulator.The problem with this circuit is, that there is quite some voltage amplification from the MOSFETs and transistors. So it will be difficult task to make this stable. One could give it a try with local feedback around the output MOSFET (e.g. about 1 nF, maybe with 100 Ohm in series drain to gate).Starting with a P-MOSFET as output power device, it would be much better to have the OP and reference tied to the positive supply - this would save the way around with the current mirror.In general for such a circuit it's a good idea to look at the output stage only first. So simulate something like only the MOSFET an maybe the 2 or 3 transistors just before that. If that part has an odd output impedance and transfer function, thing get very hard to impossible to make the loop stable. The better test-case than looking at steps in the setpoint is looking at something like a current source a load and watch that reaction and also the AC response. Finally one should take a look at the loop gain examples that come with LTspice.

author: void_error
author_rank: Frequent Contributor
timestamp: June 19, 2015, 03:09:01 pm
content: Yes, it's a voltage regulator, an adjustable one, and it needs to work with up to 55V input voltage.Referencing the op amp to the positive rail is not an option here so that's why I went with the current mirror. It needs to be ground referenced. A carefully placed series RC local feedback thingy might do the trick.I'll try reducing the gain in some way, maybe I'll make it stable. More ideas on how to do that are welcome.EDIT: a 27k resistor between the drain and Q4 base seems to improve things...

author: Kleinstein
author_rank: Super Contributor
timestamp: June 19, 2015, 03:49:08 pm
content: Another point may be swapping R5 and D2 and have some of the feedback (e.g. C3) from before R5. This could make the circuit stable, though at the price of 100 mOhm of more output impedance in the higher frequency range. R 8 might need to be considerably smaller.Having the feedback around the MOSFET will already dampen the extra gain from both the transistors and MOSFET.

author: void_error
author_rank: Frequent Contributor
timestamp: June 19, 2015, 03:58:54 pm
content: Quote from: Kleinstein on June 19, 2015, 03:49:08 pmMoved the C3-R10 group to the left of the diode (between R5 and D2) and it's now perfectly stable, oscillations are gone. I now feel like a complete idiot.There's still some overshoot/undershoot however.D2 is there to protect the soon-to-be-added current sensor (LTC6101) from anything nasty across the output (hint: lab power supply).

author: IconicPCB
author_rank: Super Contributor
timestamp: June 19, 2015, 10:43:54 pm
content: First of all it is not unstable no oscillationsHave You considered something like an LM3900 as a better option for this application?

author: dom0
author_rank: Super Contributor
timestamp: June 19, 2015, 10:58:19 pm
content: Quote from: IconicPCB on June 19, 2015, 10:43:54 pmThat massive overshoot and the twenty pixels wide trace tell me otherwise. One might make the point that the oscillation seemingly does not break the loop (yet), but that's just a matter of loading right there.

author: void_error
author_rank: Frequent Contributor
timestamp: June 20, 2015, 12:20:24 am
content: Quote from: IconicPCB on June 19, 2015, 10:43:54 pmBetter in what way? I know very little about Norton op amps. Internal structure looks quite simple though.Quote from: dom0 on June 19, 2015, 10:58:19 pmManaged to reduce the overshoot by a reasonable amount but that's not what I was concerned about since V2 is going to be a DAC output followed by a low-pass RC filter. Oscillations are pretty much gone now except for very low output voltages (<2V), but their amplitude is very low. I'll run some more simulations tomorrow morning and post the results and see what you people think. It seems that lighter loads are more of a concern.

author: dom0
author_rank: Super Contributor
timestamp: June 20, 2015, 08:35:38 am
content: By the way - is there a specific reason why this has to be low-drop?

author: void_error
author_rank: Frequent Contributor
timestamp: June 20, 2015, 09:44:36 am
content: Quote from: dom0 on June 20, 2015, 08:35:38 amNo, it just ended up this way. It'll be fed from a switching pre-regulator - 1-3V above the output, 1V if I use this low-dropout version or 3V if not. I'd like to keep power dissipation to a minimum even for 5A output current.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: June 20, 2015, 11:04:55 am
content: Niiiice, you added an integrator after an integrator! That's a fine switching supply you've got; just add an inductor and you won't need the outside switcher at all!So, yeah. Cut the current sink. That's how you make a gain of 10,000, and that's how you make an op-amp loop unstable! Sure you can slow it down by adding R+Cs to useful locations, but you're way better off just doing what you were thinking to do in the first place:Design a transistor circuit so that it multiplies the op-amp output by a fixed gain, with at least moderately high bandwidth.Attenuate the op-amp input by the same factor.Now you can use the op-amp as a unity gain buffer, if you so desire, because the loop outside of it has unity gain as well.Of course, the fundamental problem you'll find is, since you need to use the discrete circuit to regulate the PMOS output (because it's the last part of the gain loop, and can't be left open as shown), you'll be building a complete error amplifier around it. Which obviates the need for the error amp at all; you might as well use the discrete circuit directly.Tim

author: void_error
author_rank: Frequent Contributor
timestamp: June 20, 2015, 11:41:01 am
content: Quote from: T3sl4co1l on June 20, 2015, 11:04:55 amI only see one integrator, where's the second one?Quote from: T3sl4co1l on June 20, 2015, 11:04:55 amThere I go again, running circles around the same problem... At least the MOSFET is faster than a Darlington pair.Quote from: T3sl4co1l on June 20, 2015, 11:04:55 amI'm going to need the op amp anyway because I won't be able to get low offset out of it along with low offset temperature drift using discrete stuff. Offset voltage can be trimmed but offset drift will require thermally paired transistors which I can't get. I tested a discrete op amp once on a breadboard and if there's just a small temperature difference of the paired transistors (current mirror or input) the offset sky rockets.

author: void_error
author_rank: Frequent Contributor
timestamp: June 20, 2015, 02:32:58 pm
content: What did I screw up now? Why does it undershoot so much?NOTE: red is op amp output

author: T3sl4co1l
author_rank: Super Contributor
timestamp: June 20, 2015, 07:58:15 pm
content: Hmm, some sort of integrator windup thing I should guess. Rising edge looks pretty good. Going to guess the falling edge varies with amplitude and load resistance?Tim

author: void_error
author_rank: Frequent Contributor
timestamp: June 20, 2015, 09:04:21 pm
content: It varies with load resistance. I'll have some more simulations run and speaking of that, how do I determine the frequency response? I know I have to do an AC analysis but do I stack an AC source on top of a DC one to have some offset?

author: dom0
author_rank: Super Contributor
timestamp: June 20, 2015, 09:45:47 pm
content: AC analysis in SPICE is based around the calculated DC operating point (.op), so to get meaningful results you want a meaningful DC op point, i.e. realistic DC input and DC load.

author: Zero999
author_rank: Super Contributor
timestamp: June 20, 2015, 09:48:19 pm
content: Yes it has far too much gain.All of those transistors provide a lot of gain.You don't need any gain to drive the MOSFET's gate. All that's needed is level shifting. In fact you could do with some attenuation before the MOSFET.Attached is an example: D1 shifts the voltage applied to the M1's gate and R3 and R4 attenuate by a factor of 3.2. Expect to adjust this in real life because it's somewhat dependant on the gate threshold voltage. You'll probably need to change the level shifting zener voltage (perhaps it could be replaced with a VBEmultiplier or TL431) and R3 and R4 may need to be changed.Having a common source amplifier as the output pass element will always make this circuit prone to oscillation. An emitter follower would be more stable but it has a higher dropout voltage and greater current drive requirements.

author: void_error
author_rank: Frequent Contributor
timestamp: June 21, 2015, 09:27:40 am
content: Unfortunately that solution doesn't work for me. V1 will either be fixed or track 1-3V above the output voltage, depending on the current limit set (will be added later). I'm wondering if I could have a floating op amp driving a MOSFET or BJT and doing the level shifting by converting the output voltage of the ground referenced op amp to a current then shifting it and converting it back to a voltage via a resistor tied to V1...Quote from: dom0 on June 20, 2015, 09:45:47 pmI suppose that means having V2 set to 1V (10V output) in series with the AC source set to 100mV? That's a meaningful DC operating point.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: June 21, 2015, 11:24:00 am
content: If you want the signal referenced to the output (calling Vout == GND as far as the amp is concerned), you certainly can do that. That way the voltage sense divider is negative, current sense is available, and if you switch an NMOS, you can direct drive that as well (note that it's not a source follower, because the drive is still source referenced). The only thing missing is VREF; if this is just a pot, you can put the VREF source up on this elevation as well, and all is fine. If you want it externally adjustable, you might instead use a series of current mirrors (made 'perfect' with the help of op-amp(s)) and resistors to communicate the correct DC voltage or offset.Tim

author: void_error
author_rank: Frequent Contributor
timestamp: June 21, 2015, 12:08:59 pm
content: I want to keep everything ground referenced.What I'll need is to mirror(?) the op amp output swing to V1... Let me explain: op amp output goes from 0 to x which should cause the gate of M1 to go from V1 to (V1-x)... I might have got this backwards...

author: Zero999
author_rank: Super Contributor
timestamp: June 21, 2015, 08:16:07 pm
content: Of course, level shifting with the zener diode will only work over a small range of supply voltages.You're right you need another amplifier and that common base is most suitable here because of it has a low phase shift.There's no need for a current mirror though, just exchange the op-amp inverting and non-inverting pins.To improve stability, the gain of the common base and common source amplifier can be reduced by adding negative feedback (R4 and R6) see attached.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: June 21, 2015, 09:06:28 pm
content: ^ Here we go. Am implementation of:Quote from: T3sl4co1l on June 20, 2015, 11:04:55 amAs shown above, voltage gain is about 10 (the ratio of series emitter resistor to feedback resistor), and the voltage feedback ratio is much less than 1/10, so it'll be stable.One thing that might be missing: frequency response. The gate may have too much capacitance. So it could benefit from a zero-offset follower (two diodes, two transistors, and no extra resistors are needed since the bias and pull-up resistor will cover it).A CCS pull-up could also be used, to improve the gain of the driver part, keeping in mind that this probably adds more phase shift in the cutoff range, which might be helped by adding some series drain resistance on the pass FET (thus giving it some direct voltage gain, so that the local feedback loop does its job).This resistance can be sourced from capacitor ESR, which is in part why LDOs used to require it. Modern designs are usually designed for stability with very low ESR, but old ones are still just as available, and still just as cryptic in their performance range.

author: void_error
author_rank: Frequent Contributor
timestamp: June 21, 2015, 10:02:25 pm
content: Hmm... gate capacitance will slow down the MOSFET turn-off with R3 being 10k and I wonder how much it'll overshoot.

author: Zero999
author_rank: Super Contributor
timestamp: June 22, 2015, 08:35:00 am
content: Quote from: void_error on June 21, 2015, 10:02:25 pmThe simulation doesn't show any overshoot when a step is applied to the input. I didn't simulate a change in load transient though. I would post the results but I'm at work at the moment and don't have LTSpice on this PC.R3 can be reduced but it will lower the loop gain so the R4 and R6 may need to be changed.

author: void_error
author_rank: Frequent Contributor
timestamp: June 22, 2015, 10:18:26 am
content: I've simplified my previous version and even the 0V-20V-0V step response looks good.How do I put more MOSFETs in parallel here so they share the current equally? This is going to have to also be operated with the tracking pre-regulator disabled, up to a few hundred mA, so the power dissipation should be spread across multiple pass devices.Load response looks decent I think...

author: Zero999
author_rank: Super Contributor
timestamp: June 22, 2015, 08:24:30 pm
content: Mine is better and uses fewer components.

author: void_error
author_rank: Frequent Contributor
timestamp: June 22, 2015, 09:17:18 pm
content: Quote from: Hero999 on June 22, 2015, 08:24:30 pmHow do you add high side current sensing and a current control loop to your circuit?EDIT: Actually with the simulation parameters I used your circuit is slower and overshoots/undershoots more than mine for the load transient response.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: June 22, 2015, 09:52:08 pm
content: If you don't mind op-amp saturation and integrator wind-up (i.e., poor recovery coming out of current limit), use a +VIN side current shunt, and a PNP current sense transistor. This clamps the gate voltage towards +V while regulating the source voltage at 0.7V below +V.The same circuit (complemented) is used for pretty much everything.If you don't like the higher dropout voltage (~0.7V at limit), you can bias it up with a smaller voltage reference and a low overhead diff amp. (I usually build one using a diff pair and 'volt amp' transistor like so:http://seventransistorlabs.com/Images/Discrete_Tube_Supply.png)Tim

author: void_error
author_rank: Frequent Contributor
timestamp: June 22, 2015, 10:07:13 pm
content: Quote from: T3sl4co1l on June 22, 2015, 09:52:08 pmThat'll look like the complement of Q3-Q4-R4 with the MOSFET instead of Q3...? I need fairly precise adjustable current limiting and ground referenced output current to voltage conversion, and I do have one solution for that, although it's going to be slower and op-amps are going into saturation but that might be avoided.

author: Zero999
author_rank: Super Contributor
timestamp: June 22, 2015, 10:18:01 pm
content: Quote from: void_error on June 22, 2015, 09:17:18 pm1) With ease. The current sense resistor can go in between the MOSFETs drain and R1 & R2. The current amplifier can be connected to Q1's emitter via a lower value resistor than R4, so it has more gain and a diode to stop it increasing the voltage below the current limit.2) That can be improved by altering the values of C1, R4 to R6.

author: void_error
author_rank: Frequent Contributor
timestamp: June 23, 2015, 02:55:43 pm
content: Made some tweaks to both circuits, here are the results:

author: Zero999
author_rank: Super Contributor
timestamp: June 23, 2015, 06:13:42 pm
content: I've done the same and improved it further.By the way, what does the diode do?

author: T3sl4co1l
author_rank: Super Contributor
timestamp: June 23, 2015, 06:47:47 pm
content: Quote from: Hero999 on June 23, 2015, 06:13:42 pmThat's downright sexy.Yeah, I don't know what the diode's doing there.. just losing dropout really.Tim

author: void_error
author_rank: Frequent Contributor
timestamp: June 23, 2015, 11:00:24 pm
content: Double checked with the LTC6101 datasheet and the diode is not needed, it was there to prevent any voltage spikes from the output getting back to the current sensor.If Hero999's version works well with a tracking pre-regulator I'm sticking with it. Gotta run some more tests on it but I think it's better than mine. I wonder how it performs with MOSFETs which have higher gate capacitance...

author: void_error
author_rank: Frequent Contributor
timestamp: June 24, 2015, 12:09:58 am
content: Well here's an unfortunate situation where both circuits will fail miserably...Luckily this will never happen.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: June 24, 2015, 01:16:03 am
content: I don't see what's different, elaborate?Tim

author: void_error
author_rank: Frequent Contributor
timestamp: June 24, 2015, 07:38:47 am
content: 10uF instead of 100uF for the output capacitor.EDIT: More tweaks and they're both stable again.3mA to 3A load in 1ns at different input voltages.Minimum dropout voltages are 1.5V for Hero999's version and 2V for mine. Overshoot increases when the dropout voltage is lower. At 2V dropout and 5V output and 3mA-3A-3mA load transient mine overshoots less, probably because of Q2 which discharges the gate faster than a resistor.

author: Zero999
author_rank: Super Contributor
timestamp: June 25, 2015, 09:00:49 am
content: Adding an emitter follower after the common base stage may help to drive the MOSFET's capacitance. I haven't tried simulating it though as I'm at work and don't have LTSPICE on this PC.An emitter follower output stage would be best as far as stability is concerned but it comes at a cost of increased drop-out and drive requirements. Having gain in the output stage will always make it more prone to oscillation and difficult to stabilise.

author: void_error
author_rank: Frequent Contributor
timestamp: June 25, 2015, 10:03:12 am
content: Thanks for the idea!Added an emitter follower and things improved a lot.Also changed C1 to 3n3, R7 to 470R and added a 2n2-820R in parallel with R1.However it's still overshooting a more at 5mA-5A-5mA compared to mine but it behaves pretty much in the same way, even with a 22u output cap. Tested for an input voltage of VOUT+2.5V.If I manage to make this circuit work at up to 40V/5A max output I'll be happy. Got mine up to that with very few tweaks - only changed two component values.The only gain in my output stage is the MOSFET since I'm not running it in a closed local loop like you do. So far it looks stable. I might be able to add some local feedback and it might improve stuff.Didi a DC sweep on your circuit (with my tweaks) and the minimum output voltage is about 1.1V, I need to be able to go down to 0V.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: June 25, 2015, 02:09:18 pm
content: Try an R+C across R6 in Hero's latest.Tim

author: void_error
author_rank: Frequent Contributor
timestamp: June 25, 2015, 03:12:53 pm
content: Quote from: T3sl4co1l on June 25, 2015, 02:09:18 pmThat does seem to do the trick. Now, how do I make it go down to 0V?

author: Zero999
author_rank: Super Contributor
timestamp: June 25, 2015, 08:53:00 pm
content: What did you do wrong?I've done the same and it goes down to 22.9µV.

author: void_error
author_rank: Frequent Contributor
timestamp: June 25, 2015, 09:14:47 pm
content: Quote from: Hero999 on June 25, 2015, 08:53:00 pmIt might be because I used a controlled source on top of a voltage source to simulate a tracking pre-regulator tracking 2.5V above the reference voltage x10.No. It's actually because I used a LT1368 instead of the LT1013. And the pre-regulator.No idea. Copied the circuit you posted above and it goes down to above 3V with no load. I give up.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: June 25, 2015, 10:22:09 pm
content: Next thing to look at might be, can we remove R8 as well?Also, check out variation on R8, since that's probably going to be capacitor ESR in practice, and very uncertain.Tim

author: Zero999
author_rank: Super Contributor
timestamp: June 25, 2015, 10:25:24 pm
content: Quote from: T3sl4co1l on June 25, 2015, 10:22:09 pmI believe R8 is a current sense resistor in preparation for a current limiting circuit.

author: void_error
author_rank: Frequent Contributor
timestamp: June 25, 2015, 10:53:58 pm
content: Quote from: Hero999 on June 25, 2015, 10:25:24 pmThat's correct.I guess LTspice is drunk. I did a sweep from 2V to 0V and it actually goes down to zero freaking volts. It doesn't seem to like it from 0V to 2V.

author: void_error
author_rank: Frequent Contributor
timestamp: June 26, 2015, 09:23:23 am
content: Actually I have an idea why it won't reach 0V output when the input voltage is 2V or less above the output voltage. The MOSFET's gate voltage can only go down to 0V so then VGSis equal to the dropout voltage, in this case 2V, which is probably not enough to turn it on (datahseet says VGS(th)is between 2V & 4V). LTspice doesn't seem to like this.

author: void_error
author_rank: Frequent Contributor
timestamp: June 26, 2015, 10:53:56 am
content: And [insert drum roll here] problem solved. There was current leaking into the output as well as not enough swing for driving the gate. A NPN emitter follower and a diode solved that.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: June 26, 2015, 10:58:30 pm
content: Seems more likely the minimum load wasn't met. Some bias current flows into the output so you can't test with no load. Use a minimum load like 10% of full load, then figure out actual minimum load later.A couple of weird things.What's the diode for?You've got local feedback from below R4, not above.Different value C4.Why is Vsupply = 10*Vref + 2.5?Tim

author: void_error
author_rank: Frequent Contributor
timestamp: June 26, 2015, 11:38:00 pm
content: Quote from: T3sl4co1l on June 26, 2015, 10:58:30 pmI found a better and simpler solution so ignore the above post. I used Hero999's version with the NPN biased below 0V and the PNP emitter follower's collector tied to V- so it now goes down to 0V with no load.

author: void_error
author_rank: Frequent Contributor
timestamp: June 29, 2015, 11:10:05 pm
content: I've been doing some homework lately...Ditched the MOSFET LDO solution because it seems to have quite strict output capacitance requirements to be stable and went with a quasi-LDO using BJTs since this is going to be part of a bench supply (0-20V @ 3A, scalable up or down). Found some very useful stuff in this documenthttp://igor.chudov.com/manuals/Linear-Voltage-Regulators-NatSemi.pdf.The output capacitor has an ESR of 50mohm so probably a small 100nF ceramic would help. Guess it's time to breadboard it.Here's how the waveforms & bode plot look look like. This is the best I could do. I'd like some feedback please (call it constructive criticism).