trungbeca
Newbie level 4
Hello everyone. Firstly, I have to say sorry if my description is hard to understand because my first language is not English.
This is my AC phase control + zero_crossing circuit:
As you can see above, the output "Zero_crossing" and the input "PWM" connected to my Arduino Uno . and here is my program is wrote for Arduino:
My idea is: when zero_crossing is detected, go to the sub_program name "xung_dk". disable the timer1 by set CS11 bit = 0. set the BOTTOM value and COMPARE value again. then set CS11 = 1. Timer1 will count from BOTTOM to COMPARE value, OC1A pin (pin 9 Arduino) will be set LOW and open the TRIAC. TRIAC will be close on next zero_crossing.
If i set the open angle (alpha in Arduino program) less 30 or over 140, system will work normally, no complaint.
The problem here: when i set alpha from 30 to 140, zero_crossing will go wrong if i connect LOAD (Thermal Resistance) to AC output (picture 1) so PWM wrong also but no LOAD no problem. as you can see pictures below:
- channel 1 (yellow): Zero_crossing signal
- channel 2 (blue): PWM signal
- alpha: 60
LOAD Thermal resistance is not connected:
or:
and when Thermal resistance is connected
or AC wave ouput:
I don't know how they come and how to solve these. Hope to get your answers soon.
Thanks a lot for reading!
This is my AC phase control + zero_crossing circuit:
As you can see above, the output "Zero_crossing" and the input "PWM" connected to my Arduino Uno . and here is my program is wrote for Arduino:
Code:
#include <avr/interrupt.h>
#define pin_interrupt 3 // zero_crossing detect
#define pin_pwm 9 // PWM pin out
volatile float alpha = 30; // open angle, alpha = 0: OFF, alpha = 180: OPEN 100%
void setup() {
pinMode(pin_pwm,OUTPUT);
pinMode(pin_interrupt,INPUT);
attachInterrupt(digitalPinToInterrupt(pin_interrupt), xung_dk, RISING);
TCCR1A = 0;
TCCR1B = 0;
TIMSK1 = 0;
ICR1 = 19200; // TOP value, 10ms*16Mhz/prescaler = 20000
OCR1A = 19200;
TCCR1A |= (1 << COM1A1)|(1 << WGM11); // mode 14
TCCR1B |= (1 << WGM12)|(1 << WGM13); // mode 14,fast PWM
}
void loop() {
}
void xung_dk(){
TCCR1B &= ~(1 << CS11); // disable prescaler
TCNT1 = 0; // BOTTOM value
OCR1A = (int)(20000*(1-(alpha/180.0))); // Compare value
TCCR1B |= (1 << CS11); //prescaler = 8
}
My idea is: when zero_crossing is detected, go to the sub_program name "xung_dk". disable the timer1 by set CS11 bit = 0. set the BOTTOM value and COMPARE value again. then set CS11 = 1. Timer1 will count from BOTTOM to COMPARE value, OC1A pin (pin 9 Arduino) will be set LOW and open the TRIAC. TRIAC will be close on next zero_crossing.
If i set the open angle (alpha in Arduino program) less 30 or over 140, system will work normally, no complaint.
The problem here: when i set alpha from 30 to 140, zero_crossing will go wrong if i connect LOAD (Thermal Resistance) to AC output (picture 1) so PWM wrong also but no LOAD no problem. as you can see pictures below:
- channel 1 (yellow): Zero_crossing signal
- channel 2 (blue): PWM signal
- alpha: 60
LOAD Thermal resistance is not connected:
or:
and when Thermal resistance is connected
or AC wave ouput:
I don't know how they come and how to solve these. Hope to get your answers soon.
Thanks a lot for reading!