Using Zero-Cross Detect (ZCD) Peripheral for Triac Firing

Background:

Triacs are commonly used to chop AC waveforms to control the amount of average power to the intended load. The firing angle delay is the amount of time between the zero-cross of the AC signal and the time that the triac is turned on (T1 and T2 in figure below). To decrease the amount of power that is transferred to the load, the firing angle delay is increased. The microcontroller will turn on the triac and does not need to turn the triac off. The triac will turn itself off when the conduction current falls below the holding current level of the triac.

Problem:

When switching AC voltages, there could be in excess of 240V RMS that needs to be switched. The microcontroller is a much lower voltage device and needs to be isolated from this high voltage. Many engineers use external interface circuits to provide this isolation, such as opto-isolators, transistor circuits, etc… These external circuits will also introduce delays in the zero-cross detection.

Is there a way to use the Zero Cross Detector (ZCD) peripheral for the zero cross detection and control the delay?

Solution

The ZCD can quickly detect the zero-cross point of the AC signal and immediately notify the firmware that the zero-cross occurred. Interrupts can be set up to detect the rising and falling zero-cross edges that allow detection of the positive AC half cycle, negative half-cycle, or both. The ZCD works by providing a current to maintain a constant voltage on the pin. Therefore, it both sources and sinks a very small amount of current during the AC cycle. At any time during code execution, the firmware can detect if the ZCD is sinking or sourcing current and can determine if the AC is in the positive or negative half cycle.

Plus, with the ZCD, only a resistor is needed to provide this isolation. This reduces in the number of external components required and also lowers the cost of the circuit and simplifies the design.

When the zero-cross occurs, an interrupt will occur if the ZCD interrupt is enabled. The zero-cross interrupt flag needs to be cleared. A timer could then be used to create a delay. When this timer expires, fire the triac.

triac.png

The voltage at the ZCD pin will stay constant throughout the sine wave input. The Sink/Source capabilities of the ZCD design maintain that constant voltage.


Sample Code

The ZCD setup is simple. Just set the positive, negative (or both) edge detect and enable the peripheral. If the firmware needs to know the exact time of the zero-cross, enable the ZCD interrupt. An interrupt will occur at the zero-cross point when the signal is rising or falling (or both). If desired, the interrupt flag could be polled without actually enabling the hard interrupt.

The code sample below is just a portion of the code setup suggested for this application. The rest of the triac control algorithm will need to be added.

// Initialization Code
ZCD1EN = 1;    //Turn on the ZCD peripheral 
ZCD1INTN = 1;  //Turn on the negative edge polarity detect
ZCD1INTP = 1;  //Turn on the positive edge polarity detect
ZCDIF = 0;     //Clear the interrupt flag
ZCDIE = 1;     //Turn on the ZCD interrupt
PEIE = 1;      //Enable peripheral interrupt
GIE = 1;       //Enable global interrupt


// Interrupt Service Routine
void interrupt interrupt_handler(void)
{

    if(ZCDIE && ZCDIF)
   {
       ZCDIF = 0;

       //Timer delay routine is added here to create the phase angle firing delay.  
       //When this timer expires, fire the triac.

   }

20th Annual
Microchip MASTERs Conference 2016
Register now - Deadline: July 29

JW Marriott Desert Ridge Resort-Phoenix, AZ

© 2016 Microchip Technology, Inc.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.