Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

My AC phase control circuit by Arduino has a weird problem??

Status
Not open for further replies.

trungbeca

Newbie level 4
Joined
Feb 26, 2013
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,326
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:
cs.PNG

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:
IMG00041-20160412-1055.jpg

or:
IMG00044-20160412-1057.jpg

and when Thermal resistance is connected

IMG00045-20160412-1057.jpg

or AC wave ouput:

IMG00047-20160412-1606.jpg

I don't know how they come and how to solve these. Hope to get your answers soon.
Thanks a lot for reading!
 

First of all...you don't do PWM on a sinewave with a Triac. You do phase control.

Very different control methods.

Also...your zero crossing circuit is unusual. Where did you get it from? Have you validated that its pulse output remains the same with/without load?
 
Last edited:
You are running the main code at the interrupt vector instead of within the loop() vector.
I'm not sure how this would affect the whole working, but it is quite unusual.
 

thank you very much schmitt trigger, i understood the different between PWM and Triac control. Your advice helped me so much to solve my problem

- - - Updated - - -

You are running the main code at the interrupt vector instead of within the loop() vector.
I'm not sure how this would affect the whole working, but it is quite unusual.

the above code is a small part of my program. if zero_crossing signal rise, timer1 will count from 0 to alpha and generate a pulse to control triac on exactly time i want.
the loop() vector doing other works such as Display, comunicate ...
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top