Current Limiting and Oscillation  - Page 1
Forum section: electronics / projects

author: maurosmartins
author_rank: Regular Contributor
timestamp: April 14, 2021, 02:23:42 pm
content: Hello all,I'm building a simple DAC controlled power supply based on a LM317. I'm using a dual DAC so set both output voltage and max output current, here is my schematic (R11 and LED3 not mounted):

author: Vovk_Z
author_rank: Super Contributor
timestamp: April 14, 2021, 04:31:17 pm
content: Isn't it a software problem, possibly?

author: maurosmartins
author_rank: Regular Contributor
timestamp: April 14, 2021, 05:08:16 pm
content: Hello,Quote from: Vovk_Z on April 14, 2021, 04:31:17 pmSW only writes the DAC values it should not play a role afterwards. I think it has to do with the LM358 oscillating.Best regards, Mauro.

author: mikerj
author_rank: Super Contributor
timestamp: April 14, 2021, 05:28:47 pm
content: I'm not surprised it's oscillating, the NCS213 is a very slow device and the MIC6270 adds a huge amount of gain to the loop, and you also have IC1A in the loop. You are effectively trying to use a fairly mediocre comparator in it's linear region as an op-amp in this circuit.Additionally when in constant voltage mode your over-current indicator LED is injecting significant amounts of current into the voltage set point node just after the DAC. This will not only give inaccurate voltage setting but adds additional feedback when the current limit is reached. Have you not noticed the LED glowing even when you are not in current limit?Not sure where to start to be honest, certainly R11/LED3 should be removed, but you are most certainly going to need some compensation in the loop.

author: maurosmartins
author_rank: Regular Contributor
timestamp: April 14, 2021, 08:40:13 pm
content: Hello mikerj and thank you for your reply,Please note that I've informed on the original post that these components are not mounted because I also thought they were a bad idea.Quote from: mikerj on April 14, 2021, 05:28:47 pmnevertheless the remaining part of your comment is not so clear to me, can you please explain differently?Quote from: mikerj on April 14, 2021, 05:28:47 pmI'm only comparing the reference voltage from the DAC with the amplified voltage from the shunt resistor, so what do you mean by:Quote from: mikerj on April 14, 2021, 05:28:47 pmI also think I need to compensate the loop but honestly I have no clue on how to do it.Other suggestions on how to implement current limiting are welcome.Best regards, Mauro.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: April 14, 2021, 08:54:10 pm
content: Try a schottky (e.g. BAT54) from ADJ to OUT?Tim

author: maurosmartins
author_rank: Regular Contributor
timestamp: April 14, 2021, 09:04:51 pm
content: Hello T3sl4co1l and thank you for the reply,I'll try it as soon as possible (I don't have a schottky on hand) nevertheless, what is the reason behind this?Best regards, Mauro.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: April 14, 2021, 09:50:30 pm
content: Oh nevermind, I see it now, the yellow highlight of course. Yeah, you made an oscillator, not sure what else to expect?I can explain what is missing. A typical thought process goes like this:- Default: output a regulated voltage- When current goes above the set threshold, turn off the outputAnd... that's that. See the problem? Well, let me continue, as reality necessarily must--- So what happens after the output is turned off?- Current falls below threshold.- So output goes back to default voltage.- Which trips the current threshold.- Etc.It's an explicitly unstable system, due to rigid binary thinking.To get a useful response, we need to break the loop somehow.Often, it's enough to simply latch the output. Instead of disabling the output only above threshold, have a separate circuit (a flip-flop) store whether the output is enabled or not. Trigger the flip-flop, and the output becomes disabledand remains disabled. It doesn't oscillate, it turns off like a fuse.Which naturally leads us to the next problem: how does it reset?We can have a power-on reset, or a manual reset button (or signal from an MCU or whatever), or have a timed delay generate a reset -- in which case, we're making an oscillator again, but this time it's specified explicitly, not arising as an emergent property.And this might be nice. It sounds good in principle. But in a lot of uses, we will probably find it's unexpectedly annoying: it trips fromanything, even just touching a capacitor to the output (for some values of capacitance). Even if it's auto-restarting, it might just sit there chattering, rather than starting up, even when the load is just a few mA and the setpoint is 1A or something.So we might go further and ask, for a short instant in time, what should we do?When charging a capacitor from a constant voltage, a large initial current flows, reducing over time, to zero as the voltage stabilizes to nominal output.Is this behavior we want to permit, modify, or prohibit?To permit it: we can simply delay the response, perhaps by adding a timer between the comparator and flip-flop. Only trip if it remains active for the entire time period, otherwise reset the timer. (Or not fully reset the timer, in which case we can try to model a physical process, like the internal temperature of the pass regulator or load: it can sustain some current for some time, but too much current, too often (it doesn't have to all be in one whole gulp) and it trips. In this case, the timer's count would bleed away when inactive, so that when inactive only briefly, it doesn't lose much time and finishes counting about where it left off. That sort of thing.)In this case, the current setpoint serves as a steady state (for some duration of "steady") limit, much as a fuse functions. Note that a real fuse requires fault current to open -- a typical one will withstand 50-100% above rated current for quite some time (seconds-hours); their purpose is to clear faults (large sustained surges of many times rated current). We might be serving a similar function in this case, so beware what the regulator or load is capable of surviving. (In this case, the LM317's built in current limit will already serve the below function.)To modify it: we can add a series impedance, or in general, alter the V/I characteristic of the power supply.This is the traditional method, simply using a circuit that provides continuous control over current and voltage. Instead of a comparator, use an op-amp, compensate it for stability, and that's basically it. (Op-amps generally have bidirectional outputs; you'll need a diode on the yellow highlighted line, to mimic the open-collector output of the comparator, so it doesn't push up the VREF side, only pull down.)As mentioned above, the LM317 already does this, with its, whatever it is, 1.5A I think current limit? To make this adjustable, we have much work to do, and we might justifiably ask the question whether it's worth using one at all here; after all the DAC is dominating output voltage accuracy, the '317 is just a voltage follower. It does have a high voltage drop (2V+). It also has thermal protection (which again, makes all of these decisions rather moot, wouldn't you say?), for which without, we'll have to do a bit more work.And, to prohibit it entirely: we can again return to the fuse circuit, but make it very fast so that any current excursion is simply nipped off as it starts.So, to wrap up loose ends -- the other way we can break the loop, is to soften the binary thought process. This way, we're not so much breaking the loop, as refining it to a more subtle condition.Rather than thinking in rigid on/off terms, think in continuous terms, of quantities varying gradually over time.Instead of shutting off the output, what if we just reduce it a little bit at a time? What's more, the amount we reduce it by, can be in proportion to the amount exceeding the threshold. That is, the new output voltage shall be Vset - (Iout - Iset) * gain. "gain" in turn can vary with time, perhaps being small for rapid changes (say, if a step load of 1A occurs, reduce the output by some best-guess amount like 5V or something), but tending towards large values over long periods of time -- this has the effect of integrating the error (Iout - Iset), so that, whatever the output voltage ends up at, we don't really know, but it's simply whatever is necessary to deliver Iset amperes to the load.And this is simply all that a compensated error amplifier does. It approaches the situation cautiously, changing slowly over time.(And no, you can't compensate a comparator; it just oscillates. An op-amp isn't much more than a comparator -- they're very similar devices, it's just that one isn't guaranteed to be stable under any condition at all, whereas the other is guaranteed to be stable under some range of conditions. Often all the way up to having one input tied directly to the output (unity gain stable, voltage follower).)Tim

author: maurosmartins
author_rank: Regular Contributor
timestamp: April 15, 2021, 09:11:46 am
content: Hello T3sl4co1l, thank you for taking the time for such thorough reply,I'll try to break it into pieces:I now see that it is a bad idea as the system will be switching between the two statesQuote from: T3sl4co1l on April 14, 2021, 09:50:30 pmI think the "modify" option is preferred and it relates with the current foldback mechanism some circuits have am I correct?Quote from: T3sl4co1l on April 14, 2021, 09:50:30 pm(image from torexsemi.com)if this is the case can I implement this functionality and if so a few pointers would be nice.Best regards, Mauro.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: April 15, 2021, 04:00:23 pm
content: Yes, in general you can implement almost any V/I profile you like. Flat limit, and foldback (the full diagonal slope one), are most common.Note that aggressive foldback (such that Iset < 0 at Vout = 0) can have a latching behavior as well; this is generally undesirable as it won't start up into a load at all. Best is a compromise between power dissipation (this is ultimately a transistor and heatsink savings measure) and a modest foldback rate (to say 10-50% of nominal current, at Vout = 0). Keep an eye on temperature sensitivity -- the simplest typical implementation just uses a BJT to sense current, the Vbe of which is temperature dependent. This can be compensated with a thermistor and some clever resistor choice; I suggest doing simulations to try it out.Tim

author: maurosmartins
author_rank: Regular Contributor
timestamp: April 22, 2021, 08:43:42 am
content: Hello again,I've found some old HP power supplies schematics here in the forum and I've tried to integrate the ideas in my design." alt="" class="bbc_img" />I have doubts regarding the schematics, for instance what is the function of the capacitor that I'm highlighting in the image below? is the op amp still working as a comparator?Here is my current schematic. I've changed the current comparator to a MCP6001 op amp and used the comparator as a CC indication output. What is your opinion regarding the current limiting now?" alt="" class="bbc_img" />thanks in advanced,Best regards, Mauro.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: April 22, 2021, 10:29:47 am
content: Compensation. Which your MCP6001 will likely need!A series resistor into the - input, and a cap or R+C across the amp, will do.Tim

author: maurosmartins
author_rank: Regular Contributor
timestamp: April 22, 2021, 12:20:36 pm
content: Hi Tim,again thank you for your reply!Quote from: T3sl4co1l on April 22, 2021, 10:29:47 amR+C across output and inverting or non inverting input?Can you point me out any literature regarding this compensation and/or the solution you are proposing.Best regards, Mauro.

author: dietert1
author_rank: Super Contributor
timestamp: April 22, 2021, 01:38:49 pm
content: Please try to find information and understand what is "unity gain stability" with OpAmps. Then you will learn that making a control loop with more than one amplifier requires detailed studies. In your case the current control loop has three amplifiers: The shunt sense amplifier, then the current limit DAC adder, then the voltage control adder. I left out the LM317, it also adds a delay. To calculate the stability of this combo, you need to understand what is a "Bode diagram" and how to characterize the loop experimentally. There is no simple trick that will do.In some power supply schematics i saw a diode pair to make a "wired or" for pass transistor control. Then the current control loop does not mix with the voltage control loop. Also i am wondering about the +15 V supply of the shunt sense amplifier. This works as long as the shunt itself remains below 15 V. If you want to use higher output voltage, you need to supply more than 15 V to the sense amplifier. Some designs have the shunt in the Gnd output line, to eliminate that amplifier from the current control loop.Regards, Dieter

author: maurosmartins
author_rank: Regular Contributor
timestamp: April 22, 2021, 03:08:12 pm
content: Hello Dieter,also thank you for your reply.I'm familiar with Bode Diagrams, phase and gain margin but oddly I don't remember ever using them for such application, I'll search more!Quote from: dietert1 on April 22, 2021, 01:38:49 pmIndeed I've seen the diode pair in many designs in fact the HP schematic I've sent in previous post has it, nevertheless I don't see how it will fit into my design. My idea is that as long as current is below the threshold imposed by the DAC, the output of MCP6001 should be near the positive rail reverse biasing diode D2 as the voltage DAC should always be less. When current exceeds the threshold the output of MCP6001 will start to go down forward biasing D2 and creating a voltage drop at R6 and thus reducing output voltage -> reducing current (and possibly in my case oscillating as crazy).Quote from: dietert1 on April 22, 2021, 01:38:49 pmin my case the "+15V" represents the maximum input voltage so output voltage will always be smaller, the maximum output from my supply should be 12V (4V from the DAC * 3 provided by the LM358 non inverting configuration) and considering 3V voltage drop from the LM317.Best regards, Mauro.

author: dietert1
author_rank: Super Contributor
timestamp: April 22, 2021, 03:44:26 pm
content: "Unity gain stability" is a concept of using opamps without the hassle of detailed stability analysis. But it's basic rule is "One opamp per control loop". You cannot assume that a loop with more than one unity gain stable amplifier will be stable. On the contrary - unless you apply additional "compensation" such a loop will definitely be unstable.You have one opamp for voltage control and it seems to be stable. That means the delay by the LM317 is small enough to let the opamp balance the loop successfully. How can you control current with one amplifier? Put the shunt into the ground line and use the DAC adder opamp to control the current loop. And use a diode pair to avoid feeding the current control signal into the voltage control loop. That may be a path to success without a lot of work.Regards, Dieter

author: xavier60
author_rank: Super Contributor
timestamp: April 22, 2021, 10:22:25 pm
content: The MIC6270 is a comparator. I have come across open collector opamps but I didn't note the part number.