AC phase control Q6015L5 markings

60hz 120VAC in US
I am working on this AC phase controll circuit and am having an issue with the voltage output to the load (which is a light bulb right now). I get a clean zero cross signal, and a clean signal from the Arduino to the MOC triac driver. My triac output ranges from 18V to 38V AC.

Due to o-scope issues, I am unable to see the triac input or output signal, so these measures are from a DVM. I will try to troubleshoot until I get my scope taken care of and can see more information.

Additionally, the max voltage of 38V occurs at what seems to be in the middle of the AC half cycle, as opposed to at the beginning of the AC half cycle. If I increase the PULSE value from 4 counts to 8 counts, the max voltage goes up by about a volt. The minimum of 17V occurs at the end of the half cycle, as expected. At the beginning, the value is about 23V. (Beginning would be to the far left on the scope shot, and end would be just before the green zero cross signal on the right side)
See attached scope shot (in a follow up post) of the approximate location of the max voltage.

I have tried two different Q6015L5 devices. and two different MOC devices. On the Q60, I am not certain which pin is the gate / non-isolated tab. I don't see the markings described in the data sheet. I believe the right most pin when looking at the front is the gate (with text being read from left to right). Pictures of a device and the data sheet are attached.

I am using a standard bread board and it is hard to get the Q60 inserted, but it is fully inserted. Could there be a connection issue with the Q60?

Here is the scope shot

ACphase_maxV.png

Hi,
478642b0e9a94e5119b37826a22b8e251896ffde.png

X and Y scale setting?

What is the scope trace of?
Yellow trace?
Green trace?
Scope gnd reference is?

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
A picture of your project will help.

Can you please post a copy of your sketch, using code tags?
They are made with the </> icon in the reply Menu.
See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

Tom... :slight_smile:

Circuit can be found at the link in the opening post (AC phase control)
Channel B green is the zero cross detection - H11AA1
Channel A yellow is the Arduino signal to the triac driver (MOC...), output defined by the timer compare and overflow.
1V per division
1ms per division

Those signals look good. The yellow trace is showing the 'triac on' point which corresponds to the DVM measuring the highest voltage - it is closer to the center of the voltage half cycle. It should be at the beginning, unless my DVM is not capable. I do need to scope the AC voltage signals - have to purchase some additional hardware or a different scope since mine (bit scope) does not accept >50V. I don't want this to be a wild goose chase, but if anyone has seen this issue (max V at 1/4 cycle instead of 1/2 cycle), and can comment on having connection issues using breadboard for 120VAC and chunky Q60 leads, that would be appreciated.

I am running the below code.

//PID loop include statements
  #include <PID_v1.h>

// #define PIN_INPUT A0
//  #define PIN_OUTPUT 3  now connected to AC Phase control

//Define Variables we'll be connecting to
  double Setpoint, Input, Output;

//Specify the links and initial tuning parameters
  double Kp=1, Ki=.5, Kd=0;
  PID myPID(&Input, &Output, &Setpoint, Kp, Ki, Kd, REVERSE);

// photoresistor for testing purposes only
//int sensorValue;
//int sensorLow = 1023;
//int sensorHigh = 0;


// AC Control V1.1
//
// This arduino sketch is for use with the heater 
// control circuit board which includes a zero 
// crossing detect fucntion 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 truns 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(){

  Serial.begin(9600);

//  pinMode(PIN_INPUT, INPUT); 
//  while (millis() < 5000)    // for photoresistor testing only
//    {
//      sensorValue = analogRead(PIN_INPUT);
//      if (sensorValue > sensorHigh) {
//        sensorHigh = sensorValue;
//      }
//      if (sensorValue < sensorLow){
//      sensorLow = sensorValue;
//      }
//    }



  // set up pins
  pinMode(DETECT, INPUT);     //zero cross detect   INPUT_PULLUP
//  digitalWrite(DETECT, HIGH); //enable pull-up resistor
  pinMode(GATE, OUTPUT);      //triac gate control

  // set up Timer1 
  //(see ATMEGA 328 data sheet pg 134 for more details)
  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


  //Set up the PID loop
  //initialize the variables we're linked to
  //  Input = 145;
  //  Setpoint = 225;

  //turn the PID on
  //  myPID.SetMode(AUTOMATIC);
  
//    SetOutputLimits()
//    SetTunings()
//    SetSampleTime()



}  

//Interrupt Service Routines

void zeroCrossingInterrupt(){ //zero cross detect   
  TCCR1B=0x04; //start timer with divide by 256 input
  TCNT1 = 0;   //reset timer - count from zero     TCNT1 is the Timer/counter Register for timer 1
}

ISR(TIMER1_COMPA_vect){ //comparator match
  digitalWrite(GATE,HIGH);  //set triac gate to high

Serial.println(TCNT1);

  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

//Serial.print("             on");
//Serial.println("     ");



}

void loop(){ // sample code to exercise the circuit

//use photoresistor for input for testing only
//sensorValue = analogRead(PIN_INPUT);
//Input = map(sensorValue,sensorLow,sensorHigh, 0, 255);



//PID calculation
//  Input = analogRead(PIN_INPUT);
//  myPID.Compute();
//  analogWrite(PIN_OUTPUT, Output);    now feeds to the AC Phase control

i--;
OCR1A = i;     //set the compare register brightness desired.
if (i<25){i=483;}                      
delay(150);   

//OCR1A = 110;

//  OCR1A = map(Output,0,255, 0, 521);   //send the PID value to the triac

//Serial.print(sensorValue);
//Serial.print("     ");
//Serial.print(Input);
//Serial.print("     ");
//Serial.print(i);
//Serial.print("     ");
//Serial.print(OCR1A);
//Serial.println("     ");



}

The yellow trace is showing the 'triac on' point which corresponds to the DVM measuring the highest voltage - it is closer to the center of the voltage half cycle. It should be at the beginning, unless my DVM is not capable.

The position of the yellow trace will depend on the value of OCR1A which sets the delayed turn of after zero crossing. What was the value of OCR1A which showed the yellow trace at the center of the voltage half cycle?

Your code shows a sweep between 25 and 483.
Can you see the yellow trace move its position between the two zero crossing pulses as the sweep is running.

Hi,
Can you try the code that they supplied, to see if your hardware is correct?
Code supplied:

// AC Control V1.1
//
// This arduino sketch is for use with the heater 
// control circuit board which includes a zero 
// crossing detect fucntion 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 truns 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 
  //(see ATMEGA 328 data sheet pg 134 for more details)
  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);                             

}

Tom... :slight_smile:

OCR1A is approximately 215 when the max voltage occurs. The center is at approximately 260 (as it should be if there are 520 counts in a 1/2 cycle).

483 (7.728ms) represents a 'late in the cycle' point, and 25 an early point in the 1/2 cycle of 60hz. These numbers can change, and will be the output of a PID loop in the future, for heater control.

The yellow trace does sweep. Alternately, I can set it to a static value by commenting and uncommenting. Other test set ups use a potentiometer.

Tom:
I cannot use the code as is. I was unable to get the zero crossing with the internal Arduino pull-up resistor, so I added my own resistor and made the input pin simply INPUT.
So I copied what you supplied, which is what I used originally, and pasted into a new sketch, commented out the pull-up command, and ran it. Same results. Comparing my code to the original you supplied: they are the same with the exception of the pull-up resistor command, and me changing the OCR1A value for testing purposes.

I believe I got the zero-crossing and arduino output to MOC working properly (e.g. The Q60 data sheet indicates <10 micro-seconds needed for gate time (Tgt given as 4). The original codes gives 64 micro-seconds. Moving the gate time around does not really change the output voltage.)

Will get a scope and get more data.

I would not trust the DMM voltage values. What kind of DMM do you have?

Most Low end DMM RMS algorithms are based on pure sine waves. The chopped waveform you feed it is no going to give accurate results.

You need something called a True-RMS meter.

Your scope will resolve all confusion.

Hi,
With the example code did you see the code make the gate pulse move /cycle in position wrt zero crossing pulse?
What model arduino controller are you using?
Tom... :slight_smile:

yelkenli:
I have tried ... two different MOC devices. On the Q60, I am not certain which pin is the gate / non-isolated tab. I don't see the markings described in the data sheet.

Not all "MOC devices" are alike. Some are for random firing and the others are zero-cross, not interchangeable.

The Q6015 lead out is: MT1 - MT2 - Gate. The tab is also MT2. MT1 and MT2 are not interchangeable.

Hi,
Have you measured the output, with a load?
Say a desk lamp?
TRIACs only work when conducting current.

Tom.... :slight_smile:

Markings indicate "standard triac" in TO-220L packaging.
Pancake confirms I have the correct pin for the gate.
The data sheet confirms the gate pulse should be more than adequate.
I have tried this with a table lamp, i.e. under load.
The rest of the circuit works as expected - the gate signal moves with respect to the zero crossing depending on what I have programmed.

So there is either a poor connection (e.g. the large Q60 pins damaged the breadboard) or some other issue a scope will identify. Will have to wait till I take care of the scope issue.

Do protoboards have holes big enough for these Q60 devices? I am interested in soldering the circuit anyhow (breadboard connections seem loose, though the circuits work, present one excepted).

perf-boards

Runaway Pancake makes an excellent point in reply #9 about M1 and M2 not being interchangeable.

Are you certain that you followed the schematic in the ACphase control tutorial which shows M2 and pin 6 of the optocoupler both on Line and M1 of the triac going out to load.

I did have MT1 and MT2 reversed, and have corrected that.
I was able to get the circuit to work, however, my 1.5k ohm resistor burned up - I turned off the power when first seeing the smoke. But my incandescent desk lamp would dim and brighten as the compare register changed.
I checked the resistance of the burned resistor with an ohm meter and it was still showing 1.48k ohms.

I replaced the resistor, and got it to work again. Need to check the circuit more closely.

Thanks!!

Hi,
So do you still have a problem?

Tom.. :slight_smile:

Hi,
Post #2 asked for a picture.
That could have indicated MT1 and MT2 interchanged.

Can we have a picture of your project layout?

Thanks.. Tom... :slight_smile:

I must have had two different wiring issues, but they are resolved and the circuit is working properly.

I have run into another issue that looks like the Q60 does not fire on all 1/2 cycles. That could be in software. I will post a different thread for that, and might post after I get some scope shots.

I am working on a schematic layout of what I have breadboarded, and plan to get a cost on a custom PCB (they seem cheap - $10?). At the very least, a solderable protoboard.

I will post the circuit when I complete the drawing only handwritten now; anyhow, the project is based on the Arduino library circuits. I will take a picture of the breadboard tomorrow (packed for traveling home).

Thanks!!
Ted

Attached is a schematic of the design. several of the terminations, such as the 120V terminations, will be two pin connector blocks, but I have not figured out how to find the part and put it on the schematic.

And a picture. I have not connected the LCD, and therefore it is using power and signal transfer based on Marconi and Tesla.

The extra potentiometer is for testing the ac phase control.

IncubatorSchematic.pdf (50.4 KB)