You are on page 1of 22

Using PIC Microcontrollers to Control Triacs

Author: William G. Grimm


Consultant
Avorex Designs
www.avorex.com

May 1, 2003

Abstract
This application note describes how to control triacs with Microchip PIC Microcontrollers.
Special emphasis is placed on phase control of triacs. Phase Control is a cycle by cycle control
capable of delayed turn-on in each half cycle, which offers fast response and fine resolution.
Comparisons are made with other forms of triac control, such as burst mode and on/off, and
with variable switching power supplies.
A technical description of triacs is offered and two sample phase control applications. One
uses opto isolation, the other direct drive. The isolated sample application has debugged circuitry
and code. The PIC used is a 16C63. The code, written in C, is transportable to any of the
Microchip PIC16Cxx, 16F8xx, or 18Cxxx parts.
The non-isolated example also has debugged circuitry and code. It uses a 12C508. The code is
short and is in assembly language.
In depth descriptions of the calculations necessary for phase triac control is included, with a
step by step description of how to calculate and use triac firing angles and triac firing times.
Problems are addressed. These include controlling inductive loads, triac overheating, and
power line symmetry. Some myths about triac control are addressed.
Finally a list of related articles is included for those who wish to learn more about using
triacs or wish to use triacs with lower end PIC microcontrollers.

Definition of terms
Before getting started we need to get clear on some terms that are commonly used to
describe the electrical behavior of triacs.

Zero Cross - the two places in an AC wave form where the voltage goes to zero. When Zero cross
is stated alone, voltage zero cross is assumed. A current zero cross also exists. In resistive loads it
is coincident with voltage zero cross. In inductive loads it will not be.

Half Cycling - an error condition. This is a condition where the triac will act as a rectifying diode,
allowing the full wave of either the negative or positive side of the wave form to pass to the load,
but suppress the other side of the wave form. In this situation the triac has ceased to control the
energy to the load.

Commutate - The condition where the current through the triac has gone to zero. This normally
occurs at some time after zero cross. How much after zero cross this occurs depends on how
inductive the load is.
Delay Time - is the time between zero cross and gating the triac.

Delay Angle - is the same as delay time but it is expressed in degrees making this expression line
frequency independent. Zero degrees means no delay, 180 degrees is the maximum delay and
means the triac is not being gated at all.

Gating Time - is the time the triac gate is being actively driven. Gating is to start current flow
through the triac.

Dead Time - is the time just before zero cross that the triac should not be gated in a phase control
system. Gating in Dead Time runs the risk of the triac not commutating when zero cross does
happen. The triac could then pass current for the next half cycle, half cycling.

Methods of Controlling Power to a Load


Several common methods exist for controlling power to a load. For substantial power,
more than a few watts, the list narrows to the various forms of triac control, variable switching
power supplies, and of course, relays and solid state relays.
Three types of triac control exist for microcontroller based systems. These are simple
on/off, Burst mode, and phase control.

On/Off Control
On/Off is using the triac in place of a relay. In that case use the circuit in Figure 1. Control
the triac on and off just as one would control an LED. Typically no calculations are involved. Zero
cross sensing is not necessary because U2, the triac output opto-isolator takes care of the zero cross
synchronization.
Without the zero cross detection a burst of noise can be generated with each turn on of the
load. This noise can be managed. However, the more cost effective approach, typically, is to
eliminate the generation of noise at the source using this type of opto-isolator.

Burst Mode
Also known as proportional control, Burst Mode allows single cycles to pass either
completely or not at all. Every alternate zero cross creates an opportunity for turn off or turn on of
the triac. Thus for 50% burst mode, Half of the cycles are let through and half are not. The
disadvantage of this over phase control is response time and granularity. Changes in power level
take longer to implement and fine changes take even longer.
Whether the triac will be turned on or kept off is controlled by the power ratio. If for
example the requested power ratio is 3/4 (75%), then three of every four cycles are passed.
The gate length can be fixed, since it will always fire right after zero cross. Firing near zero
cross will prevent noise generation. Note: if you do use the zero cross triac output opto-isolator,
you must fire before zero cross to have the next half cycle turn on. Also for this reason Burst Mode
control requires monitoring of zero cross.
Burst mode provides a quieter system than phase control and easier implementation. The
disadvantage is performance.
Figure 1- Triac triggering circuit using a zero cross
opto-isolator for On/Off or
burst mode, to minimize switching noise.

Phase Control
Phase Control is the control of power to a load on a cycle by cycle basis. Control is
achieved by blocking current flow after zero cross. At the proper time in the half cycle, the
microcontroller will gate the triac allowing current flow. By blocking the current flow for a short
time after zero cross, more power is delivered to the load. A delay for a longer time delivers less.
Delay for the full half cycle will deliver no power to the load.
Fine granularity of control and fast reaction time are achieved. Granularity is only limited
by the number of bits in the microcontrollers timer, its clock rate, and the uncertainty in the
response time of the system. Response to changes can be implemented 50 times a second in a 50
Hz system and 60 times a second on a 60 Hz system. (This will be less in inductive loads.)
In phase control gating near zero cross must be avoided. The circuit in Figure 1 will not
work. Ordinary triac output isolators, ones without zero cross circuits in them, are best for this (see
figure 2).
Because of its performance capabilities phase control is the main focus of this application
note. Two operational examples are included.
For cost sensitive applications see the non-isolated sample application. It shows how to
control a triac without the use of an opto isolator. For performance see the isolated sample
application.

Comparison with Variable Switching Power Supplies


In some applications variable switching power supplies may be considered as an alternative
to triac phase control. Switching power supplies have some advantages. First, they are quieter in
terms of EMI. When a triac is fired at any point not near zero cross it distorts the power wave form
creating harmonics that can radiate to the air or conduct through the power lines. Second,
switching power supplies load the AC power wave form more evenly than a phase controlling
triac. For this reason power companies prefer them. Thirdly, the use of triacs control will
sometimes bring with it the need for heavy transformers adding to the weight of the final product.
Triac control, however, has three major advantages over variable switching power supplies.
First and strongest is simplicity. The typical triac driver circuit requires only 5 cheap parts. Zero
cross sensing only requires two more inexpensive parts. The electronics for variable switching
power supplies can be extremely complicated and can require months of hardware development
work. Complication increases if the variable switching power supply is intended to drive a wide
range of load impedance.
Second, if you really need AC at the load, a variable switching power supply may not be an
option, since its output is always DC.
Thirdly, the problems of EMI and uneven loading of the wave form go away if Burst Mode
is used. Even in phase control systems, the problems of EMI are manageable using line filters.

Figure 2 - simple opto-isolated triac control circuit


for phase control, and optionally for Burst Mode.

Note: for variations on this circuit, see Teccor AN1007.

What is a triac?
A triac is a three terminal electronic device designed to control large alternating currents
with a small current. It is a member of a family of electronic components known as Thyristors.
SCRs are another member. The names of the terminals on a triac are MT1, Gate, and MT2.
Specifications of the triacs operation are referenced to MT1.
Simply stated, a current flow between GATE and MT1 will allow a larger current flow
between MT2 and MT1. Once current flow is established between MT2 and MT1, current flow
will continue even if the current flow between GATE and MT1 stops. Thus, controlling the gate
cannot turn the current flow off. When current flow stops on its own the triac commutates. Further
current flow between MT2 and MT1 will be blocked. This typically happens at zero cross. Current
flow cannot restart until another gate pulse occurs.
The current flow through the gate can be in either direction to start current flow between
MT1 and MT2.
Because the current flow between GATE and MT1 can be either direction and because
current flow between MT2 and MT1 can be of either direction four triggering conditions exist for
the triac. The specifications for each of these four conditions, also known as quadrants, are all
different. By convention they are defined as follows:
GATE-MT1 MT2-MT1 Quadrant
Positive Positive QUADRANT 1
Negative Positive QUADRANT 2
Negative Negative QUADRANT 3
Positive Negative QUADRANT 4

The triac’s operation can be defined by a set three specifications. These are Gating current
(Ig), Latching Current (Il), and Holding current (Ih). Each Quadrant has its own set and all are
affected by temperature.
Gating Current (Ig) - this is the current that must flow between GATE and MT1 for the triac to fire.
Latching Current (Il) - this is the current that must be flowing between MT2 and MT1 when the
gate current turns off to maintain current flow. It can be compared to the “pull in” specification of a
relay.
Holding Current (Ih) - This is the current that must be flowing between MT2 and MT1 to prevent
commutation and the stopping of current flow. It can be compared to the “must release”
specification for a relay.
Quadrant 1 operation will always be the most sensitive. Sensitive means that the triac is
easy to trigger but hard to commutate. Quadrant 4 is the least sensitive. Quadrants 2 and 3 are in
between but are not the same. Manufactures strive to make quadrants 1, 2, and 3 as similar as
possible.

An excellent description of Triacs is available in the Teccor AP-Note 1002. It is available at


the Teccor Web site, www.Teccor.com.

Triac Selection
Triacs come in three types. There are ordinary triacs, triacs optimized for sensitive gating,
and snubberless triacs.
Sensitive gate triacs, also called logic triacs, should only be considered for direct drive
applications as in figure 3. In systems using opto-isolation drive current will not be an issue, but
false triggering can be. In systems using opto-isolators sensitive gate triacs should never be used.
The choice between snubberless triacs and ordinary triacs will be made based on the price
sensitivity of the product, current, and the level of inductance in the load.
Snubberless triacs differ from regular triacs in three ways. First, they are a little more
expensive. Second, they cannot be fired in the fourth quadrant, making them less susceptible to
false firing. Third, they tend to be available in the higher current ratings, rather than low current
ratings. Having more robust commutation and surge current capability, they also feature fast turn
on/off speeds and of course, do not need snubbers, often paying for the price difference.

Sample Triac Phase Control Application (using no isolation)


The circuit in Teccor AN1003 Figure 16.24 fires its triac in quadrants 1 and 4. This system
suffers from the different gating characteristics of quadrant 1 and quadrant 4, so it would not
respond well to inductive loads. Quadrant 4 also requires more current to gate the triac, increasing
the requirements on the power supply.
In figure 3 a positive common system is used for the microcontroller. The effect is to gate
the triac in quadrants 2 and 3. These quadrants have similar characteristics and a lower gating
current than quadrant 4. This system will also have better performance with loads that have
inductive components.
The assembly code for this application is included. The source file is ltriac.asm.
One should not plug an emulator into the circuit in figure 3, unless an isolation transformer
is used. Development can most easily be done with the Microchip MPLAB simulator.
Keep in mind, also, that at low temperatures gate drive may not be sufficient. At
temperatures below -40 degrees gate drive will be more than twice the value at room temperature.
The limitations of this approach can be seen in the power supply to run it. Lack of available
current to gate the triac limits the length of the pulse and the type of triac that can be used. Still a
logic triac is not necessary nor recommended.
A sharp eyed engineer may think that a resistor is needed between Gate and MT1. Not so.
Manufacturers now include a resistor between these pins for the purpose of taking the gate trigger
to inactive.
R1, which reads the zero cross is often split into two resistors. This design will allow easier
passing of UL.
Figure 3 - Non-isolated application example

Sample Triac Phase Control Application (using isolation)


The schematic for an application is shown in figure 4. It uses a PIC16C63 microcontroller
operating at 9.216 MHz. The PIC 16C63 was chosen because it has adequate processing and
interrupt capabilities, and it is pin for pin compatible with 18C series parts, creating an easy
upgrade path if that becomes necessary. The frequency was chosen to be fast enough to allow the
microcontroller to keep up with the zero crosses, to do some mathematical processing, and to be
compatible with RS-232 baud rates, making a computer hook up a possibility.
The triac is gated in Quadrants 1 and 3. Although the Ig, Il, and Ih specifications for
Quadrants 1 and 3 are different, they are quite close. These are best quadrants for triac operation.

Circuit description
A full schematic is shown on figure 4. The circuitry that includes the push buttons, display,
clocking, and power supply are all quite ordinary and not described here.
Triac Firing Circuitry - U1 the microcontroller drives the triac using RC2 through the opto
isolator, U5. Any port could have been used. R5 limits the gate voltage swing so as to not stress
the gate junction. This is a more detailed example of the circuit in figure 2.
R4 and C1 are a snubber. Sizing of the snubber is dependent on load and is sometimes not
necessary. Capacitors should be of the Metalized Polypropylene type. These have the high dV/dt
specification needed for snubbers. The snubber needs to act at turn off, when the voltage across the
snubber is changing quickly.
The simplicity of this circuit in terms of part count is one of the great advantages of triac
control.
Zero Cross Circuitry - R23 and U4A are the zero cross sensing circuit. The output of U3A
goes to the RB0 interrupt. Usually zero cross needs to be read by an interrupt. An exception is the
first example which uses a 12c508. Rapid polling replaces the interrupt in that example.
The internal pull up resistor is enabled in the code to pull up the open collector output of the
U4A opto-isolator.
R23 is often two series resistor to allow easier passing of UL.
Test Circuitry - TP1 allows for measurement of the voltage across the triac. TP2 allows for
measurement of current through the triac.
Figure 4 - Schematic Triac Phase control example
Operation of the test board
The triac test board is designed to control the triac and present important parameters on the
three digit display. Power to the load can be controlled in terms of gating delay time or percent
power. Important parameters can be read such as line frequency, delay time, on time, and dead
time.
An Auto/Manual switch is on the test board to determine if the triac delay angle will be
controlled in terms of triac delay time in milliseconds (manual) or percent power (auto).
The six buttons around the display allow parameters to be changed. Only line frequency is
not changeable.
The single push button beneath the arrows selects the parameter that will be viewed and
available for modification.

Code Description
Two sets of source code are included. The first is C source compiled using Hi-Tech C and
designed to be used with the hardware described above. It implements the phase control of a load.
The second set of source code is written in PIC 17C75x assembly code and designed to
work with the simulator. It is designed to verify the tables used in calculating triac firing angle.

C Source Example
Flow charts are included to describe program flow. At reset the PIC initializes its ports and
resources then enters the main loop, see figure 5.
In the main loop it reads the buttons and updates the display every 1/8 second. If a change
in requested power has resulted, a new triac firing angle is calculated using the look up tables.
On every pass through the loop, a state machine variable, zx_state, is checked to see if a
zero cross has recently passed. If a zero cross has recently passed, new triac delay and on times are
calculated. TMR1 is then updated immediately to improve response.
Figure 6 - Triac timing calculations
When a new zero cross occurs, a new triac delay time and a new triac gating time need to be
calculated. A flow chart of the calculation routine is shown in figure 6.
Triac delay time changes with zero cross, although zero cross time should not change very
much. This algorithm allows the system to track changes and accommodate them.

Once the timings have been calculated, they are ready for use in the interrupt routines. The
zero cross interrupt starts the TMR1 timer timing the triac off time.
It would be nice to do the calculations for the timings in this interrupt routine. Two issues
argue against this. First, interrupt routines need to be short. If much time is spent in the interrupt
routine it may prevent urgent main loop tasks or other interrupts such as communications from
getting through. The second reason is that doing mathematics in the interrupt will require the
compiler to generate two copies of every mathematical routine needed in the interrupt, one for the
interrupt and one for the main loop, since the main loop needs them, too. This requires a lot of
program and file memory.
The flow chart for the zero cross interrupt routine is shown on figure 7.
Figure 7 - Zero cross interrupt servicing routine

The TMR 1 interrupt is designed to occur twice every half cycle. On the first time out, the
delay time has just expired. The triac is gated. On the second time out, the gate time has just timed
out and the triac gating signal is turned inactive. Timer TM1 is then left to continue clocking. This
over count will be collected in the zero cross interrupt and used to calculate the zero cross time.
If the triac is not to be gated, this interrupt will not come due. In that case, TMR1 is loaded
with 0 at zero cross. The next zero cross will occur before the full count of TMR1 is reached.
A flow chart of the TMR1 interrupt is shown on figure 8.
Figure 8 - TMR1 interrupt

Control Details
Phase control is a five step process. It starts with the determination of the power required
and ends with values for gate delay time and gating on time.

Step 1 - Find the power required


Controlling the power output usually starts with the calculation of a desired power output.
This could be derived from a closed loop control, A/D converter, or some other means.

Step 2 - Normalize power to the maximum power available


This desired power output must be normalized to the maximum power output of the system.
This is the power that would be delivered if the triac was on full time. This power can be calculated
using the RMS power equation for a sine wave:
Pmax = (Vpk * Vpk) / (2 * R) (1)

Pmax = RMS power in watts


Vpk = peak AC line voltage = Sqrt(2) * Vrms
R = the resistance of the load

Power ratio is:


Pr = P/Pmax (2)
Pr = power ratio
P = desired power

Step 3 - Calculate the Delay Angle


The desired power for a half cycle can be expressed using the following equation:

P = Pmax *(1 - F/P + (sin2F)/2P) (3)

P = desired power
Pmax = the full power available
F = the delay angle, See the description below
P = PI, approximately 3.14159... This is also the maximum angle in radians for a half
cycle.

The Delay Angle (F) is an expression of how much the triac is delaying the current flow on
each half cycle. If the delay is zero, then P = Pmax. If the delay is P radians (180 degrees), then
the power will be zero. Delay angle is an intermediate value in calculating the time between zero
cross and triac firing.

Normalizing the desired power to the maximum power available changes the above
equation to:
Pr = P / Pmax = 1 - F/P + (sin2F) / 2P (4)

In the code the value Pr is referenced as the structure percent.

At this point we know the power that we want, we know the power that is available in the
system, and of course we know P. We would like to solve the above equation for F. Unfortunately
this equation is not solvable for F. Even if it was the resulting number crunch would be beyond
what most microcontrollers could do in a timely manner.
The most efficient solution at this point to use a look up table. In the code this table can be
found in file ttable.h. The table was generated using MathCadâ, which exported values for F for
each of the 255 power ratios between 0/255 to 255/255. These were exported in two tables, a
whole number part and a fractional number part. From a ‘C’ point of view it would be cleaner to
have a single table declared ‘const unsigned int’ type. The table, however, was originally exported
to two assembly language look up tables where they were tested and then ported to C. Although it
makes the C source longer, it does not waste any program memory space.
In the code this value F, Delay Angle, is referenced as the variable, triac_angle. It can range
from 0 to 46,080 where the least significant bit is 1/256 of a degree and 46,080 represents 180
degrees.

Step 4 - Calculate the delay time


Once the delay angle has been calculated with the help of the table, the final step can be
undertaken, the calculation of the triac delay time. This is the time the triac will keep the current
turned off after zero cross.
To do this one more piece of information must be collected. That piece of information is
the time between zero crosses. Delay of the full time is P radians or 180 degrees. Delay of half the
time is P/2 radians or 90 degrees. The calculation is as follows:
DT = F * ZX / 180 (5)

DT = the delay time. This is expressed in terms of TMR1 increments. In the code it is
referenced as triac_delay_time.
F = Delay Angle, 180 degrees maximum, in terms of 1/256 degrees. In the code it is
referenced as triac_angle.
ZX = the full zero cross time. Two readings are taken every cycle. In the code it is
referenced as full_zx_time, and is in terms of TMR1 increments.

Calculation of DT (triac_delay_time) is done in the routine CalcTriacTimes(), see flow


chart, figure 6. Along with the delay time, another timing value is calculated. This is the triac on
time.

Step 5 - Calculate a triac on time


Triac on time (referenced as triac_on_time) is the time the triac is being actively gated. It
starts after the delay and must end before dead time. If the triac delay time is short enough this time
will equal MAX_ON_TIME. If the triac delay is so long that a full triac on pulse would overlap
the dead time, then the triac on pulse will be shortened. If the calculation indicates that the pulse
would be cut too short (less than MIN_ON_TIME) then the pulse will not be issued at all and zero
power will be delivered.

Assembly Language Test code for the Table


Code has been included to check the look up tables. This code uses the math routines from
AN575 unchanged. It was written in PIC17c75x assembly language, since that part has significant
mathematical capabilities and the 18Cxxx parts were not yet available when the code was written.
This code is designed to run on the simulator only.
The main file is ctable.asm. A break point has been placed at the label AllDone. The watch
window named TABLE holds the results.
A power ratio is created by adding 16 to the previous power ratio with every pass through
the main loop. It then uses this contrived power ratio to get a delay angle. It then takes this delay
angle and plugs it into equation 3 to get the power ratio back. Error between original and calculated
power ratios can be seen if the program flow is broken at AllDone.
Power ratios range from 0 to 65535. A denominator of 65536 is assumed. What will be
found is that above 2 * 256 and below 254 * 256 the table performs at its best. Much of the
accuracy is due to the use of linear interpolation between neighboring points. The closer the points
the better this works. Near 90 degrees it is at its best. That is also where it needs to be its best since
every 1/256th of a degree carries the most power there.
In the TABLE watch window The power ratio fed to the system is to be found in the
variables power_ratio_u:power_ratio_l. The returned value is in ratiocalcPm:ratiocalcPl, where
ratiocalcPm is the more significant byte.
Problems
Problems using triacs tend to express themselves in only one way, half-cycling. If the load
the triac is feeding has any transformers the results of half-cycling are quite distinctive. Any
transformer in the load will attempt to unbolt itself and jump out of the case.
The main causes of half cycling are inductive loads, overheating, firing too near zero cross,
code bugs, and over firing.

Inductive Components in the Load


Inductive components in the load are effectively the mother of all other problems in triac
control. Because the triac turns-on by a gate signal and turns-off by lowering main terminal current
the inductive load with lagging current presents some challenges. Also some inductive loads can not
tolerate DC component. For example, if a transformer sees excessive DC component it will
saturate and draw excessive current. If gate signal to triac is not symmetrical, it can create just such
a DC component and cause an asymmetrical wave form. By Fourier analysis any asymmetry in an
AC wave form results in a DC component. If the load is just resistive, no problem, the resistor
dissipates the DC component along with the AC. If the load is capacitive, again, no problem, the
capacitance charges to the DC voltage.
If part of the load is inductive, though, that DC component gets shorted. Current between
MT1 and MT2, which is out of phase with the voltage, and quite high may not go to zero at zero
cross. If that current is above the hold current (and it almost certainly is), the triac will not
commutate, conduction will carry over through voltage zero cross, and not stop until current zero
cross is reached.
Here is where a short trigger pulse will kill you. Current zero cross on this next cycle may
not occur until that short trigger pulse has come and gone. The result will be that the triac will not
fire at all on that half cycle. It will fire on the next half cycle, though. The result will be half
cycling.
If the pulse is wide, the triac will fire on all the cycles, even if the firing is late. The
resulting DC component will be small and short lived. It won’t be a DC component at all in the
pure sense, but a low frequency (sub-Hz) transient.
The scenario cited above is most likely to happen if the requested power has changed.
Another way to get to half cycling is to exceed the voltage across the triac. This can happen
when powering an inductive load, even if the line voltage is well below the voltage spec of the triac.
Inductors like to keep the current flowing through them constant. If the current is cut off
suddenly, the voltage across the inductor rises in an attempt to find a current path and keep the
current constant. This voltage rise can be substantial. This voltage spike is described by the
following equation:
V = L (dI/dt) (6)
V = the voltage of the spike
L = inductance
dI/dt = change in current with time
This equation isn’t for plugging numbers, it is for showing relationships. The voltage spike
is made greater by greater inductance, greater current change, and shorter commutation (turn off)
time.
The main method for dealing with this sort of problem is to use snubbers. Snubbers are
capacitors and resistors in series and designed to be mounted across the triac. C1 and R4 in Figure
4 are an example.
The snubber works by having the capacitor provide a current path around the commutating
triac, decreasing the dI/dt term. The resistor reduces stress on the capacitor. Sizing of these
components is load dependent. Metalized Polypropylene is the best type to use with this
application because if its high dv/dt characteristics.

Three things are important when handling loads with inductive components. These
precautions are best done with any type of load.
1. Gate the triac with a pulse of no less than 10 microseconds. Use a 1 millisecond pulse if
possible. This is needed for the reason stated above and because it takes longer to get enough
current flowing through an inductive load to get above the Latching Current(Il) specification.
2. Size the Dead Time so that the firing pulse is off long enough to ensure that half-cycling
will not come from the pulse being too close to zero cross. This could cut back on the low power
end of the control.
3. Snubber the triac if voltage spikes are retriggering it. Size the snubber for the expected
load or use a snubberless triac.

Over Heating
The three main parameters Gating current (Ig), Latching current (Il), and Holding current
(Ih) are all temperature dependent. As temperature rises the gate becomes more sensitive. The
hold current goes down, too, which can eventually keep the triac in conduction right through zero
cross, resulting in half cycling or full cycling.
Suspect overheating if the system comes up fine, but then starts to fail after operating a
while. Spray some freeze mist on the triac. If the problem goes away for a while, you know that
overheat is the issue and heat sinking is not adequate.

Firing too Close to Zero Cross


If the firing pulse ends too close to zero cross, the Latching current, not the Hold current
parameter must be met to commutate the triac. Since the Latching current is always higher than the
Hold current commutation may not happen before zero cross.
For this reason a Dead Time needs to be part of the calculation of the triac firing pulse.
Dead Time is the time before zero cross that the firing pulse must be inactive.
This problem will show itself as half cycling incidents at high delay angles, near 180
degrees.

Code Bugs
It is very easy to upset the zero crossing interrupt. Be careful before disabling interrupts.
Disabling interrupts can cause jitter in the triac firing and mismeasurement of the full zero cross
time.

Over Driving the Gate


A problem that will imitate overheating is the overdriving of the gate. Just as with
overheating the circuit will perform well for a while, but when the GATE-MT1 junction overheats
half-cycling will occur on an intermittent basis.
To ensure that this is not a problem the gate resistor should be sized properly. This resistor
is a function of the voltage to be controlled and the amount of current available (through the opto-
isolator) for triggering. The following equation can be used:
Rg = Vpk / Io (7)
Where:
Rg = value of the gate resistor
Vpk = peak AC line voltage = Sqrt(2) * Vrms
Io = the maximum current capabilities of the opto-isolator’s output triac.
By the way, the MOC3052 was chosen for its high (1KV/uSec) switching rate. This
provides a more accurate turn on for the gate than previous generation opto devices, such as the
MOC3023. The MOC3052 should gate the triac reliably. If the isolator is suspected of false
triggering, however, try the Infineon IL4218. It is optimized against false triggering.

Line Symmetry
The algorithm used to control the triac firing angle, controls on a full cycle by full cycle
basis. It could control on a half cycle by half cycle basis, but does not. This is because symmetry
between positive and negative halves of the AC wave form must be maintained to accommodate
any inductive component of the load. Any asymmetry in the AC wave form effectively introduces
a DC component on to the wave form and will cause trouble in the form of half-cycling and loss of
control.

Triac Myths
Noise at Zero Cross
This is not a problem. If you think you have a problem with noise at zero cross, look
somewhere else.
The zero cross circuitry is low impedance. Low impedance circuits have low susceptibility
to noise.
On two of the designs that I have done using triacs, I was explicitly warned about noise at
zero cross. During development this was never an issue. One design is a product commonly used
in China. Never has there been a noise at zero cross issue.

Fire with a narrow Pulse


I was told this before one of the designs, that a narrow pulse was best. This is dead wrong.
A narrow pulse is especially deadly in inductive loads, since current may take some time to increase
above the Latching current level. If the pulse has gone away before latching level has been
reached, the triac will commutate back off again. The result is no conduction on that half cycle. It
is all too easy to write the following code:
RC2 = 0; // Turn triac firing on
NOP();
RC2 = 1; // Triac firing ends
This will give you big problems. Even a wire the width and length of your finger has some
inductance. Firing pulses need to be as long as you can make them up to 1 millisecond. Anything
beyond 1 millisecond, though, is unnecessary.

The myth of narrow pulses may be based on two things that are indeed true. First, even
though the pulse should not be short, it should have a fast rise time. Rise time should be less than 1
microsecond. For this reason Diacs are sometimes employed in the gate circuit of triacs. This is
usually not an issue with microcontroller based designs, so Diacs are not recommended. Second, if
the current of the gate pulse is too high, it can stress the GATE-MT1 junction causing overheating.
The fix is not to shorten the pulse but to ensure that the current of the pulse is not excessive. Use
equation 7 above to size the gate current limiting resistor.

Motor Control
The short answer for using a triac to control a motor is, don’t try it.
Of course a triac can be used to turn a motor on and off. Snubbering is most likely needed
and turning on and off at zero cross is also recommended.
Phase control of a motor will not work. The reason is that the process of phase control
introduces harmonic frequencies into the power waveform that are much higher in frequency than
the wave forms base frequency. Phase control is good at controlling voltage, but not at controlling
frequency. Since torque is proportional to V/F, and F becomes a complex waveform when using
phase control, torque essentially becomes undefined.
The motor’s reaction to the frequencies in the complex waveform will not be specified or
controlled by the manufacturer. The result is usually bad noises, overheating, and inefficient
operation of the motor.
Triacs have been used to control motors on aircraft. This has been done using Burst Mode
(proportional control). The result will be a an uneven operation, since some cycles will be missing,
but very little EMI will be generated. In aircraft the power wave form is 400Hz, which makes the
uneven operation a little more forgivable. Performance at 50 or 60Hz is unlikely to be considered
adequate under any product specification.

Summary
Phase triac control can provide a very cost effective solution to controlling significant
power to a load. Although problems exist with EMI and inductive components in the load, these
problems can be managed. Keep the gating pulses wide and don’t gate too close to zero cross. If
you are not stingy with line input filtering, you will get your CE mark, too.
Who could ask for more.

Related Articles
Microchip Reference Design:
PICREF-4 - “PICDIM Lamp Dimmer for the PIC12C508,” by Scott Fink, 1997, Microchip
document number 40171a. schematic in Teccor Application Note 1003

Teccor AP-Notes (www.teccor.com):


AN1002 - “Gating, Latching, and Holding of SCRs and Triacs,” dated 2001
AN1003 - “Phase Control Using Thyristors”
AN1007 - “Thyristors Used as AC Static Switches and Relays”
AN1009 - “Miscellaneous Design Tips and Facts”

ST Micro Ap-Notes:
AN308 - “Control by a Triac for an Inductive Load How to Select a Suitable Circuit,” by X.
Durbecq, Feb. 1989.

A National Semiconductor AP-Note:


COP Note 6 - “Triac Control Using the COP 400 Microcontroller Family,” dated February
1981, reissued 1995.

Teccor AP-Note 1003 has schematics and has a predecessor to the first example of this Ap-
note. The COP Note 6 describes how control was done before the invention of opto-isolators.

The ST Micro AP-Note 308 has a good description of half cycling in inductive loads. If the
description here confuses, try that one.

Acknowledgments
The author would like to thank Richard Norris of Teccor for reviewing and correcting this
Application Note and Mark Heyman of TA Instruments for driving the Math Cad to derive the look
up tables for linearizing the firing angle in the code.

You might also like