Instructables
Picture of AC Arduino dimming circuit
IMG_3085.JPG
dimmerRX.gif
THANKS TO CONCERNED VIEWERS, I HAVE LEARNED THAT THIS IS NOT SAFE AND SHOULD NOT BE REPLICATED.
SO PLEASE DONT TRY THIS :)

THANKS TO EVERYONE WHO COMMENTED, I LEARNED A LOT 
I am not an engineer, just an experimenter and hacker and prototyper etc, so, thanks to people who know a lot more than I do, I learned that this is not safe to use 
------------------------------------

Have you ever wondered how you can use a remote control to dim your own lights, to control a window fan, or to regulate the heater?

Here's a simple circuit using Arduino that makes this possible!
It uses ONLY two electrical components.

This is recommended for someone who has some experience with Arduino and electronics.

As with anything that uses AC wall power, this could be dangerous if done hastily.

Done carefully, it could also be really simple and fun.

NOTE:  This can only be used to dim a unit that runs off of a transformer-based power supply, ie something that doesn't run off of 120 V, but 12, 24, or 48 Volts. 







 
Remove these adsRemove these ads by Signing Up

Step 1: MATERIALS

Picture of MATERIALS
!B-LSf3gEGk~$(KGrHqIOKjYEzmRmHvuZBM7-MElrOg~~0_35.JPG
IRF730PBF-1.jpg
ts6p.jpg
Breadboard.jpg
45040-dscn0626.jpg
558642_lg.jpg
9v-battery.jpg
usb_soldering_iron.jpg
pna4602_t.jpg
RMEZ4.png
WHAT YOU WILL NEED: 
Solder iron, wire strippers, breadboard or perf board, wires, 9V battery, IRF730 transistor, bridge rectifier,  Arduino, infrared detector (like this one), SONY universal remote control (like this one)
1-40 of 42Next »
dudes1 month ago

So does this convert AC to DC and actually output DC? Or did I miss something and it outputs AC?

UdyRegan1 month ago

I was just about to create something similar for my glass storage cabinet but after pondering about it, I would rather not because I am not expert in this electronics field. I agree that it is indeed very fun to try out new things and produce something new by yourself. However, safety needs to always come first before achieving anything else. Thus, I have decided to leave it to the professionals. Nevertheless, you have a really creative mind!

buteman2 years ago
Good to see your efforts and what I say below is in no way meant to discourage you but rather to help you and others.
We all make mistakes and it can be a way to learn. Better not to kill ourself in the process though. :-(
Just so you know for anything else you might build here is why you had problems with the IRF520 and IRF540. You are using the bridge rectifier to turn the 110volt A.C to D.C. When it is 110volt A.C that is what is called the R.M.S voltage which means the average value of the voltage. For 110volt A.C you will have a peak voltage of 1.414 x 110 volts = 154 volts. Rectifying it does not reduce that voltage by more than 1.2 volts ( approx - due to the diodes in the rectifier ) so you are subjecting the transistors to way more than their specification so it is no wonder they failed.
So they could have easily handled the current which for your 150 watt bulb ( less than 1 amp ) they could not handle the voltage.
I agree with other comments about the danger of plugging in the low voltage supply while it is connected to the mains.
gabriellalevine (author)  buteman2 years ago
Yep I see now that this is unsafe . I am wondering if it is safe to use to modify a 12 or 24V AC power supply?

What type? Linear or switch mode? And of the switch modes, which class? Flyback, buck, boost? If you know the design of the PSW well enough, yes*.

tristantech2 years ago
"This is recommended for someone who has some experience with Arduino and electronics."

"At first, I was using the IRF 520, with a 100 V drain source voltage and a 9 amp continuous drain current. It worked fine at first, and then it burnt out (there was connectivity between the gate-source and gate-drain). So I got an IRF540, with a 100 V drain source voltage and a 33 continuous drain current. This similarly worked at first, then burnt out."

A 100V max transistor to control a 120Vrms or 169.2Vpp signal? Come on!

I'm sorry that I have to say this, but whenever I see a poorly designed circuit on Instructables that threatens the safety of anybody thinking of attempting this project and is a bad example of basic electronics guidelines, I feel that I have no choice but to call it out. And frankly, I don't think that you have the faintest clue as to what you are doing.

1) Isolation. You should never have low voltage electronics at the same ground potential as AC mains. The 5v powering the electronics must stay isolated and cannot be electrically attached to the AC. The proper course of action to take is to use an optoisolator to control the switching element (in your case the IRF730) without needing a common ground. Why? Because it creates a grounding hazard. The Arduino and all connected devices (PC) are at mains ground potential.

2) Wire gauge. In the last picture of step four you show the IRF730 attached to the AC cord with small hook-up wire (maybe 22 or 24 AWG). Then, you show a massive space heater being attached to your circuit. Wire has current limitations (maybe an amp or so); you can't run a 1,000W+ space heater (or any large load) through that dinky wiring. And yes, the full mains current comes through those wires. Follow the electron's path through the diodes and you'll see.

3) Switching. The proper way to dim an AC load is to use a TRIAC device. A zero-crossing detector is employed to sync the microcontroller to the AC waveform. The TRIAC clips off certain portions of the waveform to dim the load. In your case, you're sending some random pulse width modulation signal to the transistor, causing it to clip off random bits of the waveform. I bet that the lights often flicker when you adjust the brightness.

4) Heatsinks. Your transistor is switching a major electrical load. You need to affix a large heatsink to the metal tab of the transistor (that's why it's there). The heat sink will dissipate the heat that the heavy current is giving off.

5) Enclosure. Your clear box is what we call a "Rat's Nest". This jumble of wiring is bad for low voltage electronics because you can't find anything, but it is deadly when using AC mains voltages. Because you don't have any strain reliefs and a breadboard, it is too easy for wires to come loose and short out or come in contact with another wire. High voltage projects need to be in a neat case with soldered connections.

6) Fuses and safety precautions. Since you have a device with a current limit (Transistor) in series with a potentially heavy load, you need to insert a fuse to protect the transistor from burning out.

I know that I'm being picky, but when you publish a project for the world to see, it has to be done right. There are simply too many people out there who don't know any better than to learn from or try this.
gabriellalevine (author)  tristantech2 years ago
And thank you for that, I see what I was overlooking. Is this therefore safe if you use it to modify a device, like a lamp, running off a 12, 24 or 48 AC power supply ?

One thing I just thought of that will make this unit 1000's of times better is the implementation of a proper solid state relay. These are *specifically* designed for this exact purpose: to control mains power with low-voltage electronics. They are rare to find in household electronics due to the per-unit price compared to triacs, but with it, that alone will be enough to make this safe (and of course a nice, clean PCB etching of everything onto a PCB. It is actually not that hard to do, although I never had too much luck, I did not try hard either)

If you implemented the use of an isolation transformer, this will be somewhat safer. Also, for a permanent unit, wired must be soldered or have solid screw terminals. To add additional safety, add either a fuse in-line, a current limiting ballast, or a control loop to regulate (and restrict) current flow (All 3 to really help limit current!). Also, as he said, use a generously rated 200Vds 15A MOSFET or BJT. As long as the electronics are enclosed properly, having them operate at mains potential is fine, as long as there is no electrical connections running from the inside to the outside, like a USB or the like.

Also, the wires running to the MOSFET should be the same gauge as the extention cord, and if not, they should always be kept as short as possible.

gabriellalevine (author)  tristantech2 years ago

Do you recommend that I take this post down? The last thing I would want to do is steer someone in an unsafe direction.

"And frankly, I don't think that you have the faintest clue as to what you are doing."

I'm not sure what you mean by this. I have already explained that I am not from an electrical engineering background. I am a hacker and a programmer and I do a lot with electronics, and I use Arduino. For me, this has worked, and I have built this circuit a number of times. I used to use an optoisolator : http://blog.eletronlivre.com.br/search/label/arduino%20brasileirino%20program-me%20dimmer%20dom%C3%B3tica
like that circuit but thought from http://dmitry.co/index.php?p=./04.Thoughts/06.%20RC%20dimmer this site where I found this circuit that this would be a fine way, and it worked.

"A 100V max transistor to control a 120Vrms or 169.2Vpp signal? Come on! " I was following the circuit on http://dmitry.co/index.php?p=./04.Thoughts/06.%20RC%20dimmer website, from his post and video it seemed to work . So I got the right component and the circuit has worked for me, and as opposed to a triac / optoisolator circuit I've built, as linked to above, this one does not seem to flicker at low light level.

Anyway, I thank you for your concern, and I am happy to take down this post. Please let me know your thoughts
Hi gabriellavine,
Is it posible to see your schematic and part list? Thanks in advance
I see that what http://dmitry.co/index.php?p=./04.Thoughts/06.%20RC%20dimmer he is using it for is also not 120 Volts. So ... yes, I had built something quite unsafe. Thank you
I beg to differ with Item 3.... With large loads a TRIAC is fine... BUT... at low loads, the TRIAC will not reliably trigger, and, if the load is less than 8 to 10 watts, can become downright unstable. With low power loads, the above approach is the ONLY approach (short of a Variac) that will work reliably.

The circuit needs a little more refinement, though...
A "zero-crossing circuit needs to be added to synchronize the micro-controller with the AC mains and the PWM overall period should be a few micro-seconds short of 8.33 mSec (in the us - 10 mSec in Europe)

The PWM will "fire" twice each cycle of the AC mains (once for the positive half of the cycle and once for the negative half (hence the need for the zero crossing detector.)
gabriellalevine (author)  tristantech2 years ago
I have made an addendum, to the TOP of the post, that this should NOT BE REPLICATED as it is unsafe. thanks again for the concern
You could probably redo this in a perfectly safe way. An optocoupler, some fuses, a heat sink, and thicker wire sound like they're the only real things you need.
Item #3 is wrong.

High frequency PWM (as is used in this project) is the norm in industrial AC control. TRIACs are used in household dimmers because they work with an extremely simple (and therefore cheap) control circuit. As long as the switching frequency is at least 300 Hz there shouldn't be any flickering. The MTSpice screenshots seem to show this is the case.

The rest I pretty much agree with.
memmdo72 years ago
hello , What components should i use to control a 220 v Lamp using Arduino.. and also i would be grateful if you put your circuit schematic of the "AC Arduino dimming circuit" ..thanks in advance
atb_uk2 years ago
The idea iteself is good but I'm seriously concerned about this circuit design. There is no isolation between low and high voltage parts so the whole circuit including an arduino got potential of 110V. This is really dangerous!. I can see the small hole in the box to plug an arduino power jack, please don't do it as you may blow up your power supply or get electrocution if you touch any arduino part.
gabriellalevine (author)  atb_uk2 years ago
If you use an transformer based power supply for the Arduino (or 9 V battery) it will keep the AC and DC isolated. I can put an addendum to the post making this EXTRA CLEAR

Also, I am not an engineer and if I am overlooking something, please don't hesitate to respond. I thought that by isolating the 5V (or transformer based) power supply from the 110 V power supply, it WOULD in fact be safe. Thank you for the concern
Just to elaborate: if the arduino power
supply isolates its output from
input, then there shouldn't be in any
connection between AC and DC power. The 9V supply's grounded in the bridge rectifier.
So if using a DC power supply for Arduino or a transformer based supply, then input and output are isolated.

So yes, don't supply power from the PC via USB. ONLY use the USB to PROGRAM the Arduino board, when the AC voltage is NOT connected.

Thanks again
Tristantech is perfectly correct in what he is saying - for the sake of safety, you MUST isolate the low voltage DC from the high voltage AC.

An opto-isolator is the obvious method (and probably the cheapest) because to are simply sending pulses to the MOSFET.

If I could draw you a diagram I would (can somebody else provide one?) but imagine all the high voltage AC components on the left and all the low voltage DC components on the right. There is no physical, electrical or mechanical connection between them except for light (within the Opto-Isolator) - that's safe...!!!

People's lives are at stake whenever you use AC mains power.
gabriellalevine (author)  duncan_a2 years ago
Here is an optoisolator circuit I've used:

http://blog.eletronlivre.com.br/search/label/arduino%20brasileirino%20program-me%20dimmer%20dom%C3%B3tica

I'll respond to tristanTech, sounds like I should probably take down this post as the last thing I would want is to steer someone in an unsafe direction
Even by cutting and pasting that link it just let to a page saying "No Links Found"

Your idea is good, your Instructable is good - it's just the method used that is worrying those of us with more experience of these things - experience often gained the hard way!!!

Rework the circuit with an opto-isolator (for your own safety), recreate the schematic showing the new method and replace the original with the new one, rewword the text and you have it - a good and safe Instructable...

Don't give up, don't be disheartened - OK?
try: http://blog.eletronlivre.com.br/search?q=dimmer
If you used a bigger box and put the DC power supply inside then there wouldn't be any high voltage outside the box.
Yep I see that this shouldn't be used for 120 V AC. super unsafe. Thanks again.
No, the AC and DC is not isolated because you connected them. Look at the schematic where the 0V line connects with the MOSFET Source pin and the rectifier. By DC, we mean the low-voltage circuitry that includes the IR receiver, PIC, and anything else connected (like a computer). The DC power source can come from anywhere (battery, transformer, solar, whatever) It's the way you control the transistor that creates the problem.
jfagan atb_uk2 years ago
I have to agree with atb_uk, linking mains voltage rails to the low voltage is a recipe for disaster. There should at least be some opto-isolation between the uController and the mains side.

Sorry to be a party-pooper, but I would strongly suggest that no one really attempt this.
diy_bloke2 years ago
perhaps i completely misunderstand this project, but I do not see why the Arduino must be in the same box as the high voltage parts. It is a on optical driven dimmer am i right? The arduino sends an optical signal to a receiver in the high voltag epart. As long as that is properly wired and insulated there should not be any danger.
Also I see no difference with this project:
http://dmitry.co/index.php?p=./04.Thoughts/06.%20RC%20dimmer so i sthis just something that is copied?

mgingerich2 years ago
Really awesome project, even if it is potentially lethal.
pmadithya2 years ago
Hi can we use Arduino Dueminalove (USB ) also for the above.. will it work for this Arduino...?
Ringmeister2 years ago
Gabriella,

I really enjoyed your Instructable, thanks for posting it.

I do not understand why people get so excited about the dangers of mains electricity. 120v AC is unpleasant to touch but really not dangerous in itself. I used to work for a company that did some work in Morocco and one of the electricians working on the installation would test for live (hot) cables by touching them (he didn't have a voltmeter!). Depending on the severity of the shock he would determine whether the voltage was 220v or 440v! I have had more shocks than I can count including some in the 300v DC range.

I think the real danger here is potential for fire due to overloads, semiconductor failure (mosfet or rectifier) or arcing (poor connections). Especially when controlling a high current device such as a heater.

Other risks for working with "high" voltages/currents include destroying the Arduino, secondary risks like jumping back when receiving a shock and then tripping, falling etc. and not forgetting sparks/arcing resulting in fire or injuries (especially to the eyes).

I am guessing that the Instructable is not intended to produce a consumer product by virtue of the fact it uses an Arduino as a controller making it a very expensive solution. Hopefully other readers will appreciate this.

One thing that I suspect should be avoided with this is attaching any kind of inductive load (fans, motors etc.) as these will result in large back-emf voltage spikes in the order of 1000's of volts (see LTSpice inductive load simulation attached).

To summarise, in my opinion:

1. This ible should be regarded as an experiment.
2. It should not be left unattended.
3. It should protected with fuses in event of a short-circuit due to semiconductor failure or overload.
4. The whole thing should be contained within a fire resistant enclosure.
5. It should not be used with inductive loads.
6. Be aware that your Arduino may get killed!

I have also attached the LTSpice screenshot, the application can be downloaded free from Linear Technologies at http://www.linear.com/designtools/software/

ac switching resistive.jpgac switching inductive.jpgac switching inductive spice.jpg
Oh dear, the images are almost unreadable, I will post some better ones. For some reason I could not get the post "preview" button to respond so had to take a chance the pictures would be ok :(
smokie442 years ago
Would it work with CFLs or other fluorescent fixtures?
gabriellalevine (author)  smokie442 years ago
That's a good question - No, fluorescent's only dim about 5% and by reducing their amperage is NOT the way to dim them. Therefore it actually might shorten the life of a CFL not to give it the full V / Amperage.

Other lights it will work for (halogen, incandescent, etc)
Please note that correct operation of halogen lamps requires that they run near full power. Dimming may shorten their life. The hot quartz envelope causes a chemical reaction between the halogen gas that fills it, and any tungsten atoms that boil off the filament. The compound wafts around until it makes contact with the even hotter filament where it decomposes to deposit the tungsten back on the filament. If you lower the temperature of the envelope the reaction will not take place and the tungsten will simply plate onto the quartz, blocking the light and allowing the filament to get thinner and thinner until it fails.
ROBBIE7772 years ago
I like and interests much your work, now I this looking for something like this, but to work with 12 volts DC. What I want is to check the power supply, or to vary the power of a Peltier, and clear with the convenience of remote control. What would the modification to your you would you do to make it work with 12v DC? Best regards
gabriellalevine (author)  ROBBIE7772 years ago
for 12 V use something like http://itp.nyu.edu/physcomp/Tutorials/HighCurrentLoads
alextricity2 years ago
Important note to consider:

With AC, the average voltage will be 120V but the peak is over 170.
Hi , does anyone have a simular design to this one for the UK or is there just a change in a component to make this work in the UK .

1-40 of 42Next »