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 output
And... 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 disabled
and 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 from
anything, 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