Dimming 220v LED lights

First post here, so as an introduction I'll just say that I'm very new to Arduino and while I'm quite comfortable with the coding side of it, the hardware/electronics part is what I'll have to learn the most.

After doing some PWM tests on the breadboard, I was immediately thinking "hey, this would be cool to do with my home lights", so I started reading a bit and it got to the point where I figured asking somebody "in the know" would be a lot more productive and/or less conducive to blowing stuff up :slight_smile:

So, what I'd like to do is confirm a few things I think I learned and ask about a couple of things that still confuse, so here it goes :slight_smile:

a) If you want to control anything "big" (i.e. plugged in on mains electricity), Arduino is ok doing that, but you need a relay in between. For simple on/off stuff (turning on a light, etc.) I've seen plenty of examples and I'm confident I could do that without that many issues.

b) You can do PWM "through" a relay, but that requires the relay to switch fast enough and also SSRs would be better for this as mechanical relays might make noise and/or have their life shortened by the quick switching.

c) All LED "replacement" light bulbs (i.e. the ones you can just plug in where you used to have a normal incandescent one) have a transformer inside them which brings mains (220v here in Uruguay) to 12v DC.

So assuming those are "right", that brings me to the actual question:

d) Can i build a circuit where an Arduino PWMs an SSR "into" one of those 220v replacement LEDs to dim it or would that fail horribly? Or in a more general way, can you PWM the input of a transformer and expect the output to mimic the PWM, or does it get filtered by the transformer?

Thank you very in much in advance for any pointers/stuff to read/recommendations/comments :slight_smile:

Around here in the US we have hardware stores called Home Depot, they have special dimmers for LED bulbs.
I bought one to try it out, it made loud hum as I recall, very obnoxious on a quiet night.
They do differentiate between LED and incandescent dimmers.
http://www.homedepot.com/s/led%2520dimmer?NCNI-5

I do not believe the mains powered LED light use a 220V to 12V transformer, I am pretty sure it is something more solid state based to make a high efficiency DC-DC converter.
The mains powered LED lights (direct replacements for incandescents) are not cheap, I haven't tried opening one to see what's in them. They do work well. Much better than CFLs, especially in base-up ceiling fixtures.

Thanks for the reply.

I am aware of the availability of commercial dimmers, but it was mostly about trying to figure out if it was something that could be done from an Arduino instead (setting the light level for your whole house from a central computer would be a pretty cool application).

About the LED lamps, I actually found a video of an A19 being opened up (which is one of the possible lamps I'd have available to test) and you can see from about the 4th minute on, that it does have an AC-DC converter inside -> Philips A19 "60w" LED Light Bulb Spring 2014 Version Teardown and Review - YouTube

So the question remains if a PWM through an SSR would be able to dim that particular lamp, or by the own description of the circuit inside the lamp (explained in the video but way ahead of my current knowledge level, lol), it would require something completely different.

Pretty neat.
I think you'd want a central control telling a remote PWM control at each light what to do via standard network type connections (RS485 for example), let the receiver (Attiny series chip for example) control the SSR/dimmer equivalent at each location after receiving a command message. You don't want PWM emanting from the central control all over the house, that would be an RF nightmare.

And with a network, you could get some feedback from each location as well. PIR input, temperature sensors, door/window sensor, etc.

There are a few complications...

AC SSRs, are built with TRIACs. A TRIAC latches-on until the current drops to zero (at the next AC zero-crossing). So, regular PWM simply won't work. A normal "phase control" dimmer works by switching-on a TRIAC at some known point in the AC cycle. Then it remains-on 'till the next zero crossing. The light is dim if you trigger the TRIAC just-before the zero crossing, and it's bright if you trigger it just-after the zero-crossing.

If you are going to dim a regular incandescent bulb with a microcontroller, you need to detect the AC zero-crossing* (using transformer or opto-isolator to isolate the AC), and then you need another opto-isolator and a TRIAC (or a phase-controllable SSR) to control the AC. (There are zero-crosing SSRs that won't turn-on in the middle of the cycle, and you don't want to use one of those.)

Some AC LEDs are dimmable (with a regular dimmer) and some are not. Fluorescent lamps require a different kind of dimmer.

Another way to do it is with the [u]X-10 Protocol[/u]. Then, you can use standard X-10 wall dimmers. (I've never built an X-10 controller, but I have one that I bought.)

  • You don't have to use the actual exact zero-crossing, and that's not so easy to do anyway... It's not so easy to find the peak either... You can trigger at some point along the waveform, such as when the voltage hits 10 or 20 volts. Then, you can figure out from the line frequency when the next zero-crossing is coming. And, if you find the positive-going 10V point you know where the next two zero-crossings are, so you don't have to find the negative-going 10V point.

When I did this a long time ago with another microprocessor, I used some voltage trigger point from the secondary of the power transformer in the unit's power supply (I don't remember the voltage) and then I just experimented to find the correct timing for minimum & maximum brightness.

CrossRoads:
You don't want PWM emanting from the central control all over the house, that would be an RF nightmare.

I totally hadn't thought about that, and of course you are absolutely right.

Regardless of that, and for testing purposes, you think then that the Arduino generating PWM and a 220V SSR (for example, something like http://www.amazon.com/SainSmart-4-Channel-Duemilanove-MEGA2560-MEGA1280/dp/B0079WI37Y/ref=sr_1_1?ie=UTF8&qid=1409085974&sr=8-1&keywords=arduino+ssr) should actually work as a dimmer for an A19 lamp like in that video? I have a feeling the SSRs in that board wouldn't be fast enough for flicker-free operation, but I wouldn't care about that for just a test.

And yeah, the network with sensors and stuff is the "endgame", but like I said, I'm still a total beginner so I see that quite a bit further down the road (I can easily envision the code driving the whole thing, but I need to learn a hell of a lot about the hardware side, hehe).

DVDdoug:
AC SSRs, are built with TRIACs. A TRIAC latches-on until the current drops to zero (at the next AC zero-crossing). So, regular PWM simply won't work.

To make sure I'm understanding you correctly.

What you are saying is that if a high pulse of the PWM enables the SSR when the cycle is at, say, 10v and climbing, then the relay will stay on until it goes all the way to the peak and back to 0, disregarding other lows or highs in the PWM?

DVDdoug:
A normal "phase control" dimmer works by switching-on a TRIAC at some known point in the AC cycle. Then it remains-on 'till the next zero crossing. The light is dim if you trigger the TRIAC just-before the zero crossing, and it's bright if you trigger it just-after the zero-crossing.

Because if you switch it just before zero it has "little time" to be up and if you switch it just after you have most of the cycle?

DVDdoug:
You don't have to use the actual exact zero-crossing, and that's not so easy to do anyway... It's not so easy to find the peak either... You can trigger at some point along the waveform, such as when the voltage hits 10 or 20 volts. Then, you can figure out from the line frequency when the next zero-crossing is coming. And, if you find the positive-going 10V point you know where the next two zero-crossings are, so you don't have to find the negative-going 10V point.

When I did this a long time ago with another microprocessor, I used some voltage trigger point from the secondary of the power transformer in the unit's power supply (I don't remember the voltage) and then I just experimented to find the correct timing for minimum & maximum brightness.

While I'd have no idea how to implement this on hardware at this point, I think I get exactly what you mean. Since the cycle has a known frequency (50 Hz here) and it's a sinewave, detecting any point at all (and having a timer available in the microcontroller) immediately gives you a "model" of the entire wave, so you can basically target whichever part you want (give or take calculation errors or frequency changes in the mains power, so I guess it would be wise to "remeasure" from time to time to keep your model in sync with the actual wave).

Thanks a lot for the reply, I think I just learned quite a bit from being wrong earlier :slight_smile:

If you want to control anything "big" (i.e. plugged in on mains electricity), Arduino is ok doing that, but you need a relay in between.

The only good relay is one that has been hit repeatedly with a bloody big hammer. Take a look at the wiki entry for transistors. this is the mast useful bit Transistor - Wikipedia Relays died when Marconi invented the valve more than 100 years ago. (well ok when they invented the transistor in the 1950's.

Mark

holmes4:
The only good relay is one that has been hit repeatedly with a bloody big hammer. Take a look at the wiki entry for transistors. this is the mast useful bit Transistor - Wikipedia Relays died when Marconi invented the valve more than 100 years ago. (well ok when they invented the transistor in the 1950's.

I get that you can switch stuff with transistors.

But isn't the whole point of a relay isolating your Arduino (and the expensive Intel CPU on the motherboard with the USB port plugged to that Arduino, lol) from anything evil that can happen "on the other side" - particularly if the other side is mains power? :stuck_out_tongue:

But isn't the whole point of a relay isolating your Arduino (and the expensive Intel CPU on the motherboard with the USB port plugged to that Arduino, lol) from anything evil that can happen "on the other side" - particularly if the other side is mains power?

No! People just use relays because they are easy to understand!.

Mark

if you looking to better tools working with 110V/220 As well with easy and safe to connect and simple to program i recommend you to see this

this device allowing you to control AC voltage "on off or even as dimmer " simply by sending PWM rather than right a complex code which allow you to integrate it with more advance project.

http://www.sugarworld.net/