AC circuitry has been able to use transformers for a long long time to magically go from one voltage to another. But that gives you these giant hunks of metal and wire.
The transformer is smaller and more compact if it’s passing a higher frequency. Regular old mains power uses 50 or 60 Hz because that’s a compromise that made sense back when they were rolling out electricity. Aircraft don’t need to interconnect with the power plug in a normal way so most of the time, they use 400 Hz which makes things smaller.
If you are talking about a switching frequency in the kHz to MHz range, things can become quite tiny. You are only storing a few nanonseconds worth of energy at this point.
The miracle of modern switching power supplies lets you power a neon tube at 5kV from a 3.7v Lithium-Ion battery. Or power a multi-watt LED without generating a ton of heat (At least, compared to a linear power supply and definitely not including the LED itself)
All you need is a dinky little wire coiled in just the right way.
“All” you need.
Linear regulators and transformers, in short
Neither of these are switching DC/DC converters, but I’ll talk about them anyway, just for comparison.
A transformer is an AC/AC converter. Basically, if you have a ferrite core and you have two sets of wires wrapped around it, the ratio of windings between one side and the other, minus transformer losses, will determine the respective voltages between the two sides. This has the nice property of not wasting that much energy, however, this only works between two AC voltages, not DC. In fact, you can use a 1:1 transformer to get rid of DC in a signal.
A linear regulator, on the other hand, is a naturally wasteful device. It’s got a carefully constructed circuit that will turn any excess energy to heat. However, it’s also not switching, so it’s a lot less likely to add noise on the power line.
Boost and buck power supplies
Let’s start with the “simple” case. A “Boost” will raise the voltage, a “Buck” will reduce the voltage. So, you could have a boost converter that takes 5V from a USB port and raises it to 12V or 24V to drive some LED strips or, conversely, a buck converter that will take power from a 12V power supply and let you run some 5V circuitry off of it.
If you step back, a buck converter looks a lot like a regular old linear regulator. And that’s kinda true, but a linear regulator is going to turn all of the extra voltage into heat, whereas a buck converter is going to take tiny little fairy sips from the high voltage firehose and then gently sprinkle it as lower voltage into the rest of the circuit.
I couldn’t really extend this metaphor to boost converters without telling some hacnkeyed story about unicorns farting rainbows or the like.
The thing to understand that it’s not fully magical, just having fun with Ohm’s law. Turn 10V at 1A into 5V, you will have 2A, minus switching losses. Turn 5V at 1A into 10V and you’ll only have a half amp, minus switching losses. At the same time, if you are going from 12V to 5V, a linear regulator is going to burn up over half the energy you put in, whereas a buck regulator will burn up 20% or less of that power, depending.
In all of these cases, you need a switch (these days, this generally is a MOSFET) and a diode (generally a fairly beefy fast schotky diode), an inductor, a capacitors or maybe several, and some control logic to drive things. Boost has one arrangement of these parts, buck has another.
Your average computer, if it’s made any time in the past two decades, tends to have a bunch of buck converters that convert 12V down to whatever voltage it wants to run at.
It’s easier to sip little bits of power than it is to grab a blob of power and try to push it uphill, so buck power supplies tend to perform better than boost power supplies most of the time. If you are going from 5V to 12V, you are drawing somewhere over 2.4x the amperage (depending on efficency) from the 5V side which means that everything needs to be seriously beefy on the 5V side.
SEPIC and Buck-boost power supplies
Sometimes you want to go both up and down in voltage. For example, when you are dealing with lithium-ion battery that’s going to start at 4.2 V and then drain down to 3.0 V and if you are using 3.3V parts, you want this sort of converter.
For this case, you need a part that’s twice as pumped to do cool things for you than the stuff I’ve already described.
One way to accomplish this is with a SEPIC, which basically looks like a boost converter that has an extra inductor and capacitor (And probably other bits) added to the middle. The added capacitor is there to transfer energy between the two inductors. There are boost converters that also can operate in SEPIC mode because most of the necessary bits are already there. Depending on the switch and energy stored in the capacitor, it’s operating in a kinda-boost and kinda-buck mode.
Alternatively, you can find Buck-boost power supplies which do not need the second inductor and instead use more sophisticated switching logic. The switches, if you can switch them fast enough, can act as diodes, so depending on which switches are open, closed, or acting as diodes, this converter becomes a boost or a buck converter depending on what it needs to do.
Because it doesn’t need as many parts, this makes the overall design physically smaller, thus you see a lot more boost-buck converters.
This comes at a reduction in the efficiency and the control systems need to be much more complicated. If you just need to raise the voltage or lower the voltage, a buck or boost converter is always going to come out ahead.
But, again, because the boost side is always going to be problematic, a lot of time a boost-buck will work a lot better as a buck than a boost. If you are converting a Li-Ion battery to 3.3V, it’s going to spend most of the time in buck mode and then when the battery’s about to poop out, that’s when it starts to boost.
You wouldn’t use one of these if it’s only going to be used as boost or buck, they are always more expensive and less efficient.
SEPIC and Buck-Boost alternatives and non-alternatives
Sometimes you will find buck power supplies that have some sort of bypass mode which can be useful for the Li-Ion case, so it’ll reduce the voltage till it gets a little above 3.3 V and then let the voltage fall. If it’s not there, you can always rig it up with some MOSFETs and a comparator. If you understand that all an inductor really is is a twisty little piece of wire, pretty much all it’s doing is going 100% on instead of switching.
This might be more optimal, actually. If you are looking at lithium ion batteries, that range a smidge above 3.3 V and down to 3.0 V or so when the battery’s protection circuit kicks in is not really the biggest range to optimize for, actually. Plus, if you are using the boost side of a buck-boost converter, you are going to drain the last little bit of the battery really quickly.
Sometimes there are controllers that are able to operate both as buck and boost controllers but not at the same time, where the mode they operate in depends on how the circuit has been constructed, so you might get excited based on the description but then once you look at them, you realize that each mode requires a different layout of components.
Also, there’s an inverting boost-buck power supply that uses a different arrangement to invert the voltage. This is useful, but easily confused with the boost-buck if you are in the middle of a parametric search of a bunch of parts.
Exotics
Charge pump
Most DC/DC converters use an inductor (and a capacitor and some other stuff) Charge pumps use a capacitor instead.
I was under the impression early on that these were easier, but as I’ve made more switching power supplies, I’ve come to the conclusion that the modern set of switching power supplies aren’t that hard once you get past a few points.
There are a few huge drawbacks:
- They generally top out in the mA range, so they are only handy for small stuff.
- They are ratiometric - They only natively only do integer multiplication or division of the voltage. The bulk of them will double the voltage, halve the voltage, or maybe both. Sometimes you can find one that will do thirds instead of halves. You can find a charge-pump regulator and the way that works is that it’ll kick in the charge-pump to get the voltage closer, and then switch to a regular old linear regulator.
They have some advantages, however:
- Because they lack an inductor, they aren’t generating electromagnetic interference the way a switching power supply is. If I was making a guitar that lights up, this would be a consideration.
- If you only need 20 mA or so, a charge pump that is built to do 20 mA will be much smaller than an equivalent switching power supply because it doesn’t need an inductor.
- You don’t have to pick out an inductor.
Multiple phases
A switching power supply has a section of the power cycle where it is providing power to the storage medium and a section of the power cycle where the storage medium is discharging. You smooth that with capacitors. With a beefy switching power supply, the amount of capacitance can start to add up.
You can add multiple phases, which requires an inductor for each phase and also makes for more complicated control logic. With two phases, that means that one phase is charging as one phase is discharging. With more than two phases, that means that they can overlap.
This means overall improved voltage stability and potentially also means that you get a smaller overall footprint if the added inductors take up less space than the capacitors.
Flyback and forward
Flyback and forward converters can give you electrical isolation, split-voltage rails, and higher voltages by using a transformer instead of an inductor.
A 1:1 transformer is kinda like two inductors right next to each other, without any shielding, so energy goes from one transformer to the other. Except that you can have the ground sides not touching. This means that the two sides are electrically isolated. I’ll talk more about ground loops elsewhere but this lets you avoid that because it’s really hard to get a really solid ground everywhere, which is what I tell people when they tell me that I need to be a more grounded individual.
Since you are passing power over a transformer, this means that you can have most of your logic powered by the nearby wall outlet, but the ground for the serial data connection is referenced against the lighting controller all of the way on the other side of a room. This makes the whole set up more reliable and less likely to either have signal corruption or just asplode.
But you don’t need to use a 1:1 transformer with a flyback converter. In the days of CRT tubes, you could use one of these to generate potentially-lethal killovolts in a fairly small package.
Finally, when you are dealing with audio, you frequently need positive and negative voltages, which these converters can do as well.
These are more likely to be a part of a larger power supply module, as opposed to something that you put on the corner of a board, so they requite a lot more engineering.
Bidirectional conversion
Your average switching power supplies is designed around the idea of being like a regulator. Power comes in, power goes out, but not the other way around.
More advanced switching power supplies can work bidirectionally, where they can transfer energy in both directions, as if they are a magical portal in the middle of a wire between two worlds where power is 5V on one side and power is 3V on the other side and you can exchange power back and forth.
Offline converters
When an electrical person says “offline” what they really mean is that it’s powered directly off of the electrical line coming out of your outlet.
Which absolutely confused the heck out of me for a long time.
You probably want to stay away from anything offline because now you are talking about things that can directly harm you and other people and require a good understanding of electrical safety.
Inverters
I’m mostly talking about the light side of the force, not the dark side of the force.
But the dark side of the force has power.
Audio needs negative voltage supplies, for example. There are a bunch of ways to generate negative voltage from a positive voltage. Charge pumps are one popular way, but there’s plenty of more powerful methods.
I’ve never needed them, so I don’t have much to talk about.
The Joule Thief
These are cute little circuits that you can mostly make from scrap electronics to light an LED from a battery that’s already mostly dead.
I’ve never played with them. They have a very specific topology to generate the correct voltage to light the LED and stuff, but it turns out that it’s easier for my brain to play with actual switching power supply bits. They just weird me out.
Little fairies dancing around on the chip making things magical
Actually building, from scratch, a switching power supply seems complicated. It’s a legitimate exercise for electrical engineers.
But you don’t have to. Semiconductor electronics have gotten to the point where you can shrink a pretty reasonable version of the important bits into a chip.
The impression I have is that there might be enslaved fairies carefully secreted inside of the semiconductor fab enslaved and forced to make fairy dust.
Overall, if you look at the number of extra capacitors and resistors and equations on the older parts vs the latest and greatest parts, you’ll notice that the overall complexity has gone way down.
My impression is that there’s a lot of compensation circuitry and fancy control logic that’s been carefully designed into modern controller chips where the compensation make the external parts act more “ideal” and the control logic will switch between modes depending on load and other paramaters. This makes things real convenient because people who design switching power supplies and people who design the rest of the electronics are very different in terms of skill set and training.
The control loop
Power supplies work by comparing a feedback voltage against a reference voltage. If the feedback voltage is too low, either pulse more energy through the inductor or allow more power through the pass element. If it’s too high, do the opposite.
The control loop not being stable is going to result in degraded performance or failures.
What makes the control loop unstable is usually parasitics and non-ideal behavior. Things like stray capacitance or inductance. Thus, generally when you design a PCB for a switching power supply, you generally keep those traces short and thick and frequently the pins are laid out to enable you to do this.
This also means that sometimes added filtering to the control loop will provide more effective results than adding more output filtering.
Generally a lot of these are at least somewhat application specific for use cases where you’d want less noise or are experiencing EMI or RFI issues.
Input/Output filtering
There’s almost always some capacitors on the input and output sides to stabilize the voltages. Heavy filtering can cost you efficency — you are charging and discharging the capacitor at the frequency of the switching power supply and that can end up being enough power to heat up the capacitors, even at the fairly low ESR that capacitors have.
You can also apply more sophisticated filtering topologies to these filters with separate resistors and inductors or ferrites.
Also note that the latest and greatest switching power supplies tend to be designed to prefer ceramics but a lot of older or just larger switching power supplies will explicitly require electrolytics.
Constant-current mode instead of constant-voltage mode
Pretty much any variable-voltage regulator or DC/DC converter can be encouraged to work in constant-current mode instead of constant-voltage mode.
Unless the voltage is set internally on the part, you end up with a feedback pin connected to the output side and the DC/DC converter is going to try and maintain that voltage, Vfb, at a constant level.
Thus, to work as a constant-voltage device, you want a voltage divider on the feedback pin made from two resistors. To work as a constant-current device driving LEDs, you can use a voltage divider made from the LED, which has a constant voltage drop, and a resistor.
The resistor value is going to be Vfb / I, where Vfb is the feedback voltage and I is the amperage you want flowing through the LED. For example, if the Vfb = 1.2, the amperage is around 20 mA and so your resistor is 59 Ω.
LED-specific drivers tend to have a wider output voltage range swing, will protect against open-circuit cases, and generally have Vfb much lower, maybe 0.2 V instead of 1.2 V. I’m presuming that the internals are different as well, so there’s generally no big reason why you’d want to turn a regular switching power supply into an LED supply.
Where to go from here?
- Using multiple power supplies, maybe some of them USB
- Prototyping DC/DC converters