Power supplies and transformers; a learning experience

[Ladyada] is working on a tutorial series covering power supplies. If you’ve ever built an electronic project you’ve used some type of power supply but we think that most people have no idea how you get from mains power to the DC voltages that most small projects use. So if you want to learn, get started with the first installment which covers AC/DC converters based on a transformer like the one seen above.

These transformers are inside the heavy and hot wall-wart plugs that come with many electronics. We used one along with a breadboard power supply when building the pumpkin LED matrix. They use a pair of coils to step down the voltage to a much smaller level. From there it’s a matter of rectifying the AC into DC power, which she talks about in an easy to follow discussion.

We understand this type of converter quite well but we’re a bit foggy on switch-mode AC/DC converters that don’t use a transformer. They’re much better because you don’t have to build a regulator into the target project like you do with wall-warts. Can’t wait until she gets to that part of the series!


  1. Jim says:

    So my first job involved switching DC/DC converter design, in fact, that’s all I did. It’s really not hard, but it can be quite difficult to do without a proper PCB and a good layout. The easiest thing to do if you are just hacking something together is to use a slow loop (usually just hang a big capacitor to ground off the compensation pin) and a whole lot of output capacitors in parallel.

    As to offline converters… man, you’re really asking for trouble to do that without a transformer. If you’re paying attention it is not particularly more dangerous than any other electronics, but if you are not careful you don’t have the transformer there to help protect you from lethal line voltages. Especially for our brothers across the pond who have 240 VAC power, you can really have a bad day working on that stuff. Be careful!

  2. Jim says:

    There’s a really great tutorial on Switching-Mode Power Supply Design over at http://www.smpstech.com/tutorial/t02top.htm

  3. Noodle says:

    Aw, this is a really nice intro to this sort of thing. I did this sort of thing in my undergraduate labs but don’t remember much of it. Makes sense when it’s shown like this. Good job! More basics!

  4. George Johnson says:

    Wall WART, not wOrt. Wort is basically “pre-beer”. Warts are the nasty little things that grow on your body, similar to the nasty little things that stick out of your wall.

  5. andar_b says:

    Just because I’m a nerd, wouldn’t that be “wall-warts”?

    Since the actual skin condition is a wart, not a wort, it seems to me that they’re called “wall-warts” as an allusion.

  6. grenadier says:

    He forgot to mention the variac!

  7. Colecago says:


  8. sexiewasd says:

    I would love to see a tutorial on 5v and 3.3v power supplies for automotive conditions.

  9. Owen says:

    Recently I needed to add a 5V PSU to a kiln controller I was building and found that the easiest and cheapest option was to buy a very tiny and low priced mains to USB switched mode supply from China off eBay – it was under £4 including postage.

    It was very easy to take apart and even smaller without the case, maybe 1×2 Inches max and the circuit is very robust and able to supply 1A, more than enough for my purposes.

    I’d definitely recommended it as a way to go if you’re in a rush.

  10. Dave says:

    Since when does a switching power supply not use a transformer?

  11. signal7 says:

    This is old technology for sure. Today, the only reason to use a wall-wart in consumer electronics is if it’s cheaper than the switch-mode counterpart. Even then, you have to account for the difference in cost to rectify the output, regulate it to a known voltage, and provide short circuit protection.

    If that’s not enough, today’s chip manufacturers are working hard to cram every part of a switch mode power supply into a single package so you don’t even have to know *anything at all* about power supply design. You can’t compete on a cost basis with progress, imho. Today’s solutions are quickly making wall warts look like a vacuum tube in terms of technology…

  12. Alex the magical says:

    I have neat transformer learning trick.

    1) hook household electric cords to the high and low side of the transformer.
    2) plug them both in at the same time.
    3) Double rainbow!

  13. cgmark says:

    I still prefer transformer based supplies over SMP for prototyping. When you are building circuits one of the features of a transformer based supply is the isolation it provides.

    I was working on a simple project that lit up LED. I used a power adapter from an old router , the adapter is a switching adapter. Output is rated 12VDC @ 2A, made by 2wire. I connected the positive lead of the led to a resistor on the breadboard and then attached another wire for the negative to the LED and before I connected it to the breadboard , I noticed the LED was already glowing. So the LED was attached to the + side of this wall adapter and me touching the other side of the LED was lighting it up. Only one explanation. I was the ground ! Placing my foot on the floor made the LED glow brighter.

    I pulled out the meter and measured the current between my hand and the led, 8-10ma. Not enough to kill under most situations but I really don’t like being the path for current in my projects :)

    Now most switching adpaters are better designed than this and do attempt to isolate the mains from the output but clearly this one does not do it well . I’ll stick with transformer designs for hobby work just to be safe.

    For audio supplies transformers are nice too. Since products have started to move more to switching designs I have noticed the complaints of ground loops have really increased. All these separate devices linking grounds with no isolation really can become a problem if they are designed like the adapter I encountered.

  14. MRE says:

    I once had a switch mode emiting 6 inch purple sparks out the assend of the power cord inlet on a machine which moved a lot of water.
    Sparks were grounding out on some conduit and plumbing.

    Yeah, they are small and cheap, but no safer.

  15. cde says:

    @ Dave, they either use a 4 diode wave rectifier, then switch it down to the needed voltage, or they use a transformer and then a switching regulator.

    I think they meant to say that it doesn’t just use a transformer as the major piece.

  16. Jimbo says:

    Hmmm, if you are using or designing a mains to DC switch mode power supply chances are there will be an isolating transformer (especially if the PSU is to be approved for use in most developed countries) as an integral part of the design – most likely a flyback or push-pull type PSU with an opto-isolated feedback. The difference here that you can make such transformers much smaller than their wall-wart ancestors.

  17. Meseta says:

    I’ve designed and built a regulated 3-phase AC to DC converter (in reality, a DC/DC converter and a diode bridge rectifier) for a 7kW wind turbine system as part of my final year project as an engineering undergrad, and as quite a few posters above have said, switch-mode power supplies aren’t that difficult to understand and build.

    Switch mode converters that don’t use transformers are likely to rectify the mains AC using a diode bridge first, and then use a DC/DC converter to obtain the required voltage.

    DC/DC converters either use inductors or capacitors to do the task. A layman’s description of of how they accomplish the task is that they basically rely on being able to store up energy in either the inductor or the capacitor, and then by controlling the rate at which the devices can charge up/discharge using transistors, it is then possible to control the output voltage of the circuit.

    The down-side of DC/DC converters is that the size of the inductor/capacitors are a function of the current output and switching speeds, which is why you’ll only see consumer-grade transformer-less DC/DC converters for small things like cell phone chargers, or where it is important to regulate the output voltage (like in computer PSUs, although PSUs still use a transformer to get the voltage into the right range, and then a DC/DC converters to regulate the output)

    I used a SEPIC topology in my wind turbine circuits since I needed full regulated 300V DC out from a variable 180V to 500V 3-phase turbine. However because of the current ratings, my inductors needed to be massive, they ended up being about 3 or 4kg

  18. Max says:

    I’m not arguing how well switching mode mains supplies CAN be designed – I’d like to know how safely they usually are. Since pretty much everything uses these for a supply I get a small shock every time I disconnect any A/V equipment (TV/PC/HiFi/VCR, from the same power-strip) at home from any other, if I don’t remember to let go of either the cable plug or the chassis before the two grounds disconnect. Actually, you can steadily measure half the AC line voltage between any two chassis – but it’s only a small current, not a “short” if you shunt it, that gets uneventfully channeled somewhere when the grounds are connected; still, it’s quite enough to give you a buzz when they are not (and to visibly spark on connecting). And no, in my experience this “feature” is not exclusive to my place. So you will graciously excuse me for not liking switching mode mains supplies vs. transformers much at all.

  19. Tim says:

    My only problem with this tutorial, is that is doesn’t seem to differentiate between a standard full-wave and a bridge rectifier power supply. Given they are both full-wave, a bridge (with 4 diodes) gives a higher voltage output (and a more efficient output), than a standard full-wave (2 diode) circuit.

    In the overall scheme of things, this is probably not the significant, but in some applications, this is highly critical.

    Was a good review none the less.

  20. strider_mt2k says:

    Awesome article, great commentary.

    Classic HAD.

  21. MSEE_Madhouse says:


    It sounds as if you have an electrical
    wiring issue that should be looked into.
    What you’re describing is NOT normal !!

    The most obvious thing to check is the
    grounding conductors at your main panel.
    Since if you’re getting zapped the way
    you describe, that tells me the electric
    ground is not properly connected (either
    in the outlets, or at the meter/panel).

    Accident waiting to happen. You need
    to address it before someone in your home
    gets killed from it.

  22. Peter says:

    Linear Technology (www.linear.com) has some great switch-mode converter chips *and* a free full-featured PSPICE simulator (LTSpice), which comes with a bunch of reference designs and runs fine under WINE on Linux. (Can you tell I’m a happy user?)

    But seriously, Digikey sells their stuff, you can get demo boards for most of their regulators and it’s a great way to get over your fear of switching regulator design.

    Regarding line supplies for hacking projects, I, too, favor recycling switching supplies from consumer products. We have a big box of adapters here at work — leftovers from who knows what bygone devices — and we routinely recycle them to power other projects. They almost all have voltage and current ratings on the label, and you can often open them up and slightly tweak the output voltage by changing a resistor divider. If you screw up and it incinerates itself, hey, you didn’t pay anything for it!

    Switching supplies are also way more efficient than linear regulators (the dependable LM7805) for large voltage drops, and can be designed to accommodate a range of input voltages.

    Regarding Variacs (or more properly, autotransformers) – they’re seductive, but be aware that the output is *not* isolated from the input, and as with all line powered circuits, you need to approach them with respect. A GFI extension cord between the wall and the input to the Variac would not be a bad idea, and may in fact save your life.

  23. Einomies says:

    “I pulled out the meter and measured the current between my hand and the led, 8-10ma. Not enough to kill under most situations but I really don’t like being the path for current in my projects :)”

    Your power supply must have be leaking AC because per your description, “touching the floor made it brighter”, you didn’t have a galvanic connection to the ground but a capacitive coupling.

    And there’s the niggle. I don’t believe your story one bit.

    10 mA AC through the fingers is extremely painful. It feels like hitting a steel pipe against something so hard that your fingers sting.

    I know that because I’ve subjected myself to it several times. The pain treshold for most people is around 2 mA.

  24. Jesper says:

    This is the time to point and laugh.
    I’m a long time lurker and i just recently got a bit more involved with electronics, and this tutorial really made me want to do something about some of the stuff i got laying around. I’ve got a 22″ monitor with the adapter blown up and a laptop with the same problem. I’ve got the labels with the required voltages / currents for the hardware, but here’s question:
    If I wanted to make an adapter with these specs:
    input 100-240VAC 1.5A
    output DC12V 4.2A
    The only thing I would have to do is to get a transformer to drop the voltage to the 12V, then get a rectifier (4diodes) and then make sure all components are rated for minimum 4.2 A?

    Thanks in advance, and I’m sorry for the bad english, I’m danish if you were wondering.

  25. Meseta says:

    @Jesper, yes, that will work, but you’ll find it difficult to get a stable 12V DC output without a really big capacitor.

    Connecting up a transformer, say a 1:13 transformer, will get your 110V AC down to 8.5V AC

    HOWEVER, this is where you have to be careful, because usually an AC voltage is quoted in RMS voltage rather than peak voltage. What his means is that a US mains 110V line is actually an AC waveform with a peak voltage of about +/- 155V. (The 110V figure corresponds to the equivalent DC voltage in terms of amount of power delivered to a resistive load, i.e. 110Vrms AC will give you the same heating effect if you passed it through a resistor as 110V DC, even though the peaks of the AC are higher than 110Vrms)

    What this means is that after rectification, your rectified 8.5V AC output is actually going to be more like a rectified sine wave with peak of 12V (8.5 * sqrt(2) ~= 12). See: http://en.wikipedia.org/wiki/AC_to_DC_conversion#Full-wave_rectification

    Putting a large capacitor across the outputs will smooth out the peaks so that it’ll look more like DC. But at your current rating of 4.2A, you’re going to need a pretty massive capacitor to do this. What you’ll find is that your output will be about 12V when you have nothing connected to it, but as soon as you start drawing 4.2A, your supply voltage will suddenly pick up a large 120Hz ripple of several volts depending on your capacitor size.

    So if whatever you are powering is OK with that kind of ripple, then you’re good to go. If not, then you’d want to use a more complex circuit.

    I would recommend against powering a monitor or laptop with this circuit, the standard power supplies have built-in switch-mode regulators to provide a steady 12V DC. A transformer and bridge rectifier is a fairly crude approximation to this.

  26. Jim says:

    If you did what you are talking about it would somewhat work, in that at some load current you would get 12 V. You could make that be 12V/4.2A but that would mean that at 0A the output voltage would be higher.

    The nice way to do this is with a switching regulator, and that’s [most likely] what was in the broken adapter. It’s more efficient and cooler. And the easy [non-HaD] way is to just buy one, you should be able to find something compatible with your requirements (say, 12V/5A) off Digikey or similar for $20-30.

    But you wouldn’t learn much that way. So the easiest way to learn something is to start with a linear regulated output. You start with a transformer, then a diode bridge and a properly rated capacitor. Remember that 120 VAC is the RMS voltage, the peak AC voltage is 1.4x higher. Then follow that up with a linear regulator attached to a big heat sink. The way I’m looking at this your heat sink has to dissipate 20 W.

    Once you have that working you can start looking at DCDC converters to replace the linear regulator (or even more if you get ambitious). But if you only “just recently got a bit more involved with electronics” that would be a big leap. In that case consider the National “Simple Switcher” line of parts, preferably one at a low frequency (~40 kHz) which means a big fatty inductor but typically easier loop design. As I wrote, switchers are easy if you are careful and have a half a clue what you are doing.

  27. George Johnson says:

    You guys talking about switchers with no isolation are either crazy or are buying junk.

    Switchers (good ones) provide PLENTY of isolation via optical isolation and transformers.

    Only a fool would use a line operated switcher without any form of isolation. Just dumb.

    I’ve never seen a design that does NOT use some form of isolation. Not that it’s not out there, just *I* have not seen it. It’s VERY common to use optical isolation in the feed back circuit. And obviously, the transformer on the power side of things.

  28. Jim says:

    @Tim: A bridge rectifier and a full-wave rectifier are the same thing. A half-wave rectifier only uses two diodes. In any event, both achieve the same maximum output voltage.

    The difference between the two (aside from that there are two more diodes in a bridge) is that the negative part of the cycle is rectified in a bridge. In a half-wave rectifier, the negative part of the cycle is just cut off – it’s gone, and you don’t conduct any current during that period (half of the cycle). Which means that your capacitor hooked up to the output of the rectifier needs to be twice as beefy (well, a little more but we don’t need calculus to understand the basics).

    This is why you saw a different output voltage. If you use a multimeter to measure a half-wave and a full-wave rectifier under load with the same output capacitor, the RMS output (which is much like an average for something close to a DC signal) will be lower for the half-wave rectifier. However, if you put a big enough capacitor there, or pull no load, the voltages should measure out the same.

    Of course, if you have a scope to look at the output you’ll really understand. To explain that would take either understanding of how diodes work or a half-assed picture, which google will have for you if you really want to know. And that is the limit of my free explanations today. :)

  29. Mike Szczys says:

    Boy, that’s kind of embarrassing. I’m going to claim that I have an affinity to type the word ‘wort’ because of one of the local radio stations is WORT.


  30. cgmark says:


    Of course the supply is leaking AC, it is connected to the mains. The only way I could be providing a path back to the circuit is through the ground of my workspace which is a poured concrete foundation, very good ground connection. As for how much current hurts there is no universal amount. It was 8-10ma as measured by a fluke ammeter.

    • sa_penguin says:

      cgmark, the steel rebar in your foundations make an good earth. The concrete? Not so much.
      How much current hurts? That depends on the frequency – if your switch mode is running at about 50KHz you get a “skin effect” where the electric current is in your skin – and hard to sense. Lower frequencies [like mains 50 / 60Hz] 10mA can hurt somewhat more.
      So I conclude your switching supply was poorly filtering the AC component: that is what coupled through your body to light the LED. Good Fluke ammeters will measure AC currents at high frequencies, you need to remember to measure frequency as well.

  31. cgmark says:

    @George Johnson

    There are thousands of switching supplies that do not use isolation. It is cheaper to produce them that way. The manufacturers get away with it the same way they used to allow power supplies to be directly connected to the AC and just rectify straight into DC with not isolation. As long as the finished product doesn’t expose the power connection to a point the consumer will likely contact then it passes safety rules. Many tv were made this way years ago where the outer shell was plastic, but contact an interior part and you could get shocked.

    I had a friend that thought it cool to add a headphone jack to the tv. It shocked him pretty bad when he went to plug in the headphones. The internal speaker was NOT isolated from mains.

  32. Peter says:

    @Jesper: A 12V transformer and a full wave bridge will output “around” 17V with no load, dropping lower as you add load. That’s because the 12V is an RMS value, as others have mentioned, and the peak output (under minimum load) will be closer to 1.4 times that.

    If you’re not too concerned about output voltage — powering motors or charging batteries, for example, that might be OK for you. If you want to power something like a radio or computer, however, you’ll want to regulate that 12V @ 4.2A a bit more precisely.

    You could use an NPN power transistor with a voltage feeback circuit and keep the base of the transistor at 12.6V (0.6 above the emitter) and get pretty good regulation, but understand that the difference between the voltage on the collector of the transistor and that on the emitter, multiplied by 4.2A will be a fairly large number of watts, which will need to be dissipated through a heat sink. To say the least, it’s not a very “green” design.

    That’s why people choose switching regulators. By controlling the duty cycle of the switcher, many small, variable bursts of energy are passed to the filtering circuit, and you get a more precise control of the output voltage without dissipating as much power. The voltage measured at the output controls the width of the pulses and thus the amount of energy transferred during each switching cycle. It’s a more complex design, but it’s a more efficient way to regulate voltage at high powers.

  33. macw says:

    @Jesper: an old ATX power supply for a computer, while relatively large and ugly, is a great high-current switched-mode supply. I use one as my benchtop power supply, and it outputs perfectly stable 12v, 5v and 3.3v at more than 30 amps per line. Well, the actual values are more like 12.03v, 5.08v, 3.34v, but that’s still +/- a few percent and completely stable under load.

    So you could get one of those for a few dollars (mine came from Goodwill for $6) and use it as a supply for nearly anything electronic in your house.

  34. Myke says:

    Awful tutorial IMO. She didn’t even mention the voltages or anything about current and diodes.
    All she talks about is huge ass capacitors, but doesn’t tell that those mean huge current peaks on the rectifier diodes. Awful.

  35. Gert says:

    Nice, this reminds me.
    At my school we did some current tests on some wires and we found that flexible cable could transport more current with less heat build up/problems.
    Can anyone explain this to me.
    The used voltage was 230V 50Hz.

  36. willy says:

    in my electronics class we just went over this (somewhat) we use a AC – AC converter (120v- 1to17v (our crappy transformers range in output some people got 17v some got 1v) then we use a full wave rectifier (4 diodes) to convert it to raw DC. Its really interesting how it works, its also nice to have an oscilloscope to see the output on a full (or half) wave rectifier.

    Kinda off topic but would this: http://gizmodo.com/5252774/diy-pocket+sized-oscilloscope-kit-for-33
    be able to handle AC 120v 50Hz? (I would assume it would be able to handle the frequency but what about the voltage?


  37. Hitek146 says:

    ^The specifications listed in your link state 5 Volts per Division, and looking at the photo, I see six divisions, so 6 times 5 = 30 Volts Peak to Peak. Also, if you look closely at the second photo, you can just make out the 30 Volts Max label next to the input. :) Connect to this input a standard 10x scope probe, and you should be able to measure a signal up to the 300 Volt range…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s