Hi Mike
Try this
Code here:
clicky!What you have here isn't really "ripple" and "noise" in the traditional sense. What's happened with your power supply is that the control loop is unstable and has gone into oscillation.
Control theory is full of hideous maths and obscure terminology, and if you ever find a really good, clear way to explain poles, zeroes, gain and phase margins, then do please let me know.
The nice thing is that often, in practice, you can get good results with trial and error - provided you have accurate models of your components, and you understand what it is that you're trying to achieve.
The one thing which I find de-stabilises a control loop more easily than anything else is delay. If the controller, which in this case is the op-amp driving the big transistor, is too slow to respond to an error signal (in this case, the difference between the output voltage and the required set point), then the output of the system has time to overshoot. The controller sees the overshoot but then over-compensates, and the error goes negative. The system oscillates.
There are two approaches to sorting this. One is to reduce the delay around the loop, ie. ensure that the controller can respond quickly enough to an error in order to correct it before it overshoots. The other is to reduce the bandwidth of the controller, so the loop gain is less than 1 at the frequency at which it would tend to oscillate.
With that in mind, I've made some changes to your circuit:
a) I've removed your R-C filters. They add delay, so they'll only ever make it worse. (That said, a very small C near an op-amp input can remove very high frequency noise which would otherwise make the circuit misbehave, but this is addressing a completely different problem. Such a filter should have a cut-off frequency that's much higher than the frequencies the circuit is normally intended to handle).
b) I've added a potential divider between the output voltage and the voltage control op-amp. This allows a capacitor to be fitted across the top resistor (R1), which increases the gain of the controller at ac, ie. speeds up its response to voltage errors at the output. In this particular circuit C2 isn't actually needed, but I'd definitely leave a site for it on your board when you make a real prototype.
c) I didn't have your transistor in my LTSpice installation, so I've picked a couple of others which seem appropriate. You definitely need a fast enough power transistor to keep the control loop from oscillating. If your transistor is too slow, a capacitor from the output of U1 to its -ve input will decrease the bandwidth of the controller and make it more tolerant of delay in the loop - though doing this will affect the transient response of your power supply.
d) to speed up the current limit circuit I've swapped the inputs to the op-amp, and replaced the output transistor with a diode. This eliminates the delay due to the output transistor on U6. I've also added a capacitor between the output of U6 and its -ve input; this decreases the bandwidth of U6 and prevents it from oscillating when the supply is in CC mode.
With my changes applied, the circuit is unconditionally stable
But it's not without issues...
- Most importantly, the power transistor is going to get *very* hot. Hold <ALT> and click a component in LTSpice to plot its power dissipation.
- Output voltage is limited by the voltage from which you power the op-amps.
- I've not checked the transient response. Have a play and see what happens when the load changes suddenly. You'll certainly get a pulse of output current somewhat greater than the set limit when the circuit switches from CV to CC mode, because of the output capacitor if nothing else. I'd suggest keeping C4 fairly small, and putting the bulk of your smoothing capacitance on the 40V rail for this reason. (Lots of capacitance is the last thing you ever want on a constant current supply).
Your biggest problem will be heat in the power transistor. Draw any significant current from this supply and it's likely to burn out. My bench supply is an HP 6632B, which does 0-20V @ 5A - it's fan cooled and all the transformers and heat sinks inside mean it weighs as much as I do.
Many bench supplies overcome this problem by having a first stage PSU which can switch between different voltages depending on what output is actually required. For example, they may have a transformer with multiple windings that can deliver 10V, 20V, 30V and 40V depending on how many are actually connected. A separate control circuit monitors the required output voltage and switches in the correct combination of secondary windings so as to keep the voltage across the power transistor within sensible limits.
So, for example: if you set the PSU at 6V, the relay controller will select just the first secondary winding on the transformer, so the regulator is powered from 10V and the power transistor drops just 4V. If you then wind the voltage up to 17V, the relay controller switches in another transformer winding so now the circuit is powered from 20V, and the power transistor drops only 3V. Although rather crude, this form of pre-selection makes a huge difference to the amount of wasted power.
You can make a pre-selector to do this job with a few comparators and a bunch of relays - you just need a mains transformer with multiple secondary windings. Needless to say, be careful around the mains. By all means chicken out and use a big heat sink and fan instead, and save the clever stuff for the mk II.