Monday, November 14, 2011

How do Switched-Mode Power Supplies Work?

This is a little bit esoteric if you're not an electronics geek, but since I am I feel like there's really no excuse for not understanding it.  A little bit of background for those of you with better things to do than think about how electricity gets from the power plant into your Xbox is probably in order:

Basically all consumer electronics these days run on direct current (DC) power.  Unfortunately, for various reasons (actually just one, that it can be efficiently transmitted over long-distance power lines) all the wall outlets in your house put out alternating (AC) current.  While DC power basically just sits at a constant voltage, AC power "alternates" between the positive and negative value of its rated voltage in a sinewave pattern at a frequency of either 50 or 60 Hz, depending on where you live.  As you'd probably guess, the first step to plugging DC electronics into an AC wall outlet is to convert the AC current to DC.

In the olden days, this was accomplished with a simple circuit consisting of a transformer, something called a bridge rectifier, and one or two large filter capacitors.  Wire those up the right way and you'll get something that pretty much looks like a DC voltage on the output side, with the final value depending on the transformer you used.  This tried-and-true circuit was generally crammed into a big, fat power brick or "wall wart" that plugged into AC power outlets, as shown below:

Olde tyme "wall wart" power supply.  Can you spot all the fire hazards in this picture?


The problems with this approach are obvious and legion.  The biggest one is that transformers are large, heavy chunks of iron wrapped in copper wire.  Additionally, if you want your DC output to be as clean as possible you'll need to use the biggest filter capacitors you can.  The result is that AC-DC (ha) power supplies tended to be really damn big, especially in situations where a lot of power was needed, as anyone who's ever tried to jam one into a power strip without covering up five other outlets knows.  A second, less obvious but more dangerous issue is that the circuit is not particularly efficient-- a lot of power gets lost as heat during the conversion process.  That means two things: that you need to make the brick even bigger to account for the lost power, and that in certain situations the brick is going to get hot.  Catch-on-fire hot, occasionally.  Add that to the fact that their ridiculous weight would often cause them to hang partway out of an outlet, exposing the 120V prongs, and it's honestly amazing that we were ever even allowed to have these things in our houses.

Enter the switched-mode power supply.  As you may or may not have noticed, over the last 5-10 years gigantic "wall warts" have been replaced by much smaller, lighter converters, or occasionally no converter at all when the conversion circuitry can be crammed into the thing you're powering itself (see previously-mentioned Xbox, etc).  We have the switched-mode power supply to thank for that.


Switched-mode power supply for my phone.  It's about the size of a fat person's thumb.


I know exactly two things about switched-mode supplies:
  • They are much, much, much more efficient than old-timey wall bricks, and also way smaller
  • They do something mysterious at high frequencies, judging by the amount of high-frequency noise they're constantly throwing out.
Noticeably absent from that list is "how they actually work."  So let's go to the almighty Wikipedia...

A common theme I'm discovering while writing this blog is "transistors are goddamn magic."  You'd think that would have registered after 11 years of being an EE student, but I'm consistently amazed at the clever things people figure out for them to do.  This is a perfect example of that.

The first step of switched-mode transforming isn't too different from a regular AC-DC converter; the AC input voltage is subjected to a rectifier and a large filter capacitor to turn it into something vaguely DC-ish.  The two differences here are that the voltage isn't stepped down first (meaning no big fat transformer) and, because later stages will deal with it, the output voltage doesn't have to be perfectly constant, meaning you can get away with a much smaller filter capacitor than usual.

Here's where it gets weird: having just converted AC to DC, we're now going to turn around and convert it back to AC with something called a "chopper circuit," which isn't as cool as it sounds but is still pretty clever.  The chopper rapidly switches the voltage on and off to convert the DC signal back into AC, but with a way higher frequency than before.  Typical switching frequencies here are in the 10-100 KHz (1 KHz = 1000 Hz) neighborhood, usually high enough to not make audible noise but not, unfortunately, always high enough to not mess with high-end audio recording equipment.  Whatever the output frequency ends up being, it's definitely thousands of times higher than the 50/60 Hz input frequency.

So now we've got a high-frequency AC voltage that's still at the same level as the voltage from the wall.  What's that buy us?  I'm glad you asked!  Here's where we'll throw in our transformer to step down to the voltage we eventually want.  The advantage of doing it now is that we're operating at a much higher frequency, which for various physics-y reasons means we can get away with making the transformer a lot smaller and more efficient.  Same deal with the rectifier and filter circuitry used to convert back to DC; the high frequency means you can get away with using much smaller-value components than you would when converting at 60 Hz.

You can get even cuter with it if you want; really dirt-cheap switched-mode supplies don't even bother with a transformer, they just vary the duty cycle of the high-frequency switching and then run it through a circuit that will give a DC output that varies with the duty cycle of the AC input.

So the guiding principle here is that, if you can crank up the frequency of an AC voltage, you can use a lot less hardware to get it converted down to DC, and do it a lot more efficiently to boot.  The big downside of switched-mode power supplies, aside from the aforementioned noise, is that because you've messed with the signal so much the DC voltage output is usually less "clean" than a linear transformer and will have some ripples in it.  You can usually get around this pretty easily by running the output through a voltage regulator (another transistor-based miracle device), but it's significant enough that you'll still see old-timey power supplies on things where a constant supply voltage is critical, like audio equipment and science gear.

Interesting historical note: the first known instance of a switched-mode power supply being used in consumer electronics was the Apple II way back in 1977.  Oddly, they didn't start popping up in large numbers until well over a decade later.  And for those of you currently waving your "#1 Steve Jobs" foam fingers, it was actually a dude called Rod Holt who designed it, presumably in between porn shoots. 

6 comments:

  1. Thank you for sharing this useful information
    Really helpful
    visit us SMPS

    ReplyDelete
  2. Thanks, nice explanation.

    ReplyDelete
  3. Thank you so much to this article. I got more great idea. Furthermore, the electricity that flows in two ways, AC or alternating current and DC or direct current, is actually a movement of electrons along the conductor. The difference of the two lies in the direction, wherein the former keeps the moving electrons in a switching manner, while the latter is in a steady single track. The AC system of the power supply is utilized for transmitting long distance power to various power companies. Therefore, high voltages are needed to fill the transformers of those companies. DC power supplies, on the other hand, provide current on a small-scale basis.

    ReplyDelete
  4. Switching regulators are used as replacements for linear regulators when higher efficiency, smaller size or lighter weight are required. They are, however, more complicated; their switching currents can cause electrical noise problems if not carefully suppressed, and simple designs may have a poor power factor.
    Transformer manufacturer in India

    ReplyDelete