Introduction: AC to DC Conversion
Every once in a while I come up with an idea for a circuit or device that has applications where a battery may not be the best or most convenient option for a power supply. One example is the Motion Activated AC Switch that I built. Since I was wanting to have the switch open a relay to allow AC current to pass through, it made sense to me to make the timer circuit inside utilize the AC power that was already there. I also don't want to have to open the box every time the battery dies. That required rectifying and regulating the 120VAC mains to a stable 9VDC. The problem is that it's AC, and most people are understandably nervous about working directly with AC mains. Hopefully I can dispel that fear with this Instructable.
Before we begin, a word of caution. AC MAINS VOLTAGE IS EXTREMELY DANGEROUS!!! You must be extremely careful. This Instructable is meant to help overcome the anxiety that comes with working with AC, but don't think that I don't get the chills every time I plug in the cord so I can test the circuit. I'm not trying to downplay the dangers involved. Take your time with it. Check your work, then check it again. Be aware of where the exposed wires are. Make sure that your workstation is either isolated from other people or that they are fully aware of what you are doing. I only work with mine in my office with the door locked so the kids can't physically interrupt me. That being said, I am not responsible in any way for anything that you do. Only you can know if you should proceed or not. When you get to the point where you feel comfortable, stop and do a mental check. Don't ever get comfortable or complacent with things that can seriously hurt you.
Step 1: Theory
Most consumer electronics regulate the AC mains to DC. Some have a big, black, hurky wall wart that is unsightly and nearly impossible to plug more than one into a power strip without taking up two or three slots each. Others have the conversion circuitry built inside. A large part of the weight of the device is actually the transformer itself, which is usually made of several steel plates sandwiched and then epoxied together, and two or more windings of coated copper wire. Each winding can be any where from a just a few to several thousand turns. The number of windings determines how much change in voltage you will get out. When a current is introduced through one winding (or coil), it creates a magnetic field, with poles forming along the winding axis. If another coil is placed nearby, along the same axis, the magnetic field will induce a current, and thus a voltage, in the second coil. Adding a magnetically permeable core between the two greatly enhances the effect, reducing loss. Since the two windings are both made using insulated wire, you can wrap one around the other, with both wrapped around the core. This is very efficient and space saving, especially since you can add several separate windings to get whatever voltages you want out. Computer power supplies do this. The only thing is that the output is always AC, since for the magnetic coupling to work, the magnetic field must change polarity. The only way to do that is by using AC current, which switches between positive and negative voltages at 50-60Hz. In order for electronic circuits to work, we must convert this stepped-down AC voltage to a flat, stable DC voltage.
That's where the bridge rectifier comes in, and in this case a full-wave rectifier. We can make it out of individual discrete diodes or use one that is purpose built. The idea is that we switch the negative AC pulses to positive pulses, and leave the already positive pulses there. There is some voltage loss due to the voltage requirements of the diodes, but it is minimal and if you plan for it, it won't affect the outcome at all. The end result is a pulsed DC voltage, going from 0 to maximum voltage at 120Hz. We use a capacitor across the '+' and '-' terminals to smooth out the ripples. As the voltage rises from 0 to max, the capacitor charges. When the voltage starts to drop, the capacitor discharges through the circuit but at a much slower rate, in effect holding the voltage up while the supply drops to 0 and then rises again. Once the voltage rises to where the capacitor voltage is, it recharges the capacitor and surges back to max again. Larger capacitors will allow the voltage to stay higher longer, so you get less rippling. As long as the ripple doesn't get below a certain value, e.g. +12VDC, we can use that to power a voltage regulator, which simply stabilizes the wobbly input voltage to a specific output voltage. Full-wave rectifiers are better here than half-wave, since there is less time between the high and low pulses, resulting in a more stable output.
Schematics are shown for full-wave rectification using a center-tapped transformer and for half-wave rectification if you are interested. For the rest of this Instructable, I will be using a variation of the full-wave schematic shown in image 1.
For more thorough and better explanations, see the rectifier, diode bridge, transformer, and voltage regulator articles on Wikipedia.
Step 2: Practical Design
You will only need a few parts for this circuit. I salvage parts where I can, so you may even be able to salvage the entire AC/DC conversion circuit from something that already has it built onto a board. The side of the transformer where the AC power cable connects is the primary winding side. The secondary winding side will be connected to the bridge rectifier. Use your multi-meter to carefully check the output voltage on the secondary pins when the power cable is plugged in. The reading should be 1/10 to 1/5 of your mains voltage, which is 12-24VAC in the U.S. If you are using 220VAC mains, you will need a transformer that has a 10:1 step down ratio because most voltage regulators can't handle more than about 35VDC input. Also be aware of the power requirements for your circuit. Transformers do have current limitations and voltage regulators can usually only source 1 amp max, and only when you have a proper heat sink attached. Fuses are a good thing if you're unsure.
- 1 transformer. This one will work if you need to buy one, but they are in almost everything you use so you should be able to find one and salvage it without any difficulty.
- 5 diodes. 1N4001, 1N4004, 1N4007 will all work fine. You can substitute 4 of them for a purpose built bridge rectifier, but you will need the fifth to reverse bias the regulator output.
- 4 capacitors. 2 220-470uF electrolytic, 2 100nF ceramic disc. Check to make sure that the voltage ratings on your capacitors are higher than the voltages they will be experiencing. If the output from the diode bridge is +30VDC, and your capacitor is rated for +25VDC, you're going to have issues. Capacitors will explode if to much voltage is applied, whether your face is nearby or not.
- 1 78XX voltage regulator. I'm using a 7805 in this build. You can get them in several output voltages, e.g. +5VDC (7805), +9VDC (7809), +12VDC (7812), etc. The 79XX series of voltage regulators are similar, but provide negative voltage, i.e. a 7909 outputs -9VDC. Be sure that the output of your transformer stays at least 2V above the output level of the regulator, since it will regulate down to the output voltage required. (78XX datasheet)
- wires as needed
- heat sink if the voltage regulator is providing high current or your input voltage is significantly higher than the output voltage. For more on that, read this.
- solderless breadboard for prototyping and testing
- soldering iron and solder
- printed circuit board (PCB)
- wire cutters/strippers
Step 3: Building and Testing
This is a really simple and easy circuit to build. I've included two breadboard images that show the same thing, but one may be easier for some to understand than others.
Images 3 and 4 are o-scope images to show what is going on in the circuit. After the transformer steps down the AC voltage the diode bridge makes the signal DC, but with some serious fluctuations. Image 4 shows why we add the smoothing capacitor. This image was taken with a smaller capacitor so I could highlight the effect the capacitor has on the signal. The cap in the parts list gave an almost flat line so it was hard to see.
Image 5 shows the final regulated DC voltage at +4.8VDC. The datasheet for the 7805 shows that 4.75-5.25VDC is normal, so we are well within specs.
That's all there is to it. As long as you keep aware of what is where, you shouldn't have any problems. Remember to take it slow and double check your connections before plugging anything in. And above all, BE CAREFUL!
A special thank you to redditers t_Lancer and E_kony for their help in adding to my knowledge on this subject matter.
Please don't hesitate to ask questions, either in the comments below or PM. Have fun building!
We have a be nice policy.
Please be positive and constructive.
In the circuit below, if I make it, where do I acquire the ground ?. Thank you..