Go Down

### Topic: Fade light 220VAC (Read 2265 times)previous topic - next topic

#### Stokone

##### Jan 24, 2012, 07:16 pm
Hi to all! this is my first post

I ve made a relay shield for the automation of light in my room with a ENC28J60 ethernet module and arduino.. so.. now I want (if is possible, but i think yes) the fade on the light for 1 or 2 seconds...
The light is a 220v spot. There's 3 spot with 35 watt every spot.
I'm a newbie in electronics so i think to put a capacitor (with a diode I think) to allow an slow increase voltage in the light, this means a simple fade in and fade out...

I hope somebody can help me

#### DVDdoug

#1
##### Jan 24, 2012, 08:59 pmLast Edit: Jan 25, 2012, 12:07 am by DVDdoug Reason: 1
NOTE _ I've done this before, but with a different microcontroller.

Quote
I'm a newbie in electronics so i think to put a capacitor (with a diode I think) to allow an slow increase voltage in the light, this means a simple fade in and fade out...
It's not quite so simple with AC power.  A light dimmer works by turning on & off once per half-cycle (100 times per second at 50hz line frequency).

For example, if you turn the power on at the positive AC peak (90 degrees), off at the zero-crossing, and on again at the negative peak (270 degrees), you effectively get half-voltage.  If you turn-on near 0 degrees, you get full-brightness.  If you turn-on near 180 degrees, the light will be very dim.    Of course, you don't need to know the phase angle, you just calculate the time from the zero-crossing, based on your power line frequency.)

You also need to isolate the power line voltage from your low-voltage control circuit.

First, you need to detect the zero-crossings (or near zero crossings).   A comparator on the secondary of your power transformer should work. (The transformer provides isolation for the phase-detection part of the circuit.)   There may be some phase-shift through the transformer, so you might have to experiment with the timing.

On the AC power side, you use a triac.  Once a triac is triggered, current flows until the power is cut-off.   i.e. If you give it a short trigger pulse at 90 degrees it will stay on 'till the zero crossing, then it will shut-off 'till you trigger it again.

There are special opto-isolators designed for driving triacs, and this provides isolation on the output side of the circuit.

I'd suggest you start by building the AC triac/isolator part of the circuit, and write a program to turn the AC on & off, before working on the phase/dimmer part of the project.   (It's hard to debug the phase detector without the AC side working. )

P.S.
You should be able to use an analog input, rather than a comparator.   And, a full-wave rectifier (separate from the power supply rectifier, and not filtered with a capacitor)  will allow you to detect both-halves of the AC cycle.   Since there is a voltage drop across the rectifier, you'll be looking for a voltage a short time after the zero crossing...  But you can calculate (and experiment) to compensate for the delay and trigger on the next half-cycle.

P.P.S.
Actually, a single rectifier (diode) should work...  Once you find a zero crossing, you know exactly when the next one is coming...

#### AndrewStone

#2
##### Jan 25, 2012, 10:32 pm
I haven't done it but I'd recommend you buy a commercial dimmer switch and then hack it to fake the pot via the Arduino (use a PWM with cap smoothing maybe?)  In fact if you really want safe-but-ugly, you could drive a servo that turns the dial.  That way you are less likely to burn your house down or electrocute yourself :-).

#### Mathurm

#3
##### Jan 26, 2012, 03:44 am
i'm doing something similar with a kiln controller where i need to switch 240V / 80A   what i'm doing there is running the mains into a high power zero crossing relay and the arduino will supply 5V to the DC control pins of the relay which contains the triac that DVDoug mentioned.

might work for you, at 60 Hz you should get full power (US).  you could flicker the on/off rate to control dimming like a PWM.

you'd basically chop up the AC signal so over X time you'd decrase the on/off time per X time division.  (depending on the response time of the relay)

so you'd ramp from 0%on/30ms (for example) to 25% on per unit time to 50% on per unit time to 75% and 100% for 1:30ms  (i don't know how this would work for a zero crossing relay, you might only be able to turn on at the zero crossing in which case such a plan wouldn't work (unless you spread the chopping scheme over many times the response time of the relay.

hope that helps. i'm a newbie at this myself  i've worked with something that did this with heaters and it worked... not sure about spotlights

#### Stokone

#4
##### Jan 26, 2012, 06:24 pm
First of all, thank to all
Quote
That way you are less likely to burn your house down or electrocute yourself :-).

ahahaha maybe i'm trying to burn my home! ahaha i thought something more simple... for example.. if is a problem drive 220 AC ... I can switch to 220DC to drive it more simple... and, because it's a lamp, i think that it don't really need the AC power (the DC have to be the same).. the light it's like this

I'm a newbie and the dimmer solution it's too hard for me

....and if i try with a mosfet (in DC) or with a solid state relay (in AC)?

#### Stokone

#5
##### Jan 28, 2012, 05:34 pm
I've found this: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1276992650

I thought that it was more complicated...