Buenos días.
Mediante un zero crossing de una señal 220V AC quería controlar el disparo de 2 TRIACS para conectar a cada triac 1 bombilla de 220V (pudiendo variar su valor desde 0V a 220V).
Me gustaría que una bombilla tuviese un valor (elegido por nosotros mediante el disparo del triac antes o despues en el semiperiodo de la onda de 220V) independiente de la otra bombilla.
He encontrado este código de programa pero usa TIMERS Y COUNTERS y tras mirar el DATA SHEET del ATMEGA 328 no consigo entender el código:
// AC Control V1.1
//
// This Arduino sketch is for use with the heater
// control circuit board which includes a zero
// crossing detect function and an opto-isolated TRIAC.
//
// AC Phase control is accomplished using the internal
// hardware timer1 in the Arduino
//
// Timing Sequence
// * timer is set up but disabled
// * zero crossing detected on pin 2
// * timer starts counting from zero
// * comparator set to "delay to on" value
// * counter reaches comparator value
// * comparator ISR turns on TRIAC gate
// * counter set to overflow - pulse width
// * counter reaches overflow
// * overflow ISR turns off TRIAC gate
// * TRIAC stops conducting at next zero cross
// The hardware timer runs at 16MHz. Using a
// divide by 256 on the counter each count is
// 16 microseconds. 1/2 wave of a 60Hz AC signal
// is about 520 counts (8,333 microseconds).
#include <avr/io.h>
#include <avr/interrupt.h>
#define DETECT 2 //zero cross detect
#define GATE 9 //TRIAC gate
#define PULSE 4 //trigger pulse width (counts)
int i=483;
void setup(){
// set up pins
pinMode(DETECT, INPUT); //zero cross detect
digitalWrite(DETECT, HIGH); //enable pull-up resistor
pinMode(GATE, OUTPUT); //TRIAC gate control
// set up Timer1
OCR1A = 100; //initialize the comparator
TIMSK1 = 0x03; //enable comparator A and overflow interrupts
TCCR1A = 0x00; //timer control registers set for
TCCR1B = 0x00; //normal operation, timer disabled
// set up zero crossing interrupt
attachInterrupt(0,zeroCrossingInterrupt, RISING);
//IRQ0 is pin 2. Call zeroCrossingInterrupt
//on rising signal
}
//Interrupt Service Routines
void zeroCrossingInterrupt(){ //zero cross detect
TCCR1B=0x04; //start timer with divide by 256 input
TCNT1 = 0; //reset timer - count from zero
}
ISR(TIMER1_COMPA_vect){ //comparator match
digitalWrite(GATE,HIGH); //set TRIAC gate to high
TCNT1 = 65536-PULSE; //trigger pulse width
}
ISR(TIMER1_OVF_vect){ //timer1 overflow
digitalWrite(GATE,LOW); //turn off TRIAC gate
TCCR1B = 0x00; //disable timer stopd unintended triggers
}
void loop(){ // sample code to exercise the circuit
i--;
OCR1A = i; //set the compare register brightness desired.
if (i<65){i=483;}
delay(15);
}
Tambien adjunto la imagen del circuito.
Alguien podría explicarmelo de forma sencilla como colocar en este programa un segundo TRIAC?
Muchas gracias,
Un saludo.
Moderador: Imagen editada