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 ads by
Signing UpStep 1: MATERIALS
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)







































![pimpMyBike[1] =](http://www.instructables.com/files/deriv/FAO/AC1G/H9T4FC2Q/FAOAC1GH9T4FC2Q.SQUARE.jpg)




Visit Our Store »
Go Pro Today »




"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.
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.)
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.
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
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?
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/
Other lights it will work for (halogen, incandescent, etc)
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.
With AC, the average voltage will be 120V but the peak is over 170.
uber
Sorry to be a party-pooper, but I would strongly suggest that no one really attempt this.
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
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
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.
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
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?