controlling AC phase (AC dimming light)

Talk about Arduino board, sheilds. Sharing Arduino projects, program, problems, solutions, suggestions..... many more, all are welcome.

Re: controlling AC phase (AC dimming light)

Postby ABSF » Mon Feb 27, 2012 3:43 pm

Guess you must have seen the youtube movie that used the opto with zero crossing.
http://www.youtube.com/watch?v=5tt4zAkp ... re=related

In the circuit I posted it just uses MOC3021 without the ZCC built in.

fitri WROTE:to dim the light am i need to use Digital Output?
are the program i need to is some kind like this :
eg: 50% dim
on signal 10ms
off signal 10ms


Yes the digital output would control the MOC3021 input.
Yes, ON 10ms and OFF 10ms for 50Hz supply. But it has to synchronise with the AC at the pulse of GP2. Like this

1. Poll the pulse at GP2
2. Once detected L->H on GP2
3. H on opto 10ms
4. L on opto 10ms
5. Loop back to 1.

Allen
The next war will determine NOT who is right BUT what is left.
User avatar
ABSF
Professional
 
Posts: 810
Joined: Wed Nov 10, 2010 9:32 am
Location: E Malaysia

Re: controlling AC phase (AC dimming light)

Postby fitri » Mon Feb 27, 2012 4:36 pm

Hi, thx!! :P
i think i understand now, next few day i will try to get those hardware and try to construct it. will update the progress here.

thanks again :P
fitri
Apprentice
 
Posts: 42
Joined: Mon May 02, 2011 8:20 pm

Re: controlling AC phase (AC dimming light)

Postby ABSF » Tue Feb 28, 2012 9:54 am

The picture attached is a simulation of the circuit in proteus

ac dimmer.JPG
AC dimmer circuit

Opening this picture on another window will see the waveform clearer

From the Oscope, you can see that

Wav1 - after full bridge rectification
Wav2 - after the RC network
Wav3 - At the collector of the transistor
Wav4 - The AC before rectifiers.

The pulses are 10 ms apart becos after the rectifier, both the positive and negative phases are rectified to become 100Hz positive pulses. If your program doesnt work properly, just change it to 5ms ON and 5ms OFF. More will be discussed after you constructed your circuit on how to improve your program using PWM and interrupt techniques.

Allen
The next war will determine NOT who is right BUT what is left.
User avatar
ABSF
Professional
 
Posts: 810
Joined: Wed Nov 10, 2010 9:32 am
Location: E Malaysia

Re: controlling AC phase (AC dimming light)

Postby fitri » Tue Mar 06, 2012 8:24 am

Hi,
I'm back..huhu..a bit busy lately..

ok..now to update on this AC dimming..
i already construct the circuit. for on off the light seem there is no problem..
so i try to dim it..
but the light is blinking(in fast rate)
is this problem because of delay time?
:?:
or about the zero-crossing? not really understand the zero-crossing
:?:

below are program i tested

int buttonStateon = 0; // variable for reading the pushbutton status
int buttonStateoff = 0;

void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPinon, INPUT);
pinMode(buttonPinoff, INPUT);

}

void loop(){
// read the state of the pushbutton value:
buttonStateon = digitalRead(buttonPinon);
buttonStateoff = digitalRead(buttonPinoff);

// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonStateon == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
delay(5);
digitalWrite(ledPin, LOW);
delay(5);
}
if (buttonStateoff == HIGH) {
digitalWrite(ledPin, HIGH);
delay(3);
digitalWrite(ledPin, LOW);
delay(5);
}
}
fitri
Apprentice
 
Posts: 42
Joined: Mon May 02, 2011 8:20 pm

Re: controlling AC phase (AC dimming light)

Postby ABSF » Tue Mar 06, 2012 9:18 am

OK...Since you're controlling LED in DC, then try below. This should reduce the flikering. 8-)

void loop(){
// read the state of the pushbutton value:
buttonStateon = digitalRead(buttonPinon);
buttonStateoff = digitalRead(buttonPinoff);

// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonStateon == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
delay(5); delayMicroseconds(1000);
digitalWrite(ledPin, LOW);
delay(5); delayMicroseconds(1000);
}
if (buttonStateoff == HIGH) {
digitalWrite(ledPin, HIGH);
delay(3); delayMicroseconds(600);
digitalWrite(ledPin, LOW);
delay(5); delayMicroseconds(1400);
}
}


Allen
The next war will determine NOT who is right BUT what is left.
User avatar
ABSF
Professional
 
Posts: 810
Joined: Wed Nov 10, 2010 9:32 am
Location: E Malaysia

Re: controlling AC phase (AC dimming light)

Postby fitri » Tue Mar 06, 2012 10:03 am

Hi, ouch...sorry..
actually i'm controlling ac light..wrong variable name..
fitri
Apprentice
 
Posts: 42
Joined: Mon May 02, 2011 8:20 pm

Re: controlling AC phase (AC dimming light)

Postby fitri » Tue Mar 06, 2012 10:25 am

fitri WROTE:Hi, ouch...sorry..
actually i'm controlling ac light..wrong variable name..


void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
buttonStateoff = digitalRead(buttonPinoff);

// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn AClight on:
digitalWrite(acPin, HIGH);
delay(5);
digitalWrite(acPin, LOW);
delay(5);
}
if (buttonStateoff == HIGH) {
digitalWrite(acPin, HIGH);
delay(3);
digitalWrite(acPin, LOW);
delay(5);
}
}
fitri
Apprentice
 
Posts: 42
Joined: Mon May 02, 2011 8:20 pm

Re: controlling AC phase (AC dimming light)

Postby ABSF » Tue Mar 06, 2012 11:02 am

fitri WROTE:Hi,
ok..now to update on this AC dimming..
i already construct the circuit. for on off the light seem there is no problem..
so i try to dim it..
but the light is blinking(in fast rate)
is this problem because of delay time?
:?:
or about the zero-crossing? not really understand the zero-crossing
:?:


The AC is 50Hz, so if you dont synchronise with it at a fixed point when cutting the sine wave, it can be anywhere of the 360 degrees of the waveform. That of course would cause flikering.

Zero crossing is the place where the pos phase crosses the x-axis when going to the neg phase. It is the same position when the GP2 pulse occurs. So modify you software to syn with GP2 as I've said in my pseudocode.

Allen
The next war will determine NOT who is right BUT what is left.
User avatar
ABSF
Professional
 
Posts: 810
Joined: Wed Nov 10, 2010 9:32 am
Location: E Malaysia

Re: controlling AC phase (AC dimming light)

Postby fitri » Tue Mar 06, 2012 9:24 pm

Hi..
already try this program


const int buttonPin1 = 2; // the number of the pushbutton pin
const int buttonPin2 = 3;
const int acPin = 13; // the number of the LED pin

// variables will change:
int buttonState1 = 0; // variable for reading the pushbutton status
int buttonState2 = 0;

void setup() {

pinMode(acPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);

}

void loop(){

buttonState1 = digitalRead(buttonPin2);
buttonState1 = digitalRead(buttonPin2);


if (buttonState1 == HIGH) {

digitalWrite(acPin, HIGH);
delayMicroseconds(1000);
//digitalWrite(acPin, LOW);
//delayMicroseconds(1000);
}
if (buttonState2 == HIGH) {
digitalWrite(acPin, HIGH);
delayMicroseconds(600);
digitalWrite(acPin, LOW);
delayMicroseconds(1400);
}
}

how can i dim it 0%-100% ?
how to sync the zero crossing?
what is the purpose of the interupt button?
http://www.youtube.com/watch?v=6zTtBA0Z ... re=related
fitri
Apprentice
 
Posts: 42
Joined: Mon May 02, 2011 8:20 pm

Re: controlling AC phase (AC dimming light)

Postby ABSF » Wed Mar 07, 2012 6:20 am

void setup() {
// initialize the LED pin as an output:
pinMode(acPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPinon, INPUT);
pinMode(buttonPinoff, INPUT);
pinMode(GP2, INPUT);
BYTE pulse=0 //define pulse as 8 bit

}

void loop(){
// read the state of the pushbutton value:
buttonStateon = digitalRead(buttonPinon);
buttonStateoff = digitalRead(buttonPinoff);

// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonStateon == HIGH) {
// turn Lamp on:
pulse=digitalRead(GP2);
if (pulse == LOW)
{
while (pulse == LOW) continue; //wait for pulse to turn HIGH
digitalWrite(acPin, HIGH);
delay(5);
digitalWrite(acPin, LOW);
delay(5);
}
}
if (buttonStateoff == HIGH) {
pulse=digitalRead(GP2);
if (pulse == LOW)
{
while (pulse == LOW) continue; //wait for pulse to turn HIGH
digitalWrite(acPin, HIGH);
delay(3);
digitalWrite(acPin, LOW);
delay(7);
}
}
}



I am not good in C language. I use the cytron example for detecting a push button to poll the GP2 pulse. Not sure if the flow is correct. Any one with C experience care to give him a hand?

Allen
The next war will determine NOT who is right BUT what is left.
User avatar
ABSF
Professional
 
Posts: 810
Joined: Wed Nov 10, 2010 9:32 am
Location: E Malaysia

PreviousNext

Return to Arduino Based

Who is online

Users browsing this forum: No registered users and 11 guests

cron