Arduino AC 8CH Dimmer Lights

About: Electronic, Arduino, Raspberry, Photography, Model Train Entusiat

This project describes how to control with Arduino microcontroller an 8CH AC board by using zero-cross detection and firing angle method to dimm incandescent or alogen light bulbs and create light effects.

Warning: This project deals with AC electricity which is dangerous if you don’t know how to treat it safely.
You must treat electricity with caution!

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Prerequisites #1

The 8CH AC Module is a module with 8 Triacs with zero-cross detector for control the intensity of incandescent or alogen lamps through a microcontroller.

I used the Krida Electronics 8 CHANNEL DIGITAL LIGHT DIMMER V3 with zero-cross detector

(http://www.inmojo.com/store/krida-electronics/item... )

The board has the following main characteristics:

- Working AC voltage 80v to 240v

- Connected LOAD current for each channel 2A long-term, short-term 5A.
NOT appropriate to change the brightness of fluorescent lamps !!!

- Auto detect 50Hz or 60Hz.

- Zero-Cross detection (with zero/cross output pin SYNC).

- Low voltage side and high voltage side is completely isolated.

- Compatible with any ARDUINO, RASPBERRY boards.

Step 2: Prerequisites #2

For this project you need also:

Arduino microcontroller (I used Arduino UNO compatible board);

Some Dupont wires to connect the Arduino to the Krida terminals;

Some wires (1.5mm section) to connect the output load terminals of the 8CH AC Krida board to your incandescent or alogen lamps.

Wiring connection is available here:

https://drive.google.com/file/d/0B6GJokXFb5oETWFfd...

To connect Arduino board to the Krida board:

GND - > GND
VCC -> 5V

SYNC -> DIGITAL.3 (zero-cross detector output positive impulse - pulse length 200us)

CH1 -> DIGITAL.4

CH2 -> DIGITAL.5

CH3 -> DIGITAL.6

CH4 -> DIGITAL.7

CH5 -> DIGITAL.8

CH6 -> DIGITAL.9

CH7 -> DIGITAL.10

CH8 -> DIGITAL.11

To connect the Krida board to the AC power input and 8CH output:

AC INPUT -> AC voltage input 110/220 50-60Hz
AC LOAD -> Connect your load here for 1ch, 2ch, 3ch, 4ch, 5ch, 6ch, 7ch and 8ch (2A)

To power on the Krida board:

GND -> ground of low voltage side
VCC -> device power, DC 5 volts

Step 3: The Code

To obtain light effects (200V - 50Hz) as shown in the video the Arduino IDE code is provided:

https://create.arduino.cc/editor/Gianvi826/5c1c819...

#include
unsigned char channel_1 = 4; // Output to Opto Triac pin, channel 1 unsigned char channel_2 = 5; // Output to Opto Triac pin, channel 2 unsigned char channel_3 = 6; // Output to Opto Triac pin, channel 3 unsigned char channel_4 = 7; // Output to Opto Triac pin, channel 4 unsigned char channel_5 = 8; // Output to Opto Triac pin, channel 5 unsigned char channel_6 = 9; // Output to Opto Triac pin, channel 6 unsigned char channel_7 = 10; // Output to Opto Triac pin, channel 7 unsigned char channel_8 = 11; // Output to Opto Triac pin, channel 8 unsigned char CH1, CH2, CH3, CH4, CH5, CH6, CH7, CH8; unsigned char CHANNEL_SELECT; unsigned char i = 0; unsigned char clock_tick; // variable for Timer1 unsigned int delay_time = 50; unsigned int delay_time2 = 100; unsigned char low = 75; // luce massima unsigned char high = 55; // luce minima unsigned char off = 95; // totalmente accesa int lux = 75; // limite luce minima int lux2 = 85; // limite luce massima

unsigned char CH[] = {CH1, CH2, CH3, CH4, CH5, CH6, CH7, CH8};

void setup() {

// CH1=CH2=CH3=CH4=CH5=CH6=CH7=CH8=high;

pinMode(channel_1, OUTPUT);// Set AC Load pin as output pinMode(channel_2, OUTPUT);// Set AC Load pin as output pinMode(channel_3, OUTPUT);// Set AC Load pin as output pinMode(channel_4, OUTPUT);// Set AC Load pin as output pinMode(channel_5, OUTPUT);// Set AC Load pin as output pinMode(channel_6, OUTPUT);// Set AC Load pin as output pinMode(channel_7, OUTPUT);// Set AC Load pin as output pinMode(channel_8, OUTPUT);// Set AC Load pin as output attachInterrupt(1, zero_crosss_int, RISING); Timer1.initialize(100); // set a timer of length 100 microseconds for 50Hz or 83 microseconds for 60Hz; Timer1.attachInterrupt( timerIsr ); // attach the service routine here

}

void timerIsr() { clock_tick++;

if (CH1 == clock_tick) { digitalWrite(channel_1, HIGH); // triac firing delayMicroseconds(5); // triac On propogation delay (for 60Hz use 8.33) digitalWrite(channel_1, LOW); // triac Off }

if (CH2 == clock_tick) { digitalWrite(channel_2, HIGH); // triac firing delayMicroseconds(5); // triac On propogation delay (for 60Hz use 8.33) digitalWrite(channel_2, LOW); // triac Off }

if (CH3 == clock_tick) { digitalWrite(channel_3, HIGH); // triac firing delayMicroseconds(5); // triac On propogation delay (for 60Hz use 8.33) digitalWrite(channel_3, LOW); // triac Off }

if (CH4 == clock_tick) { digitalWrite(channel_4, HIGH); // triac firing delayMicroseconds(5); // triac On propogation delay (for 60Hz use 8.33) digitalWrite(channel_4, LOW); // triac Off }

if (CH5 == clock_tick) { digitalWrite(channel_5, HIGH); // triac firing delayMicroseconds(5); // triac On propogation delay (for 60Hz use 8.33) digitalWrite(channel_5, LOW); // triac Off }

if (CH6 == clock_tick) { digitalWrite(channel_6, HIGH); // triac firing delayMicroseconds(5); // triac On propogation delay (for 60Hz use 8.33) digitalWrite(channel_6, LOW); // triac Off }

if (CH7 == clock_tick) { digitalWrite(channel_7, HIGH); // triac firing delayMicroseconds(5); // triac On propogation delay (for 60Hz use 8.33) digitalWrite(channel_7, LOW); // triac Off }

if (CH8 == clock_tick) { digitalWrite(channel_8, HIGH); // triac firing delayMicroseconds(5); // triac On propogation delay (for 60Hz use 8.33) digitalWrite(channel_8, LOW); // triac Off }

}

void zero_crosss_int() // function to be fired at the zero crossing to dim the light { // Every zerocrossing interrupt: For 50Hz (1/2 Cycle) => 10ms ; For 60Hz (1/2 Cycle) => 8.33ms // 10ms=10000us , 8.33ms=8330us

clock_tick = 0; }

void loop() {

// CICLO 3 ********************************************************

for (i = lux; i < lux2; i++) { CH1 = i; delay(delay_time); }

for (i = lux2; i > lux; i--) { CH1 = i; delay(delay_time); }

for (i = lux; i < lux2; i++) { CH2 = i; delay(delay_time);

}

for (i = lux2; i > lux; i--) { CH2 = i; delay(delay_time); }

for (i = lux; i < lux2; i++) { CH3 = i; delay(delay_time); }

for (i = lux2; i > lux; i--) { CH3 = i; delay(delay_time); }

for (i = lux; i < lux2; i++) { CH4 = i; delay(delay_time); }

for (i = lux2; i > lux; i--) { CH4 = i; delay(delay_time); }

for (i = lux; i < lux2; i++) { CH5 = i; delay(delay_time); }

for (i = lux2; i > lux; i--) { CH5 = i; delay(delay_time); }

for (i = lux; i < lux2; i++) { CH6 = i; delay(delay_time); }

for (i = lux2; i > lux; i--) { CH6 = i; delay(delay_time); }

for (i = lux; i < lux2; i++) { CH7 = i; delay(delay_time); }

for (i = lux2; i > lux; i--) { CH7 = i; delay(delay_time); }

for (i = lux; i < lux2; i++) { CH8 = i; delay(delay_time); }

for (i = lux2; i > lux; i--) { CH8 = i; delay(delay_time); }

// ****************************************************************

// CICLO 4 *******************************************************

for (i = lux; i < lux2; i++) { CH7 = i; delay(delay_time);

}

for (i = lux2; i > lux; i--) { CH7 = i; delay(delay_time); }

for (i = lux2; i < 75; i++) { CH6 = i; delay(delay_time); }

for (i = lux2; i > lux; i--) { CH6 = i; delay(delay_time); }

for (i = lux; i < lux2; i++) { CH5 = i; delay(delay_time); }

for (i = lux2; i > lux; i--) { CH5 = i; delay(delay_time); }

for (i = lux; i < lux2; i++) { CH4 = i; delay(delay_time); }

for (i = lux2; i > lux; i--) { CH4 = i; delay(delay_time); }

for (i = lux; i < lux2; i++) { CH3 = i; delay(delay_time); }

for (i = lux2; i > lux; i--) { CH3 = i; delay(delay_time); }

for (i = lux; i < lux2; i++) { CH2 = i; delay(delay_time); }

for (i = lux2; i > lux; i--) { CH2 = i; delay(delay_time); }

// ****************************************************************

}

Step 4: AC Dimmer and More

You can use the 8CH Krida board also to control (sequencing) lights without dimming them.

In this scase no zero-crossing method was used and I made a K.I.T.T. Knight rider Effect

Here is the code:

// 8CH AC -
const int cb0=1; const int cb1=2; const int cb2=4; const int cb3=8; const int cb4=16; const int cb5=32; const int cb6=64; const int cb7=128; const int cb8=256; const int cb9=512;

void setup() { // initializzo i 10 piedini come uscite for (int i=4;i<12;i++) pinMode(i, OUTPUT); Serial.begin(9600); }

void Uscita(int valore) { if((valore&cb0)>0) digitalWrite(4,HIGH); else digitalWrite(4,LOW); if((valore&cb1)>0) digitalWrite(5,HIGH); else digitalWrite(5,LOW); if((valore&cb2)>0) digitalWrite(6,HIGH); else digitalWrite(6,LOW); if((valore&cb3)>0) digitalWrite(7,HIGH); else digitalWrite(7,LOW); if((valore&cb4)>0) digitalWrite(8,HIGH); else digitalWrite(8,LOW); if((valore&cb5)>0) digitalWrite(9,HIGH); else digitalWrite(9,LOW); if((valore&cb6)>0) digitalWrite(10,HIGH); else digitalWrite(10,LOW); if((valore&cb7)>0) digitalWrite(11,HIGH); else digitalWrite(11,LOW);

}

const int nro=23; int valo[nro]= { // elenco dei valori del foglio elettronico 1,3,7,14,28,56,112,224,448,896,768,512, 768,896,448,224,112,56,28,14,7,3,1 };

void loop() { for(int i=0; i

Be the First to Share

    Recommendations

    • Instrument Contest

      Instrument Contest
    • Make it Glow Contest

      Make it Glow Contest
    • STEM Contest

      STEM Contest

    Discussions