 ### Network # Making a variable power supply variable... (what?)

#### (*steve*)

##### ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,505
OK, weird title.

What I want to do is to make a variable power supply controllable by a microcontroller. This is a switching (DC-DC) power supply, and the generic circuit is as follows: See the datasheet here. The Adj pin feeds into a comparator which compares the voltage on this pin to an internal 1.25V reference. The traditional method of making this supply variable is to change R1 into a variable resistor.

And while I imagine I could use a chip which generates a variable resistance in place of R1, the output voltage could never be reduced below the reference voltage of 1.25V.

So... My idea is to use a D2A to generate a voltage which is added to the voltage at the junction of R1 and R2. As the added voltage increases, the required voltage across R2 will fall. This will enable the output voltage to be varied all the way down to zero.

Here's my idea: For simplicity I'm not showing any absolute values.
• The voltage divider R1/R2 is in a ratio to give a normal output voltage 10x the reference voltage (or 12.5V in this case)
• The voltage divider R3/R4 has equal value resistors giving a 2.5V split supply to the op-amps (which happen to operate from 5V (not shown))
• R5=R6=R7=R8=R9 so that the gain is 1
If we assume that the output voltage of the D2A is 2.5V and the output of the R1/R2 divider is 1.25V, we also want 1.25V to appear at the ADJ pin.

Summing amplifiers are inverting, so the output of the first op-amp (U3) is 3.75V (1.25V is 1.25V lower than 2.5V (the reference) so the output is 1.25V higher than the reference. The input to the other summing input is the same as the reference voltage, so it has no effect on the output.

With an input voltage of 3.75V into the second op-amp (U2), the output is 1.25V.

When the output is regulated, the output of U2 will always be 1.25V, therefore the output of U3 will always be 3.75V.

This means that the input voltages must always sum to 3.75V.

So, for the ratios shown, if I call the voltage from the voltage divider d, and the voltage from the D2A a, the output equations are:

V = 10d, and 1.25 = (d + a) - 2.5

so, d = 3.75 - a, and by substitution V = 37.5 - 10a, or a = (37.5 - V) / 10

If I want the output to vary from 0 to 12V, then the default voltage must be 6V, and the gain from the D2A changed (by altering R8) so that a change in a of 2.5V results in the same change in output as a change of d of 1.25V. Simply stated, that means R8 needs to be 2xR9.

Thus, with R1 = 3.8xR2, and R8 = 2xR9, the equations become:

V = 4.8d, 1.25 = d + (a - 2.5)/2

so d = 2.5 - a/2, and by substitution V = 12 - 2.4a

If a has a range of 0 to 5V the output can vary from 12V to 0V. In my case the D2A is 12bit, so I can do this in steps of about 3mV.

So... 2 questions:
1. Do you think the circuit is viable?
2. Is my math right?
Why do I want to do this do you ask? I'm creating a circuit to control the speed of a brushless DC motor (BLDC) from very low speeds (say 30rpm) up to around 4000rpm. At very low speeds, PWM is used to create a very low frequency AC signal to apply to each of the windings. At these very low frequencies the current can be huge, so I will be altering the voltage as a function of RPM. The motor is essentially unloaded (it turns what amounts to a small flywheel) so to maintain a relatively constant torque, the voltage will need to vary quite widely.

And why do I want to do that? It's for an optical chopper to go with my lock-in amplifiers.

#### kellys_eye

Jun 25, 2010
5,688
Can't you use a small negative voltage rail to pull the bottom of R2 to a value below zero?

#### WHONOES

May 20, 2017
1,216
I think your circuit is unnecessarily complicated.
All you need to do is to throw away resistors R1 and R2 and put in their place a single rail to rail opamp (like my favourite the CA3140) and connect the - input to the output of your regulator via a 1KΩ resistor and the + input to your A2D output the, connect the O/P of the opamp to the ADJ pin of U1. A small compensating capacitor between - input and opamp O/P should be included.
An opamp will always try to make its input pins agree with each other and will set its output to whatever value is required to do so.

Moderator
Jan 21, 2010
25,505

#### WHONOES

May 20, 2017
1,216
I have use a similar circuit before and it worked fine. You just need the compensating capacitor to keep it all stable. I seem to remember (from about 10 years ago) the cap was about 100nF. It was on a battery charger for a small piece of medical equipment. And have use similar in a high current buck converter designed around the 555 and outputted about 20A at 0.8 to 1.2V for running multiple model engine glow plugs.

#### (*steve*)

##### ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,505
For some amusement I reverse engineered the buck regulator I purchased from eBay.

It looks like this: It cost me about \$8 and claims to be 10A rated. The chip itself is rated for 8A, so that's a bit ambitious. I only expect a couple of amps, so it should be fine.

And the schematic looks like this: Many of the resistor values were read in-circuit, and I have not bothered to remove the ceramic caps to measure them.

#### (*steve*)

##### ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,505
Just in case you're wondering how the circuit is reverse engineered...

I used a magnifying headset, a multimeter, some datasheets, and good old pencil and paper to mark out all the components and the connections between them.

With all of those I end up with something like this: And from that, drawing the circuit is just a matter of arranging things sensibly.

Obviously that's not the whole circuit, and you can see I was still puzzled as to where some of the connections went. But after drawing the part I had figured out, it became fairly clear what the other part was doing and then it was simply a case of tracing some tracks that were hidden under components on the other side (with the multimeter and a better understanding of what I was expecting).

#### WHONOES

May 20, 2017
1,216
So I guess you'd recommend this:

View attachment 42238
Should I add some resistance between the d2a and the op-amp? If so, what sort of relationship should there be between the RC time constant and the switch

First of all, you don't need R2 in your circuit. Yes you should put a resistor between the O/P of U4 and the - input of U2. The actual value depends on the transient response i.e. its response to a step change in load or output voltage of U1. I would suggest a starting point of 100KΩ and 100nF but you will probably need to experiment a little.

Just for interest, I have attached the schematic for my Gloplug Buck Converter. A plot of the output and reference voltage is also included. It runs at about 39KHz.[/QUOTE]

#### Attachments

• Gloplug buck converter.pdf
15.8 KB · Views: 24
• Gloplug Buck Converter Graph.pdf
42 KB · Views: 25
Last edited by a moderator:

#### (*steve*)

##### ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,505
First of all, you don't need R2 in your circuit

The maximum output of the dac is less than the maximum output voltage I want.

#### WHONOES

May 20, 2017
1,216
OK. I didn't realise that. The preferred option would be to put a gain stage between the DAC and the - I/P of U2. Or leave your circuit as drawn. I'd try both and see which works best.

#### (*steve*)

##### ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,505
The next interesting question is the method of driving the BLDC. In this application I have the unusual requirement that the voltage to the motor may be less than the minimum voltage to the chip logic.

I can't do this with PWM (which would be my normal option) because I will be using PWM to create low frequency sine waves for the windings and if I was to attempt to use PWM to do both, I would rapidly run out of resolution.

My original choice of chipset was the L6234. However, this has a single supply which can't go below 5V or so. I'm now looking at the DRV8332. This latter chip has separate Vss for the logic and the half bridges.

The interesting factor is that my power supply for the motor (the one I am discussing earlier in this thread) has a sense resistor in the ground lead. This may cause some issues.

As I see it, I could:
1. defeat the current sense on the power supply by shorting out the sense resistor and live with no current limit.
2. modify the sensing to be in the +ve output
3. use the ground after the current sense as the ground for all of my power supplies.
I think 3 may introduce a little noise, but it seems the simplest.

The 4th option might be to simply ignore the difference and let some current pass through the 1Ω resistor bridging the AGND and the GND, however I'm a little concerned because the sense resistor in the power supply is of a similar magnitude to the sense resistors used (when used) for the DRV8332 itself.

This may require some experimentation.

P
Replies
1
Views
938
J.A. Legris
J
Replies
2
Views
60
Replies
1
Views
79
Replies
3
Views
360
Replies
9
Views
727