MicroController control for switching regulator

I'm wanting to use a microcontroller to control the output of a switching regulator, maybe something like a LM2576 simple switcher. I see the adjustability is on the feedback lead but what's the best way make it adjustable from a microcontroller. I'm guessing the feedback may be used in switching timing, ie, I guess I can't just use a DAC and get an output of

1.23V more than the DAC output? I want to monitor voltage and current and use a control algorithm in the microcontroller (Arduino at first for experimentation) for custom battery charging experimentation.

RogerN

Reply to
RogerN
Loading thread data ...

What did Jan Pabntelje's uC switcher do? I remember it but not the details.

Reply to
Dennis

Power supply design is an art. First, you have to decide EXACTLY what you want. Not, kinda-sorta, EXACTLY. The electrons have no concept of battery charger. All they know is voltage and current and fault conditions and how to explode stuff. The devil is in the details. The rest is 99% boiler plate copy the datasheet example and 1% "why did the board catch fire?" And fixing that

1% takes 500% of the time you planned to spend on it, and smokes more devices than you ordered.

I'll rattle off the top few things I can remember on short notice.

Safety first. Wear those safety glasses. Somewhere in Wilsonville, Oregon, there's a ceiling containing many chunks of epoxy and silicon from switching power supplies I exploded during evaluation. I also expect the floor still smells like pee.

1.23V is a seriously inconvenient minimum voltage for a general purpose supply. The LM2576 appears to have no capability for programmable current limit. How you implement that will have a major impact on your topology. What transient response do you expect for current transients or going in and out of current limit? And what do you want to happen when the internal safety limit interacts with your external limit?

The datasheet gives you clear instructions on component selection given a fixed in/out voltage and current. Extrapolating to a wide range supply is not so simple. The Onsemi datasheet mentions core saturation, but not in a way that emphasizes its importance...AKA 1% Exactly where you connect the wires is CRITICAL. They drew the circuits funny with all the connections to a single ground node for a reason. And many of the other connections can be just as critical...I can tell you stories...

If your battery charging experiments are limited to charging one technology and voltage, your requirements just got simpler... And more complicated. Using the example circuits, it's easy to come up with a design that goes up in smoke if you connect the battery before the input power. If the supply doesn't explode, the battery might.

A lot depends on exactly what you're trying to accomplish. I wouldn't attempt to build any power supply without access to an oscilloscope, but that's just me. I've redesigned many a power supply designed by engineers who didn't take the project seriously. That 1% can look mighty big when you're surrounded by smoke and flying debris...and you smell like pee.

If you want to build a power supply, go for it. If you want to experiment with batteries, buy a power supply. When your power supply fails shorted and the battery explodes, things get ugly. YMMV

Reply to
mike

Overkill.

Reply to
MrTallyman

Pabulum Boy!

The new Super Non-Hero!

Reply to
MrTallyman

Use a fast microcontroller (IOW: ARM) and use the PWM + ADC from the controller to do what you want.

--
Failure does not prove something is impossible, failure simply 
indicates you are not using the right tools... 
 Click to see the full signature
Reply to
Nico Coesel

The ADC in the Arduino is not too flash, as in not being stable. You will see the value "jitter" up and down. Previous advice about using purpose designed devices would seem a better idea to me :-)

Cheers .......... Rheilly P

Reply to
Rheilly Phoull

Use this pair and make your own switcher and controller.

UC1526J & UC1832J That, with a couple op amps and you can make it a voltage and current controlled and monitored supply. Drive a pair of FETs or the like into your transformer, and then rectify or multiply and store for the final voltage. on the output. Shunt and tap that node for the feedback, monitoring and control. Voila!

Reply to
SoothSayer

On a sunny day (Tue, 25 Dec 2012 20:46:09 +0800) it happened Dennis wrote in :

It is my lab suply, on 12 hours a day: http://

formatting link

I dunno about arduino, but I use a Microchip PIC PWM output, and monitor current in real time (with an internal PIC comparator), called cycle by cycle current limiting. The real time thing avoids the need for a specialized chip. Can arduino do that? Looks like overkill to me even if it can.

The LM2576 could be controlled by a multiplying DAC over some range, seems a bit dangerous...

(reference DAC on output, output DAC on feedback of LM2576). Output voltage limited to whatever the DAC can stand, add resistor divider for more, could even work, but DAC to zero would create zero feedback and push the output way up and saturate that inductor I am sure.

------- R -------- Vout |

8 bit control --> DAC ----> pin 4 feedback LM2576 form arduino? | ///

And you cannot go to zero that way.

Reply to
Jan Panteltje

Cheers TallyWhacker - I'm just in the process or rebuilding my filters..........

Reply to
Dennis

Generate control DC voltage by microcontroller PWM. Add this voltage to the feedback input of the switcher. Thus higher PWM voltage results in proportionally lower switcher output. Two resistors, capacitor and little math is all it takes. Done that many times. Works very well.

Vladimir Vassilevsky DSP and Mixed Signal Consultant

formatting link

Reply to
Vladimir Vassilevsky

switching

used

output

current

for

You might want to look at Microchip's new line of PICs with on-board switchmode controllers:

formatting link

They are only about $2, and include other advanced peripherals:

formatting link

For a battery charger, you may do better with one of the dedicated battery management ICs, especially if you are using LiFePO4 or NiMH or other more critical chemistry:

formatting link
T1511&x=16&y=14
formatting link

23PBF-ND/2334070
formatting link
4787
formatting link

Paul

Reply to
P E Schoen

On a sunny day (Tue, 25 Dec 2012 09:29:20 -0600) it happened "Vladimir Vassilevsky" wrote in :

Right, way to go! That is what I did here:

formatting link

Reply to
Jan Panteltje

Software lowpass filter the ADC samples. You'd want to do that even if the ADC was perfect. Any signal near a power switcher is going to be noisy.

The most elegant way to do this job is to use the uP PWM to drive the switcher stage, and use the ADC to measure input voltage, output voltage, and current.

Or, the OP could use a DAC (or a PWM made into a DAC) to push the feedback node of the Simple Switcher.

Reply to
John Larkin

There are battery charger chips designed for universal applications, i.e. chemistry independent. I would go that route.

When it comes to safety, the verbiage is often repeated in the datasheet just in the event somebody doesn't read the whole thing. Sometimes repeated three times.

Reply to
miso

Got any tips on how to do this? At 20 kHz. you have 50microseconds to do two measurements, update the displays, and decide whether and how to tweak the PWM.

Even if you dedicate the whole processor to the task, you still gotta get data in and out. A 50 millisecond key debounce timer is an eternity when the output is shorted. So you make everything interrupt driven...and it gets messy.

For a 20kHz. PWM frequency, can you really get enough resolution? Or do you dither the clock and the duty factor or????

Got some sage advice on the tricks of the trade?

Reply to
mike

You don't need to do the measurement at the same rate as the PWM PRF. Even if you did, a low end PIC can cope easily.

Actually it gets remarkably elegant using interrupts. YMMV I guess. High priority interrupts A to D that controls the PWM driving the switching FET and low priority interrupts for the keyboard, serial port or whatever.

I've used a bit higher, 28Khz or so. Depending what you want (battery charger?)

6+ bits is fine - it will dither due to the measurement on the A to D correcting it.
Reply to
Rocky

you did, a low end PIC can cope easily.

FET and low priority interrupts for the keyboard, serial port or whatever.

charger?) 6+ bits is fine -

it will dither due to the measurement on the A to D correcting it.

Ok, if you're gonna tolerate the noise of a cycle/cycle regulator, I guess 2% resolution is fine. I don't have a problem with dither as long as it's filtered and doesn't show up in the output. I've never tried to use a switcher as a bench supply. I think I'd want to start with a high-res PWM and cycle skip to handle load dumps.

Reply to
mike

in

The easy way is exponential smoothing, the equivalent of a 1st order RC lowpass filter.

Filt_Val = Filt_Val + (ADC_Val - Filt_Val) / K

where, if you work in intgers, you can do the divide-by-K as a right shift.

Filt_Val = Filt_Val + ( (ADC_Val - Filt_Val) >> N )

It's all signed. N might be, say, 16 or 256 or something.

The data has to be aligned such that you don't roll bits off the end when you do the right shift. Using a 32-bit Filt_Val simplifies life; the ADC sample should be up-shifted maybe 16 bits before the math is done.

If you do this in floats, it's simpler but slower; don't worry about alignment at all.

Filt_Val = Filt_Val + J * (ADC_Val - Filt_Val)

since multiplies are faster than divs. J = 0.01 would give the filter a time constant 100x the sample rate.

If you do all the math as ints, that should be possible. We've done more complex stuff, filtering and PID control and error checks at 100 KHz on a cheap ARM.

If you don't have a real DAC, run the PWM as fast as it will go. That's not the same rate at which you might run the filtering and control algorithm.

One trick is to filter the ADC data twice; a fast filter for the control path and a slow one for display cosmetics. If you filter too much in the control path, the loop can go unstable. A P+I controller with low P may not need filtering at all.

Reply to
John Larkin

Thanks for the replies.

So around 30 years ago in school we made an oscillator using an Op Amp, IIRC, this was a comparator circuit with hysteresis and the output caused a capacitor to charge/discharge. What if the same type of circuit was used in a buck regulator so when the voltage reached a certain level, the output would go low, when the output dropped below a lower level, the output would go back high? Then an analog output could determine the comparator voltage. That may not be perfect SMPS design but I would think it would be good enough to charge batteries, probably need to switch off to take measurements or at least filter the measurement.

RogerN

Reply to
RogerN

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.