Go Down

Topic: Dimming AC lights (Read 8703 times) previous topic - next topic

Hugobox

Hi Arduinos,
I'd like to use the arduino with sensors to dim AC lights. I've never interfaced a microcontroller to dim AC and would like to know some tips and tricks and bypass the traps that you might have encountered while doing so.
Thanks!

tomski

I can recommend buying a  velleman K8064 dimmer kit as suggested by Massimo:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1150063488

it was really quick to get everything up & running...

oori

As someone who's gone the light&arduino path.. it only really ended when i bought dmx equipment..
which by itself is a fragile protocol, but as least it dims lamps easily..

I've also built the arduinoDmx (http://www.arduino.cc/playground/Learning/DMX)
it worked but i had a lot of sync problems with my dmx lamp - although to really debug these problems you
must have a dmx testing device, or at least some more dmx equipment to try on.

Ciao, oori

Hugobox

Hi Oori,
For this project, I wanted to control normal house lamps and not rely on DMX equipment.
I've gone the DMX way and had my share of DMX problems, btw search for my posts on DMX for a more precise code for Arduino DMX if your DMX lamps are picky.

also Thanks Tomski for the velleman kit reference.

jims

X10 with a "firecracker" controller? That should be easy to drive from an Arduino. You can get the firecracker, transceiver, hand held remote, and a dimmer for $20. Looks like extra dimmers go for about $10 each. Those are 110v 60hz units, I presume there are variants for folk with more deadly mains.

It looks like the firecracker works by using RTS and DTR as both power and signaling. I don't know if you'd have to drive them with more than 5v. http://www.rentron.com/FireCracker.htm As if I didn't have enough to do.. it looks interesting.

jeep1984

#5
Apr 09, 2009, 03:45 pm Last Edit: Apr 09, 2009, 03:46 pm by jeep1984 Reason: 1
Hi,

This might be a useful link for people trying to dim AC lights through a Velleman K8064 kit and an arduino:

http://www.brakmolotov.net/blog/Meriol_Lehmanns_blog/Entries/2009/2/23_How_to_control_an_AC_dimmer_with_an_Arduino.html

It includes sample code and circuit diagram, and it works.

Jaap

bHogan

@jims
I've already interfaced to the firecracker -
http://www.arduino.cc/playground/X10/CM17A
"Data is not information, information is not knowledge, knowledge is not understanding, understanding is not wisdom."
~ Clifford Stoll

Timothy9742

#7
May 11, 2009, 04:41 pm Last Edit: May 11, 2009, 04:43 pm by t.m.assman Reason: 1
Hi,

I used an Arduino and a Velleman K8064 to make my own WakeUpLight.

The electric circuit scheme of brakmolotov.net posted by jeep1984 above was very helpful, thanks!

Everything works fine, I've placed a movie on Youtube.

Code: [Select]

// Define pins

int pwmPin    = 9;    // select the output pin for the dimmer
int analogPin = 1;    // select the input pin for the alarmclock
int ledPin    = 13;   // select the pin for the LED

// Program variables

int pwmVal    = 0;     // Variable to store the value to send to the pin
int analogVal = 0;     // Variable to store the value read from the analog pin
int fadeCount = 0;     // Loop counter
int stopCount = 0;
int wait      = 250;   // 250ms delay; shorten for faster fades

void setup()
{
 pinMode(ledPin, OUTPUT);   // declare the ledPin as an OUTPUT
 pinMode(pwmPin, OUTPUT);   // sets the pins as output
 analogWrite(pwmPin,   pwmVal);   // Write current values to pwm pin
}


// Main program
void loop()
{
 analogVal = analogRead(analogPin);   // read the value from the sensor
 if (analogVal==0)                    // if no alarm beep is received
 {
   stopCount += 1;
 }
 else                           // if alarm beep is received
 {
   fadeCount += 1;
   stopCount = 0;
 }
 
 if (fadeCount==20 && pwmVal!=255)
 {
   fadeCount=0;
   pwmVal += 1;
   analogWrite(pwmPin,   pwmVal);   // Write current values to pwm pin
   digitalWrite(ledPin, HIGH);   // turn the ledPin on
 }
 else
 {
   digitalWrite(ledPin, LOW);   // turn the ledPin off
 }
 
 if (stopCount==60)
 {
   stopCount=0;
   fadeCount=0;
   pwmVal = 0;
   analogWrite(pwmPin,   pwmVal);   // Write current values to pwm pin
 }
 
   delay(wait); // Pause for 'wait' milliseconds before resuming the loop

}


Tim

fubbi

I have built the circuit exactly like in brakmolotov's example.

I can see the value going up and down between 0v and 5v nicely on pin 9 when I run his code.

But I am not getting past the transistor. When I measure at the output to the velleman I see a constant 6v

Any clues as to why this might be? Have I got something the wrong way around?

Thanks

here's the schematic


Grumpy_Mike

I noticed the schematic has a GND connection going to the Velleman. This is wrong it should go to the analogue input line on SK3. These are not the same as gnd on the Velleman

fubbi


Grumpy_Mike

Quote
SK3?


That's what it says on the data sheet.

fubbi

Hi Mike

I get what you mean, but not what it means...

The SK3 has "+" and "-" connectors, "-" is not ground?

thanks

fubbi

Grumpy_Mike

#13
Jun 25, 2009, 06:06 pm Last Edit: Jun 25, 2009, 06:06 pm by Grumpy_Mike Reason: 1
Quote
The SK3 has "+" and "-" connectors, "-" is not ground?


No it is the other side of an opto isolator. So it needs to be connected to this and not ground as shown in the diagram. In fact the 1M and capacitor are rubbish. But it will work if you connect what is marked gnd to the SK3 - and the 5V to the SK3 +


fubbi

most excellent sir

thank you

fubbi

Go Up