• AVR Freaks

a detailed guide to building your own DC/DC converter using a little PIC, by Olin Lathrop

Author
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
2009/10/03 03:08:13 (permalink)
0

a detailed guide to building your own DC/DC converter using a little PIC, by Olin Lathrop

[...]
The guiding equation for inductive switching power supply is:


Volt Sec
Amps = --------
Henries

In other words, if you know any three of applied voltage to a inductor, the length of time that voltage is applied, the inductance, and the resulting change in inductor current, you can find the fourth.

For a micro to control a switching power supply directly from firmware, we want switching edges to be a few uS apart. Just to see where we're at, let's see what size inductor would charge up to 1/4 amp from 3V in 10uS:


Volt Sec 3V 10uS
Henries = -------- = ------- = 120uH
Amps 250mA

OK, that's not way out of line so a 100uH inductor should be quite usable.
That's a common value and finding one with at least 500mA saturation current will be no problem. So now that we've tentatively decided on 100uH 500mA inductor, let's see what the longest guaranteed not to saturate switch on time is. Obviously, this needs to be computed at the maximum input voltage, which you said previous was 4.2V:


Amp Henries 500mA 100uH
Sec = ----------- = ----------- = 11.9uS
Volts 4.2V

So this tells us that as long as the firmware never leaves the switch on for more than 11uS, and the inductor current starts out at zero, we are safe and the inductor won't saturate. Let's say the controller is a 10F204 where each instruction cycle is 1us, so that would be 11 instruction cycles.
That's actually a fairly long time, but then again that is the max
saturation limit. Nothing says we have to charge up the inductor to 500mA each pulse, and there are some reasons not to.

We'll likely use a NPN switch, since FETs that can handle 70V aren't going to switch well with only 3V on the base. The downside of a bipolar is you have to keep feeding it enough base current to stay in saturation. Let's say you can get a NPN that can withstand the voltage with a guaranteed gain of at least 40 (I haven't checked, but that sounds about right). If you wanted to max out the inductor at 500mA, the would require 500mA / 40 = 12.5mA base current to keep the transistor saturated. At least that's easily doable from a PIC pin, since those are rated for twice that current. I wouldn't actually run the transistor at the limit, since there will be some rise in C-E voltage.

I don't want to write a book here, so I'm going to cut short a few thought processes. Let's just pick 6uS as the inductor on time, and we'll use a pulse on demand system. Whenever the output voltage goes below its regulation threshold, the micro will produce a 6uS (6 instruction cycle) pulse.

Note how each time we pick a parameter, we can feed that into the equations and nail down something else more tightly. At this point we've decided to use a 100uH inductor, a NPN grounded emitter switch with a minimum guaranteed current gain of 40, and a fixed size 6uS pulse on demand control system. Now we go back and find what our highest inductor current can be:


Volt Sec 4.2V 6uS
Amps = -------- = -------- = 252mA
Henries 100uH

1/4 amp is going to be no problem for finding a inductor or transistor, so that all looks good. To keep the transistor saturated, it needs 252mA / 40 = 6.3mA base current. Obviously we want a little more for margin and to keep the saturate voltage low. 10mA sounds like a nice number given the circumstances.

Here's something that might not be obvious. The limiting case for base
current is the lowest input voltage, not the highest. You might think it doesn't matter because the inductor current will scale linearly with input voltage, so proportionately less base current is needed as the input voltage goes lower. However, there is a larger fixed offset subtracted from the base current drive voltage than from the inductor drive voltage. This is because the voltage accross the base resistor is the supply voltage minus the fixed B-E drop of the transistor, whereas the inductor charge voltage is the supply voltage minus only the transistor saturated on voltage. The net effect is that the base current scales down more quickly as the supply voltage drops than the inductor current does. So we need to know what current the transistor must sustain at 3V:

Volt Sec 3.0V 6uS
Amps = -------- = -------- = 180mA
Henries 100uH

180mA / 40 = 4.5mA minimum required base current with 3V supply. Let's say 700mV is lost between the B-E drop of the transistor and the high side output pin driver in the PIC. That leaves 3.0V - 700mV = 2.3V accross the base resistor. 2.3V / 4.5mA = 511 ohms. We of course want to build in some margin and keep the saturation voltage down. 360ohms sounds like a nice number. That provides 30% margin.

Now we need to do a sanity check at the maximum supply voltage. Again let's assume 700mV is lost that is not applied accross the base resistor. (4.2V - 700mV) / 360ohms = 9.7mA. That's real close to the 10mA we thought sounded nice earlier, so that checks fine.

I'd add another minor detail to speed up the switching transitions a little.
At 6uS on it's not a big deal, but a $.01 part can help things just a
little. Turning the transistor on isn't a issue since the inductor current starts out at 0 anyway. The base current will build up to its steady value much faster than any appreciable inductor current will. However, we want to make the transistor switch off as fast as possible. Grounding its base via a 360 ohm resistor is actually not that bad, but we can still speed it up with a small capacitor in parallel accross the base resistor. The resistor alone will probably turn off the transistor within about 100nS. To see where we're at, let's see what capacitance would result in a 100nS time constant, meaning about 2/3 of the effect is over in 100nS. 100nS / 360ohms
= 278pF. Hmm, that sounds too big. Make it 100pF. That results in a time constant of 100pF * 360ohms = 36nS.

Normally you have to consider the inductor discharge time. In this case it's obvious from casual observation it's not a issue given the 70V output, but let's do the calculation anyway just to show it:


Amp Henries 252mA 100uH
Sec = ----------- = ----------- = 383nS
Volts 70V - 4.2V

which is well under a single instruction cycle. Or put another way, the inductor current is guaranteed to reach 0 with the switch off for just one instruction cycle.

Of course the above is only true during normal operation when the output voltage is already around 70V. Startup is a whole other issue. This is one of the advantages of having a micro. You can easily use a different algorithm and different parameters during startup than during normal operation. I don't feel like getting into startup here, but it's something that has to be considered.

So the 10F204 code for the normal operating loop looks like this:


loop
skip_low ;output below regulation threshold ?
goto loop ;no, go back and check again

switch_on ;turn on the switching element
nop
nop
nop
nop
nop
switch_off ;turn off switch 6uS later
goto loop ;back to wait for output low again

SKIP_LO, SWITCH_ON, and SWITCH_OFF are macros that expand to single
instructions. It's a good idea to add that layer of abstraction. It
separates the control algorithm from the details of how that particular
project is wired to the micro.

Now we can calculate the maximum output current the supply can maintain
voltage regulation with. From the code above it should be obvious that
there is a minimum of 4uS between the fixed size 6uS pulses, for a maximum pulse repetition period of 10uS, and a maximum pulse rate of 100KHz.

At the lowest specified input supply voltage, we calculated earlier the
inductor charges to a maximum of 180mA. This was assuming no switch loss, but let's see what the best possible case is and scale back from there. 1/2 * (180mA)**2 * 100uH = 1.62uJ, x 100KHz = 162mW, / 70V = 2.3mA. Obviously we're not going to get 100%, but certainly this supply will be good for at least 1mA. Since the spec said "miniscule" (rant about bad engineering suppressed), we can claim we're done.

[...]

The calculations above took way longer to describe than to do. A couple of minutes with a calculator is all it should take to get to this stage.


(this was posted @PICList some days ago by Olin, and I asked permission to make it available in here since I (and others) found it interesting and detailed)
post edited by DarioG - 2009/10/03 03:10:57

GENOVA :D :D ! GODO
#1

9 Replies Related Threads

    Stefan Uhlemayr
    Super Member
    • Total Posts : 4292
    • Reward points : 0
    • Joined: 2005/05/12 12:25:46
    • Location: Germany
    • Status: offline
    RE: a detailed guide to building your own DC/DC converter using a little PIC, by Olin Lath 2009/10/15 04:02:29 (permalink)
    +2 (1)
    Hi Dario,

    big thanks for posting this guide from Olin here. Never built a DC-DC-converter myself (always taken ready-to-use-parts), but very interresting reading! Maybe you can send Olin big thanks, too, and nice greetings. His knowledge is really missing here in the forum.

    Greetings,
    Stefan
    #2
    1and0
    Access is Denied
    • Total Posts : 9314
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    RE: a detailed guide to building your own DC/DC converter using a little PIC, by Olin Lath 2009/10/15 05:11:05 (permalink)
    0

    ORIGINAL: Stefan Uhlemayr

    Maybe you can send Olin big thanks, too, and nice greetings. His knowledge is really missing here in the forum.

    Agree. Really miss Olin's posts around here.sad Thank you Dario and Olin for the guide.
    #3
    DarioG
    Allmächtig.
    • Total Posts : 54081
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: Oesterreich
    • Status: offline
    RE: a detailed guide to building your own DC/DC converter using a little PIC, by Olin Lath 2009/10/15 05:28:35 (permalink)
    0
    Smile will do, or you can do that by yourself as well

    Aftre reading this post, I felt like building a DC-DC converter like this just to... have some fun with the parameters! Smile
    post edited by DarioG - 2009/10/15 15:49:01

    GENOVA :D :D ! GODO
    #4
    kenn
    Super Member
    • Total Posts : 226
    • Reward points : 0
    • Joined: 2008/01/19 09:23:48
    • Location: Toronto ON
    • Status: offline
    RE: a detailed guide to building your own DC/DC converter using a little PIC, by Olin Lath 2009/10/15 05:38:04 (permalink)
    0
    That was a good article. Dario, could you add a link to that post?

    (I have two words for piclist though - "user interface". Man that site hurts! [:@] )

    what, me assemble?
    #5
    violin
    Super Member
    • Total Posts : 3301
    • Reward points : 0
    • Joined: 2005/05/09 04:59:48
    • Status: offline
    RE: a detailed guide to building your own DC/DC converter using a little PIC, by Olin Lath 2009/10/15 10:32:44 (permalink)
    0
    Hi Dario,

    big thanks for posting this guide from Olin here. Never built a DC-DC-converter myself (always taken ready-to-use-parts), but very interresting reading! Maybe you can send Olin big thanks, too, and nice greetings. His knowledge is really missing here in the forum.sad

    Greetings,
    Stefan


    Not only do miss Olin but also Ric and many, many others who no longer participate here since Olin’s ban. The forum’s is defiantly not what it used to be since I first joined it a few years ago. I still learn some here but not as much what I used too. Regards
     
     
    #6
    atferrari
    Super Member
    • Total Posts : 1380
    • Reward points : 0
    • Joined: 2004/07/08 13:09:24
    • Location: Buenos Aires - Argentina
    • Status: offline
    RE: a detailed guide to building your own DC/DC converter using a little PIC, by Olin Lath 2009/10/15 10:48:53 (permalink)
    0
    Grazzie Darío.

    Positively an interesting post!

    Agustín Tomás

    In theory, there is no difference between theory and practice. In practice, however, there is.

    http://cablemodem.fibertel.com.ar/atferrari/
    #7
    Stefan Uhlemayr
    Super Member
    • Total Posts : 4292
    • Reward points : 0
    • Joined: 2005/05/12 12:25:46
    • Location: Germany
    • Status: offline
    RE: a detailed guide to building your own DC/DC converter using a little PIC, by Olin Lath 2009/10/15 11:47:03 (permalink)
    0
    ORIGINAL: kenn

    That was a good article. Dario, could you add a link to that post?
    Here it is: http://www.nabble.com/Re%3A-24V--%3E-5V-switching-regulator--p25560372.html
    ORIGINAL: kenn

    (I have two words for piclist though - "user interface". Man that site hurts! [:@] )
    Yeah, I agree.wink
    #8
    Neiwiertz
    Super Member
    • Total Posts : 2094
    • Reward points : 0
    • Joined: 2004/09/01 02:58:52
    • Status: offline
    RE: a detailed guide to building your own DC/DC converter using a little PIC, by Olin Lath 2009/10/15 14:48:05 (permalink)
    0
    Stefan

    See if this nice article from Olin can bein added at the Hardware Favorites.

    Regards

    Flying With --|Explorer 16|HardWare|SoftWare|-- Fav(s) Gallery Lists
    #9
    DarioG
    Allmächtig.
    • Total Posts : 54081
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: Oesterreich
    • Status: offline
    RE: a detailed guide to building your own DC/DC converter using a little PIC, by Olin Lath 2009/10/15 15:52:43 (permalink)
    0
    Thank you Stefan - it would have taken longer for me to go finding the "interface" to PICList grin

    @Violin: it's true, we learn less now...

    GENOVA :D :D ! GODO
    #10
    Jump to:
    © 2019 APG vNext Commercial Version 4.5