The Shocking Truth About Transformerless Power Supplies

Transformerless power supplies are showing up a lot here on Hackaday, especially in inexpensive products where the cost of a transformer would add significantly to the BOM. But transformerless power supplies are a double-edged sword. That title? Not clickbait. Poking around in a transformerless-powered device can turn your oscilloscope into a smoking pile or get you electrocuted if you don’t understand them and take proper safety precautions.

But this isn’t a scare piece. Transformerless designs are great in their proper place, and you’re probably going to encounter one someday because they’re in everything from LED lightbulbs to IoT WiFi switches. We’re going to look at how they work, and how to design and work on them safely, because you never know when you might want to hack on one.

Here’s the punchline: transformerless power supplies are safely useable only in situations where the entire device can be enclosed and nobody can accidentally come in contact with any part of it. That means no physical electrical connections in or out — RF and IR are fair game. And when you work with one, you have to know that any part of the circuit can be at mains voltage. Now read on to see why!

The Principle

A transformerless power supply (TPS) is basically just a voltage divider that takes the 115 or 220 VAC from your wall and divides it down to whatever voltage you want. If that voltage needs to be DC, it is rectified through a few diodes, and maybe regulated to a maximum voltage but we’ll get to that in a minute.

Normally, DC voltage dividers are made with a pair of resistors. Combined, they define the current flowing through the path, and the top resistor can then be chosen to drop the difference between the input voltage and the desired output. If, in our case, that difference is some one or two hundred volts, even if it only has to pass a few tens of milliamps, that resistor is going to get hot fast.

A better component to use in the top of the divider is a capacitor, with its reactance chosen to give the desired “resistance” at whatever the mains frequency is where you live. For example, say you want 25 milliamps out at 5 V, and you’re in America and need to drop 110 V. R = V / I = 4,400 Ω. Using the reactance of a capacitor, that’s C = 1 / (2 * pi * 60 Hz * 4400) = 0.6 μF. If you need more current, use a larger capacitor, and vice-versa. It’s that easy!

A fully elaborated TPS design requires a few more parts. For safety, and to limit inrush current, a fuse and a one-watt current-limiting resistor on the input are a good idea. A large-value discharge resistor in parallel with the reactive capacitor will keep it from holding its high voltage and shocking you when the circuit is unplugged.

And speaking of that capacitor, it’s a safety-critical part of the circuit. It is subjected to continuous high alternating voltages and if it fails short, the “5 V” output is at mains voltage and parts may catch fire. This is a job for an X-rated capacitor. You’ll see them marked X1 or X2 mostly, with X1 being able to withstand higher voltage spikes. Either one will do, just be sure that it’s rated X and specified for your mains voltage level.

After the capacitor, the AC that passes through needs to be rectified into DC. A normal half- or full-wave rectifier will work here: a handful of diodes and a large-valued smoothing capacitor. If the load isn’t constant, you’ll probably want to limit the maximum voltage seen by the capacitor with a Zener diode, so that excess current is shunted to ground when the load draws less than the 25 milliamps we designed for. These parts only see low voltages, so there are no special requirements here.

Finally, note that there are many possible configurations of this circuit. Instead of dropping most of the voltage between live and our device, it’s also possible to connect our device straight to the live wire, with the capacitor in the lower leg of the voltage divider — the same circuit upside-down. The fuse and safety resistors can be located anywhere in the circuit, of course. But the basics are the same: the capacitor acts as one leg in a voltage divider, followed by some rectification and regulation, with the load as the other leg.

Muphry’s Law

The big caveat with a TPS circuit is that it must be isolated. That’s totally fine for a self-contained IoT switch or DIY light dimmer. A TPS is a good match for radio or IR control. LED lightbulbs all use TPSs inside because they’re cheap and completely sealed up. But if you’re thinking of touching any part of this circuit, or plugging any signal line into it, you should be looking at a transformer instead.

Why the complete isolation? Notice that the wire that serves as the circuit’s ground reference is the same as your home’s neutral line (in contrast with the “hot” line). Now imagine mistakenly putting the plug in backwards. Ground is hot, and although the device works just fine because AC is symmetric, it becomes an electrocution hazard if you can come in contact with “ground”. Plug a USB-serial connector into this device, and you’ve just fried your laptop through the “ground” line. So the first line of defense is to use polarized plugs that can’t be plugged in wrong. If you live in Europe, this may not be an option.

But even polarized plugs are not enough. Some old houses (including an apartment we lived in in Washington, DC) have the neutral and hot lines reversed. Again, you’ll never notice until you touch “neutral” and real ground at the same time, but when you do, it can be fatal. You can, and probably should, test this with a multimeter right now. When referenced to ground, the neutral line should present under a volt AC, while the hot line will read either 115 or 220 VAC. Check these against your local plug types.

Anyway, even if you get the plug polarization right, there’s a difference between your wall socket’s neutral and ground lines. Codes in the US and EU say that neutral is the current-carrying line, and ground should, under normal conditions, not carry any. Ground-fault circuit interrupters (GFCI) enforce this in practice. Still, high loads elsewhere in your house coupled with non-negligible resistance in the wiring can result in some V=IR voltage on the neutral line. An imbalance on the service transformer that splits the “phases” of power entering your home can also pull the neutral voltage away from ground, depending on where it’s grounded. In short, neutral should be around ground, but it’s not guaranteed.

The only way to be absolutely safe with this circuit is to never come in contact with it. Put it in a non-conductive box, or a metal one that’s connected to the earth safety ground. If it gets plugged in backwards, or if the neutral wire goes hot, nobody gets hurt. That’s what the pros do.

What else can go wrong with this circuit? We picked the reactive capacitor to have the right resistance at 50 or 60 Hz, but it’s less resistive at higher frequencies. If you have high-frequency switching devices somewhere in your home, they can push unexpected current through your TPS. Quick power-line spikes pass right through, for instance, and damping them is one reason for the input resistor. Lightning strike? Blammo! Anything else that can go wrong? Leave us a comment! (But don’t mention Muphry.)

A transformer-based power supply is going to be marginally more expensive and a little bit bigger than an equivalent TPS. But if you can’t entirely enclose the device, or you cannot absolutely guarantee the polarity of the incoming power, you cannot use a TPS safely. For personal daily use, I’ll always choose a switch-mode power supply or wall-wart. Isn’t it worth a couple dollars to be galvanically isolated from the wall?

Let’s Take One Apart

On the other hand, TPSs are in all sorts of devices that we like to hack so you need to recognize them in real life. Look for the fuse or big X1- or X2-rated capacitor and you’ll be on the right track. (Does it have a bleeder resistor in parallel? If not, it might be hot.) The current-limiting resistor is the big ceramic thing barely visible behind the X2 cap. The fuse is dressed for a night on the town, wearing a one-piece, black shrink-wrap number.

Next, find your way to the rectification section — a four-diode full-wave rectifier and a 100 μF capacitor in this cheap RF wall switch. The diodes point toward the positive DC rail, and away from the negative.

Now look around for Zener diodes. In the case of this RF-controlled switch, there are two: a 25 V Zener used to activate the relay, and a 5 V Zener that supplies the IC and radio circuitry. This is a handy feature of the TPS circuit. Since the capacitor passes some current as long as the DC voltage doesn’t exceed the AC peaks, you can get practically any, or multiple, voltages out of the same circuit just by picking the right Zeners.

Playing With Fire

You’ll want to avoid working on a powered-up TPS as much as possible, but there are ways to do so safely. This is a prime case for an isolation transformer, which essentially interposes the transformer into the circuit that it’s lacking. There is still a pair of wires in your circuit with 115 or 220 V between them, but at least with the transformer you can attach your ‘scope to the device.


Without an isolation transformer, you can do a lot with a battery-powered (non-grounded) multimeter. Plug the TPS device into an extension cord with a switch, and keep that switch off as much of the time as possible. To take readings: unplug the TPS, tack-solder wires where you want to take a measurement, connect these to your multimeter, stand back and turn the power strip on. Once you’ve made the reading, turn it back off and wait a tick before touching anything.

The one part of a TPS that can hold charge is the reactive capacitor, and that’s why it should have a bleeder resistor across it. In our example circuit, 0.6 μF * 1 MΩ = 0.6 seconds, and you’re probably good waiting at least five of these time constants before touching anything, so count to three. The RF switch bypasses a 0.33 μF capacitor with 220 kΩ, so it’s safer faster. (It also uses two SMT resistors in series, presumably because the voltage rating of either one alone wasn’t sufficient. Smart design.)

You can find out which parts of the circuit are at what voltages by measuring them with respect to the wall socket’s ground pin. For instance, with a 560 Ω safety resistor in the return leg, the RF switch’s “ground” actually floats some 12 VAC above earth ground. This is worth knowing when poking around. Again, connect your probes, stand back, turn on, read, turn off, wait.

And that’s all there is to it. You can now figure out what voltages are in the device, and hijack them for your own purposes. Just make sure that whatever you do, it all fits back inside its nice case. Because although TPSs are ubiquitous, small, and cheap, they’re potentially (tee-hee!) too hot to touch.

Source link

Leave a Reply
