Close

The LM2596 "variable output voltage" challenge

A project log for Low-Cost Programmable Power Supply

Chinese "LM2596 DC/DC buck converter with voltmeter" + "some wires" + "Forth" = "programmable power supply"

thomasThomas 02/03/2017 at 18:028 Comments

Controlling the LM2596 with minimal modification of the DCDC board is the main challenge. The most obvious way to do this is by manipulating the LM2596 feedback input with PC.3. Setting two different voltage levels is simple, and it has already been demonstrated.

The next level is closed loop control of the output voltage within a certain range.

The adjustable variant of the LM2596 (the one used in cheap boards) compares the feedback signal with a fixed reference voltage of about 1.23V (1.18V to 1.28V through the temperature range) using a fixed voltage divider, and sets the converter duty cycle accordingly

Variable controlling of the output voltage requires the following elements:

A) Reading the output voltage can be done by either 1) reading the output voltage, by 2) reading the feedback voltage, or 3) with a combination of the two.

B) Controlling the output voltage with the STM8 can be done by 1) setting the feedback voltage, by 2) changing the feedback ratio, or 3) with a combination of the two.

The B3603 (refer to HaD Power Supply B3603 Alternative Firmware) uses method A1-B1.

I want to try A2-B2, A3-B2, or even A3-B3.

Here is how:

Synchronization and control is possible with the help of Timer1:

Open questions are:

  1. whether the LM2596 remains stable with such a kind of "bending"
  2. how can TIM1 be synchronized with the LM2596 oscillator without using an additional GPIO

Suggestions, or feedback, are welcome!

Discussions

Thomas wrote 02/03/2017 at 20:51 point

Hi K.C.! 

I had planned to synchronize TIM1 with the LM2596 oscillator PLL style, but I don't know yet if I can create a sufficient PLL sync using the ADC (this depends on the choice of signal processing, I guess :-))

Variant B3 basically injects a DC offset but the "PLL" synchronization is a necessary prerequisite.

Edit: removing the LED display is an option. That would free up GPIOs for building an 8bitish R-2R "feedback DAC".

  Are you sure? yes | no

K.C. Lee wrote 02/03/2017 at 21:06 point

LM2596 block diagram

Think of the feedback amplifier (GM) as a summing amplifier.  V1 is connected to your output.  You should be able to inject a DC offset on V2 to shift that output up or down.  (You don't get to play with RF, but there is some fixed gain.)

That DC offset can be coming from my 1 GPIO + opamp sigma delta DAC built with opamp integrator. 

  Are you sure? yes | no

Thomas wrote 02/03/2017 at 21:29 point

Yes, that's an option! 

However, I have a gut feeling that the problem would be the digital control feedback loop. I'll have to figure out the value of C5 in the output voltage measurement (A1).

The alternative, reading the output voltage through the feedback loop (A2), only works if the GPIO switches from "low side output" to "analog input" at the right time in the LM2596 oscillator cycle.

  Are you sure? yes | no

K.C. Lee wrote 02/03/2017 at 21:36 point

Same as my power supply, I would only care about the low pass DC output for trimming up/down the output.  The firmware PID loop figures out the trimming by monitoring the output.  I used a 30Hz update loop I think.

I would let the chip handle the more exciting AC transient response. i.e. a few Hz up to may be a fraction of the switching frequency (usually 1/6 to 1/10).

  Are you sure? yes | no

Thomas wrote 02/04/2017 at 07:14 point

On a second thought: 

LM2596 doesn't have RF, and I have difficulties understanding GM (which is used without feedback and drives an "active capacitor" - this looks to me like a fixed amplification low-pass-filter). On the plus side: In the adjustable variant, R1 and R2 are also missing. Currently I don't see how turning GM into a summing amplifier can work. Of course, using an external summing amplifier is possible.

  Are you sure? yes | no

K.C. Lee wrote 02/04/2017 at 12:05 point

GM is a fix gain amplifier.  You can think of it having its RF connected internally. The adjustable version of the chip have the inverting input directly to the FEEDBACK pin where you normally connect a voltage divider.  

So you already have R1 connected to the output.  Now normally the lower side of the voltage divider which is V2 is connected to GND.  If you now connect that branch to a DC offset, you can level shift the feedback node.  This converts the feedback circuit similar to the summing amplifier form.  

Alternatively you can work out the voltage at the feedback pin as a voltage divider with the ground side connected to a floating DC offset using simple algebra.  

I have done that to level shift a +/- 3.3V signal to a 0-3.3V shown below for ADC front end.  As long as the voltage you are level shifting is larger than the desired output and have the same polarity, a passive network can work.  Most would have missed that and wasted an opamp and ended up with an inverted signal that they have to be converted back in firmware.

In you case, the divider ratio is not 1:1.  A PID loop can iterate and inject the need offset value when you close the loop using the output voltage.

  Are you sure? yes | no

Thomas wrote 02/04/2017 at 13:38 point

Cool, that's good to know. Most likely applying a DC offset the way you pointed out is the the most viable option (and it's simple, too).

  Are you sure? yes | no

K.C. Lee wrote 02/03/2017 at 20:21 point

You won't be able to synchronize to the switcher without using a GPIO line.  Not unless the part can oversample and process data.

>24.2       ADC main features

      External trigger option using external interrupt (ADC_ETR) or timer trigger (TRGO)

Pin 12 can be set as ADC_ETR

-------------------------------------------------------

If you are willing to throw in extra hardware, a $0.77 I2C 4 digits LED display can free up lots of I/O.

https://www.aliexpress.com/item/4-digital-display-with-adjustable-brightness-LED-module-clock-Point-Accessories-Blocks-for-arduino/32216576572.html

For adjusting the output, you can try to inject a DC offset into the feedback node similar to my 1k power supply project.

  Are you sure? yes | no