Microcontroller Switchmode Control

twenglish1

New member
Has anyone here ever gone the route of using a microcontroller to generate the pwm signal/signals required to drive a switchmode powersupply? I have always been into coding for microcontrollers, and thought about trying to drive an inverter with code and using the micro to handle the voltage/current sensing
 

KX36

New member
I assume you mean for a regulated power supply since there's no point in using something smart if it's generating a fixed PWM signal. A well designed digital PID controller has the potential to perform very well, but to do it right you really need to know what you're doing and be very confident in closing the control loop with stability in the analog domain first. Most switching power supplies need some form of loop compensation. People seem not to realise this doesn't change just because part of the loop is in the digital domain, a lot of people seem to think just having a microcontroller's ADC then some simple negative feedback code to output PWM will be OK. Simply putting in an opamp into the loop with no local feedback for compensation and hoping for it to sort everything out won't work and that's the digital equivalent.

You need a fast ADC and microcontroller or DSP chip. It's more of a DSP thing than a standard microcontroller thing but I'm sure it can be done in a micro. Even if you manage all that, there are still drawbacks to digital control. This image shows a digital and analog equivalent circuit in their step response. You can see quantisation error in the red digital model


SIMPLIS System Designer looks like a pretty good tool for designing digital control loops. I got a quote for it around the £7,000-10,000 mark. If it was easy to do right with an arduino, people wouldn't pay that.

Of course if you want to do it badly, that can be done quite easily. There's a video of a chinese eBay "digitally controlled boost converter" on Julian Illett's youtube channel. It takes about 30 seconds for the output voltage to creep up. For comparison most of my analog control loops reach steady state in around 1-3ms. Giving it such a poor response was likely the only way the designer could stabilise it.
 
Last edited:

demykiko

Member
because we have the same thought of using microcontroller as the main ic for smps, i believe it's possible.
I'm planning to use AVR attiny45/85 to control the operation of simple medium power smps..and I'm still on my research
because pwm is not that easy to code espescially I'm just a newbie to MCU.
 

demykiko

Member
It's not bad to explore on things other than the usual or dedicated controller ones as long as it gives merit and enjoyment to anyone..
No one knows one day there is one who can make it with a MCU...
I already made a microcontroller to output 32kHz with variable duty cycle in a totem pole configuration..but I there is a need to test it first if
the inverting mode and non-inverting mode PWM signal can switch the LO-HI driver IC properly..
 

KX36

New member
(Appologies for posting without having watched your video - I'm at work) The challenge is not in making a MCU generate a PWM, they have dedictated PWM outputs for one thing. That's only the first step of a marathon, I could do that on my arduino in 10 minutes. The challenge is in closing a control loop to make the MCU output the appropriate duty cycle every cycle to get a regulated output as good as an analog control loop would do.

I wish you the best of luck.
 
Last edited:

demykiko

Member
Thanks KX36 for your good opinion and wish..I agree with you that the big challenge is in making a good control loop with MCU to make a regulated output
but still the challenge depends on what purpose we design our smps to function for..I mean if what I want to achieve is only to make my smps to have variable output voltage and at least with short circuit protection maybe I don't need a control loop anymore for regulation..since the output can be adjusted gradually and manually to make it suitably right for a circuit to which it is connected...But incorporating a successful control loop to it, is really another very great challenge in my opinion and I believe it's possible...
 

KX36

New member
OK, if you don't want a regulated output but simply a digital interface for adjusting a PWM, that should be easily accomplished, in fact it sounds like you've already done it although I still haven't got around to watching your video. If you've got a good waveform out of it, the next step would be to build up a power stage and use the PWM to drive the switch. I'd probably start with a relatively cheap and easy low power dc-dc converter, maybe a boost since it's low-side drive on the FET and you don't have to worry about the boost's RHP zero if you're not regulating. If you've got a long wire from your MCU prototype board to your power stage, put a local driver near the FET, e.g. NPN-PNP totem pole.

If you do want to move on to high power mains isolated supplies, you'd have to consider whether the MCU will be on the primary or secondary and how you interface with it as the main switch will always be on the primary and the user interface will always be on the secondary and the MCU in the middle. Fortunately, getting a digital signal across the isolation boundary is supposed to be a lot easier than analog although it depends on the frequencies involved.
 
Last edited:

demykiko

Member
Thanks for that great advises KX36..that's why I believe you can be my good friend in this forum..I just want to share the latest outcome of my experiment and if you have time again your comments are always welcome..I used IR2113 lo-hi side mosfet driver it's same as the popular IR2110..the signals were clean as shown on my scope and the pulse's adjustment from both output of IR2113 from minimum to almost 50% were both ok..so it means that my MCU can give a good signal drive to the inputs of IR2113 which is supplied with 5v to make it compatible with MCU as a source of logic pulse drive PWM signal (32kHz)..It was just the situation when the half bridge mosfets were not yet given a supply i.e.. the voltages from two filter electrolytic caps...But my sad story began after I connected the supply to two mosfets..the signal drive of MCU immediately died down and so the IR2113 also...I still don't know why it is like that..maybe there is something which must be done to make it work fine..I think it's some good interface like what you mentioned above..I hope you can understand my explanation..

Regards,
demykiko
 

demykiko

Member
Finally my idea of using MCU to control the operation of SMPS became possible..even the prototype in the video is just a small power one, and yet
the possibility to make it achievable with high power one is just a matter of perseverance...At least in the video what I had in mind became real..

Please see this video..as a proof..thanks

http://youtu.be/fX-r4f7pJvU
 
Last edited:

KX36

New member
Hi demykiko. I've watched your videos. It looks like a good demonstration of the difference between posting an unloaded square wave as in the first video and one with a large capacitive load (the FET or IGBT's input capacitance) as in the second. Often people post pictures of nice clean gate drive waveforms that aren't actually connected to a gate or the drain of the FET isn't connected to a power rail or there's no load on the output and you can be left wondering why yours don't look like that.

In the first video you can see some overshoot, but before reading anything into that I'd check your scope probes are compensated correctly. In the second video, you can see the rising edge of the waveform rounds off and there are miller plateaus at turn on and turn off where the gate capacitances are charging/discharging and so the voltage briefly stops changing on the way up/down. I might expect a cleaner waveform from the IR2113 if a different switch device was used with a lower input capacitance. e.g. for a lower power SMPS you'd use FETs with perhaps a higher Rds(on) but a lower Qg and therefore lower input capacitance, it's all a trade off between switching and conduction losses. Here's a good page for an explanation of that: http://www.richieburnett.co.uk/temp/gdt/gdt2.html

I didn't really understand what you meant in your second from last post, but it sounds like you've gotten past it.

May I ask what topology are you using for this power supply and what the switching device is?
 

demykiko

Member
Hi KX36,

Thanks for the sharing of the link but I will go to that later I' m just still busy with my work..Yes! we actually have the same observation on the shape of the waveform..I'm really wondering what to do to have a cleaner waveshape despite I already followed the component's values prior to driving FET or IGBT from the work of our fellow members here in this forum..I think you have a point in saying that the cause may come from the higher capacitance of gate..But I already anticipated that that's why I used a high speed optocoupler IGBT driver to compensate that high capacitance because the opto is capable of giving an output dirve of 2amps..But still the wave shape is not really perfect...I also lowered the Resistor between gate and source to make the discharge very fast..also the series Resistor or Rg I made it lower to only 5 ohms..and yet the waveform looked as you described it above..By the way I used IGBT here in my second video
and optocoupler IGBT/FET driver as interface between MCU and IGBT...my topology is Forward or Flyback if I'm not mistaken..because I used only one IGBT...Just only for the purpose of testing..
 

demykiko

Member
Hi KX36,

Thanks for the sharing of the link but I will go to that later I' m just still busy with my work..Yes! we actually have the same observation on the shape of the waveform..I'm really wondering what to do to have a cleaner waveshape despite I already followed the component's values prior to driving FET or IGBT from the work of our fellow members here in this forum..I think you have a point in saying that the cause may come from the higher capacitance of gate..But I already anticipated that that's why I used a high speed optocoupler IGBT driver to compensate that high capacitance because the opto is capable of giving an output dirve of 2amps..But still the wave shape is not really perfect...I also lowered the Resistor between gate and source to make the discharge very fast..also the series Resistor or Rg I made it lower to only 5 ohms..and yet the waveform looked as you described it above..By the way I used IGBT here in my second video
and optocoupler IGBT/FET driver as interface between MCU and IGBT...my topology is Forward or Flyback if I'm not mistaken..because I used only one IGBT...Just only for the purpose of testing..
 

demykiko

Member
The link is very informative..I can easily relate to it because I already experienced observing some of them from my previous experiments..
The article is specifically written for half bridge topology, although it can be used as a basis or reference for other topology in my opinion.
One big challenge for us is how to find ways to eliminate or reduce the Miller effect..And as far as I know that battle is just a matter of
making proper selection of components' values..
 

demykiko

Member
The circuit looks good but I observed it's only a representative diagram..if it will be given time for studying the concept can be made using different devices like microcontroller the constructor is already familiar with..
 

nsvinc

New member
KX36 is absolutely right about troubles with digital control loops. But it is not as hard as it seems. He didn't mention that RHP zeroes are occuring only in CCM modes (in boost derived topologies).
Control loops for non isolated converters operating in DCM are relatively easy to manage, despite the fact, that their transfer functions are highly non-linear. I mean of course a sub-optimal, but reasonably working solution, not a super fast high performance control loop - this would require not only strictly digital implementation, but also other algorithms than a simple PID; probably SMC, and some fuzzy logic would be useful.

RHP zeroes occur also in current mode control only (and much more 'troubles' like subharmonic oscillations). Simple voltage mode control (slightly overcompensated) will work quite well for virtually any converter topology. This also applies for digital domain controllers - fairly good tuned PID will do the work. Do not expect outstanding performance from such solution, but a power supply designed like this will be usable; it will be far better than a few seconds of settling time (usually around tens of ms).

The fact is, that any CMC for CCM modes are rather difficult to implement in the digital domain. I have to admit that KX36 is right about this sort of controllers, and if you don't know exactly what you're doing - don't do it...
 
Top