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.

The Parts:

- 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.

The tools:

- 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!

Comments

author
pandam4 (author)2017-06-10

greetings instructables! please help guys/ gals. i have a transformer 220vac to 12vac 12A i've placed 4 diodes 6a05 bridged, then 2 capacitors 25V / 10000UF then a LM7812 Linear voltage regulator. i'm expecting to have 11v to 11.5v but it shows only 8.5 from the relay. what did i missed?

from 4 diodes 8.5v to 8.6v

from 2 capacitors 8.3v to 8.4v

from 1st regulator 7v

from 2nd regulator 8.5v

from 3rd regulator 7.5v

author
brmarcum (author)pandam42017-06-10

You're stepping down your AC too far.
You need to supply voltage regulators with at least 2 volts more input than you expect on the output. So with the 7812, if you want 12V out, you have to supply it with at least 14V bare minimum, preferably over 15V. That 15V is the output from the diode bridge, which will also drop the voltage about 0.7V per diode. The current travels through two of the four diodes at any point in time (all four are still used though) so the input to the diode bridge needs to be at least 17VAC.
The datasheet four the 7812 will list the max input V at around 30V (double check that), so if you use a 10X step down transformer that outputs ~22VAC you should have no problems, though you may need a heat sink on the 7812.
Your setup as is will only provide enough voltage to drive a 7805 5VDC voltage regulator or lower.

author
pandam4 (author)brmarcum2017-06-11

thank you sir brmarcum. will post the pic what i've made sorry it's very unprofessional work. it's not on a circuit though. if it's not too much to ask can i ask for diagram what should i put in it with parts. diode, capacitor, regulator, etc. appreciate it!

got 220vac to 12vac 12A transformer

IMG_20170611_222419.jpgIMG_20170611_222432.jpg
author
brmarcum (author)pandam42017-06-10

Good question. Thank you for providing sample data. It makes it easier to pinpoint the solution.
Cheers

author
josephbuilds (author)2017-02-04

hi there, thanks for the instructable! I would like to make this as safe as possible and would like to add a fuse as you mentioned. I live in Germany now and here they don't have fused wall plugs as i used to in Engand. How would you recommend doing this? (more than happy to recieve a simple link and I'll work it out from there...)

author
brmarcum (author)josephbuilds2017-02-04

I would add a fuse between AC mains and the transformer. The correct fuse rating needs to be determined by the max input current capacity of your transformer, or the max input capacity of your circuit, whichever is lower.

author
brmarcum (author)brmarcum2017-02-04

I added a fuse to this project //www.instructables.com/id/Motion-Activated-AC-Switch/ but not on the ac/dc rectifier portion. I split the ac mains input to use as a switched ac source controlled by the dc portion.

author
Confuseddad (author)2016-11-19

I made this using a lm317. My output voltage is jumping quite a bit. Would a larger cap help smooth that out?

author
brmarcum (author)Confuseddad2016-11-20

I would have to see your circuit. The capacitors between the diode bridge and the regulator should take care of a lot of the AC ripple in, and the capacitors after the regulator should filter anything else that gets through.

Is the "jumping" you are seeing happening at regular frequency? Does it appear at several places in the circuit or just on the output of the 317? Are you using long wires that could be acting as antennas and picking up signals from other devices nearby?

What voltages are you working with at each stage? AC input, after the diode bridge, into the regulator, and after the regulator? If you are trying to get your 317 output to be close to what you put into it, but flat, you will likely have problems. You need some buffer voltage in that you can afford to lose to the regulator to let it do its job properly.

author
ANDERM (author)2015-09-18

Do all Transformers require this method? Example if you have a motor that runs on 18v DC but want it to run on AC, you just happen to have a 117v (AC) to18v (DC) @ 2amp transformer would this work? or does it require this method you show? My other concern is the amperage because I do not know for sure the amp limit on the DC motor. Any help or advice will be greatly apreaciated.

author
brmarcum (author)ANDERM2015-09-18

This method is for stable, flat line DC output using sinusoidal AC input. If the device you are connecting to the output can handle an imperfect, unstable DC signal, then it is possible to use just the transformer and diode bridge (the signal still needs to be rectified positive. LED strips can use this method as long as you match your numbers right).

As far as I understand DC motors, you need rectified AND stabilized DC power for it to work right. So you will need to set it up as shown here.

Regarding amperage, as long as the entire circuit after the transformer (diode bridge, regulator, AND motor) requires less than 2 amps, it will work fine. The motor should list average amps needed as well as max amps needed (peak) in the datasheet. If it lists it in watts, divide that by the voltage rating to get amps. The motor should never require more than that, so just make sure your transformer's output rating exceeds that power requirement.

Hope that helps.

author
ANDERM (author)brmarcum2015-09-19

Yes it did help me understand a bit better, thank you! I did manage to find out the amps under normal run and load run which is ranging from 2.7A to 16A under load. So now I just need to figure out how to build the transformer set up correctly. Also I found out more about the transformer I found which list a apparent power of 36VA, not a 100% sure of this meaning yet. Which will be the next step to learn is knowing which diodes or parts will be needed and as you stated making sure the numbers are correct. So now that I know my amp limits, the current transformer may or may not work unless the amp limit/power is controlled or regulated from my understanding if this is correct. This is what I am understanding if my assumptions are correct that is. I am enjoying learning about this, I only know basics but this is getting me into a very exciting world of circuitry. Which is a bit confusing and complicating but way cool. I did find another site called all about circuits which helping also, it is a bit hard to understand some of it sometimes but it helps. This is awesome stuff, From a beginner, Thank you very much for your help! BTW: I like how you present your instructions very informative.

author
trplback (author)2015-06-20

Are ac and dc powered motors so different that it's impossible to change a motor that currently runs on ac to run on dc?

author
brmarcum (author)trplback2015-06-21

Impossible is an absolute and I don't like absolute. But in this case, it may be accurate. They work in similar but very different ways. AC motors are matched to the frequency of the input current, which is how you vary speed. DC motors use the level (quantity) of current to vary speed. I'm no expert, but it would probably be much (much, much) easier to just get the right motor than convert one. Though it would be a pretty cool way to learn motors.

author
trplback (author)brmarcum2015-06-21

Thanks....

author
Akasi (author)2015-02-14

One more question. Is this circuit meant only to convert AC main to DC? Can I use any other source of AC and use this circuit to convert this to DC? Thanks!

author
brmarcum (author)Akasi2015-02-14

Yes and yes. This exact circuit, with these parts, will rectify 100-240VAC to a rough DC at about 10% of that input, giving you enough DC to smooth out and regulate down to a stable 5VDC output. In concept, this design can be used to convert any AC source to DC, but you are responsible for determining your design requirements and ensuring that your components can handle the voltages/currents being applied to them.

author
Akasi (author)brmarcum2015-02-23

I was going to give this circuit at max, approximately 12 VAC, and I wanted to know if this circuit could make it 3 VDC, so that I could power a simple motor.

author
brmarcum (author)Akasi2015-02-23

I think that may work. If you pass the 12VAC directly through the bridge rectifier, you'll get a really rough 10VDC out of it, which you can then pass into the regulator. Check the datasheet for your particular regulator since most require a certain amount of voltage in to ensure you get the rated output, i.e. a 7805 requires about +7V input to ensure a stable +5VDC output. With a 10V input, you should be fine using a regulator rated for 6V or less.

author
Akasi (author)brmarcum2015-02-26

Thanks. I have made the circuit, but it seems not to be working. My only plausible explanation of it not working is that the AC voltage fluctuates a lot. You can learn more about where I got the AC voltage by looking at Easy Wireless LED's by electro18. Does the voltage have to remain constant in order for this circuit to work?

Here are the pictures. Please reply! Thank you so much!

IMG_0351.JPGIMG_0352.JPGIMG_0353.JPGIMG_0354.JPGIMG_0355.JPGIMG_0356.JPGIMG_0357.JPG
author
Akasi (author)2015-02-07

Hello there! By the way, great project. You explained the process throughly

Now, I want to convert an AC source into a DC current so that I can use it to charge a phone. How could you modify this to ensure that the correct amount of voltage will reach your phone?

author
brmarcum (author)Akasi2015-02-07

Thanks for checking it out and for the compliment.

To start, I need you to clarify between current and voltage. They are very different. This circuit, as is, will output +5VDC, which is the same voltage as nearly every phone charger out there. Also, I've never built a dedicated battery charger. This circuit MAY do the trick, but you would need to add a resistive load in series between the +5V output and the positive battery terminal to prevent charging too quickly. (I am not in any way responsible for any damage caused by the use of this circuit. Do your own thorough research and make the best decision for your application based on YOUR knowledge.)

This circuit is designed to provide a constant fixed voltage (e.g. +5V like above). Voltage regulators can also be wired to provide constant current as well. In the case of charging batteries, you will need to keep both current and voltage in mind. A quick Google search for "battery charger circuit" yields tons of results. What they have in common is that the voltage source is greater than or equal to the rated voltage of the battery, i.e. you can't charge a 3.7V battery with less than 3.7V, and you will need 4V+ for a good charge. The other common item is a current limiting resistive load as mentioned above, like a large power resistor or even a simple incandescent light bulb, in order to prevent the battery from charging too quickly. All batteries must be protected from charging too fast as well as overcharging, but lithium batteries are especially sensitive to overcharging, so be extra careful. Whatever circuit you choose, connecting the +5V/GND output wires to a cable that fits your phone power port would be a simple soldering hack. If you leave the battery in the phone it may have monitoring software to prevent overcharging.

author
inswlkes (author)2014-12-17

Thanks for the tutorial, brmarcum. What are your thoughts on how you might handle circuit protection on this type of circuit, be it varistor, TVS, neither, both?

author
brmarcum (author)inswlkes2014-12-17

Thanks for checking it out.
The honest answer is that I don't know enough about circuit protection to give you an educated answer. The projects I've come up with to use this with haven't been important enough to worry about needing circuit protection.
You can find schematics on the interwebs, but do your research and look at many different designs before picking one.
And as always, use extreme prudence and caution when working with AC. Good luck!

author
gada888 (author)2014-07-05

Hi,brmarcum.i followed you from another tutorial to this one.I like your tutorials,i already got the digilent analog discovery and found it very useful.but i am afraid of using it to test this circuit as it involves mains power.i thought the tool may not test more than 5Volts.how did you get the waves?

author
brmarcum (author)gada8882014-07-06

On the right side of the o-scope window you can change the settings for each scope channel. Set the V/div to whatever you need to see the data. You can only go up to a max of 5V/div though, which will allow you to see +/- 25V. If you then set the offset to -25V, you'll be able to see 0 to +50V, and +25V offset gives you -50 to 0V. You won't be able to see the full 120VAC wave, but you can still get time based measurements, like frequency, from it. I use a digital multimeter to measure high voltages and then the Discovery for the lower voltage stuff.

author
gada888 (author)brmarcum2014-07-12

Thanks for your time,Could you leave me your email.in case i consult you about use of Digilent product.lkglass@hotmail.com

author
gada888 (author)brmarcum2014-07-06

Thanks

author
bergerab (author)2014-07-01

Thanks for submitting this! An explanation like this is hard to come across and it really does help to demystify AC. However, I wish there were a few more pictures or maybe even a video to help guide beginners and those who have trouble reading longer text (like me). (maybe a video of testing parts of the circuit with an oscilliscope?) But, for those who enjoy a nice read you really lay out all the information well and the amount of information you know on this subject is impressive. Can't wait to see some more instructables from you

author
brmarcum (author)bergerab2014-07-01

Thanks bergerab. I'll see what I can do about some more pics.

About This Instructable

39,098views

121favorites

License:

Bio: I've always loved to figure out how things work, so hacking and making just fits for me. I'm a husband, a father, an ... More »
More by brmarcum:Programming Digilent FPGAs Using NI MultisimMonitoring Digital Circuits With the Digital DiscoveryUsing the Voltmeter With the Analog Discovery 2
Add instructable to: