Terra Incognita & Transformerless Power
One of my recent projects involves a microcontroller circuit powered from AC mains. The project is heavily cost constrained, so my first reaction was to educate myself a bit on transformerless power supplies (converting 110Vrms AC into 3.3V DC without a transformer). There are quite a few designs out there to work from, all of which follow the same basic combination of rectification, voltage regulation with a zener diode, and current limiting with a resistance or capacitive impedance. Using Google to search for “transformerless power supply”, one of the most popular results you’ll come across is a document from Microchip Inc. entitled “TB008 Transformerless Power Supply.” In general, it is a good tutorial and covers the basics of what should be done. One thing which immediately bothered me however, was that all of the circuits were reference to earth ground (the third prong of an AC plug that connects directly to terra firma). Interestingly, after some searching, I found another post here which also points out the same issues with referencing to earth ground. I’ll repeat some of the figures and discussion below to explain why this is a bad idea.
To begin, we need to understand why earth ground is ever included in a power supply. Disclaimer: much of what follows is a simplification and ignores a variety of special cases, etc. I’m not an expert. In any case, if you take a minute to check out the national electrical code (NEC) you’ll discover an important difference between the two “grounds” in a three prong outlet. The neutral line is referred to as the “grounding conductor” while the ground line is referred to as the “grounded conductor”. While subtle, this naming difference relates to a very important design fact: the grounded conductor was never meant to carry current. The neutral line, on the other hand, is the grounding conductor and supplies a return path for current. The grounded and grounding conductors are connected to each other at the junction box where an actual path to the earth is provided. So why is the grounded conductor there at all? For safety. The grounded conductor is used to deal with insulation faults and stray buildup of charge. It is for this reason that most chassis of consumer appliances are connected to earth ground. If something goes wrong inside your microwave, you won’t get zapped by touching the handle.
Back to the power supply design. Here is the schematic taken from the Microchip application example:
As you can see, all of the return paths go to earth ground. What’s worse, the neutral line is then directly connected to earth ground through a fuse. In the event that somebody accidentally swapped L & N, you would have a direct short from the hot AC to earth. This type of wiring mixup is not entirely uncommon. Another problem scenario is when such a circuit is plugged into a GFI receptacle. This type of outlet (the one with the test and reset button) looks for any imbalance between the hot current and the neutral current. In the above circuit, the GFI could easily trip.
Here is the transformerless supply for my project:
As you can see, the current return path is to neutral (V-). The varistor and thermistor are to protect against surges and inrush current. The 1M resistor across C14 is used to discharge this cap when unplugged – otherwise you can have the full AC voltage on the terminals for quite a while which is a shock hazard. C14 is a metal poly capacitor rated for high AC voltages. This particular supply uses the negative half cycle to generate -4.3V with zener diode D1. This negative supply is smoothed with C15 and the regulated down to -3.3V using the LM337 adjustable LDO. I’ve breadboarded and tested this design and it works…. and should even work when hot and neutral are swapped.