By Reston Condit,
Microchip Technology Inc.
Most countertop cooking appliances like electric ranges, skillets, and fryers have an adjustable mechanical thermostat to vary the heat output of the range. This solution is inexpensive, but there are several drawbacks to mechanical thermostats:
• Mechanical thermostats have to be calibrated at the factory.
• They have poor simmer performance (control is not precise at low temperatures).
• The accuracy of these devices is poor.
• Mechanical components wear out over time.
This article describes how, using a mechatronics approach, a low-cost microcontroller-based replacement for the mechanical thermostat can be designed to eliminate these drawbacks.
The PIC10F204, Microchip’s 6-pin PICmicro microcontroller (SOT-23 package), is used to implement this solution. The PICmicro gathers user inputs from a potentiometer and controls current to the heating element via a triac. This article will discuss triac theory, so it is also a good resource for other applications that interface to ac lines (i.e., light switches, vacuum cleaners and various other household appliances). Power to the PICmicro is supplied directly from the ac lines via a resistive power supply. Compared to the mechanical thermostat, the PIC10F204 solution offers design flexibility, including the addition of user-friendly features. Two such features are incorporated into the PICmicro solution detailed here. These features are: (1) a status LED indicating the range is on or off, and (2) an automatic shutdown. The automatic shutdown provides added safety by shutting the range off after 2 hours if it is left unattended.
Mechanical thermostat operation
Electric ranges create heat by applying the AC line voltage across a resistive heating element. An adjustable mechanical thermostat in series with the heating element has a rotary dial which sets the amount of current to the element. The mechanical thermostat shown in Figure 1 has a complex set of metal tabs, spacers and contacts that work together to connect and disconnect power depending on the setting of the rotary dial. The following sequence of events describes the operation of a mechanical thermostat when the dial is turned halfway between off and full on.
1. Contact is made between the two terminals of the switch.
2. Resistive materials in the switch cause parts of the switch to heat and expand.
3. The expansive materials push the contact apart and the switch stops conducting current.
4. The element then cools until contact is made again.
Based on the position of the dial, the switch repeats this sequence more or less frequently. The switch allows infinite control, but without a clear reference. As a result, the switch is not very accurate. The switch is constantly subjected to thermal changes and arching occurs frequently across the contacts when the dial is not in an absolute position (off or full on). These stresses affect the reliability of the switch.
Figure 1:Adjustable mechanical thermostat.
A traic will be used to control current flow to the heating element in the microcontroller-based design. A triac is a three-terminal bidirectional AC switch that is triggered by a low-energy signal applied to the gate. When this signal is applied, the triac goes from a high-impedance state to a conductive state, allowing current to flow to the load. A positive or negative gate signal will trigger a triac, though one signal is more efficient. Figure 2 shows the four trigger modes for a triac. Each mode is referred to as a quadrant. Note that everything is referenced to terminal MT1.
Triacs are typically most sensitive in QI and QIII, slightly less sensitive in QII and least sensitive in QIV. The triac used in this article, for instance, requires a trigger current of 25 mA for QI, QII, and QIII and 50 mA for QIV. Triggering in QIV should be avoided unless special circumstances dictate it. A low-cost solution will use the same trigger signal for each half wave. Since QIV should be avoided, a negative trigger signal with respect to MT1 is used. This corresponds to operation in QII and QIII.
One nice characteristic of the triac is the fact that it is triggered by current rather than voltage. In other words, it is the amount of current injected at the gate, not the magnitude of voltage
applied to the gate that determines whether or not the triac is turned on. This characteristic makes triacs useful in the digital realm where voltages are significantly less than 115 VAC or 220 VAC. A PICmicro microcontroller operates in the 2.5V-5V range, yet it can sink and source 25 mA on its I/O pins. During any half-cycle of the AC waveform, a negative current pulse (with respect to MT1) of sufficient width and magnitude will trigger the triac. The width and magnitude of the triggering current varies per triac and is specified in the triac manufacturer’s data sheet. The triac will conduct
current until the half-cycle is completed and then revert to the non-conductive or blocking state. Figure 3 illustrates this characteristic of triacs.
Figure 3 is also an example of phase control. Phase control is one method for controlling the amount of power delivered to the load. Phase control works by turning on a fraction of each half-wave, similar to pulse width modulating a digital signal. Current to the load is proportional to the integral of each sine wave. This type of triac control is commonly used in light dimmers. The light’s brightness will be proportional to the area under the curve.
The benefit of phase control is that the frequency of the waveform providing power to the load is unchanged at 60 Hz. This is necessary when dimming a light because if the frequency were much less, flickers in the light would be detectable by the human eye. The drawback to phase control is that switching the AC waveform in the manner described produces undesirable electromagnetic interference (EMI). Care must be taken to prevent this EMI from radiating back onto the line or affecting the triac circuit itself.
An alternative to phase control is zero-cross switching. Zero-cross switching eliminates most EMI
problems because an entire cycle is either on or off. To vary the average current sent to the load, alternating cycles are skipped (see Figure 4). This method of control is not suitable for light dimmers because the intensity of the light will noticeably fluctuate. However, in the case of a resistive heating element, this method of control is preferred for its lower EMI.
Zero-cross switching and phase control both require that the point at which voltage on the line crosses neutral be detected. A method of detecting a zero cross is detailed in application note AN521, Interfacing to AC Power Lines. A different zero-cross detection method is used for this application. This method is detailed in the next section.
The circuit for the low-cost thermostat solution is shown in Figure 5. Power to the microcontroller is
provided by a transformerless resistive power supply. An analysis of resistive power supplies is given in Microchip application note AN954, Transformerless Power Supplies: Resistive and
Capacitive. The resistive power supply was sized to provide the necessary current for powering the microcontroller, switching the triac, turning on the LED and charging the ADC circuit used to read the potentiometer.
The system is an open-loop system just as with the mechanical thermostat. The potentiometer provides input from the user. This input is then translated into an output to the triac. When the triac is being modulated, the LED is turned on to indicate the unit is on.
A 1,100-W heating element is being switched by the triac. In countries using 115 Vac, this translates to an rms current of nearly 9 A; therefore, a rather large triac is needed. A 16-A triac is used to insure an adequate margin of safety. The triac is mounted to a heat sink in order to prevent thermal runaway on the triac.
One benefit of using this type of transformerless power supply is that the zero cross is detected by tying a pin on the microcontroller directly to the anode of the zener diode. This node will transition between -0.6 V and VZ, the Zener voltage, on every zero cross. Figure 6 compares the waveform seen at this node to the line voltage.
The triac used is a Q4016LH3 from Teccor Electronics. This triac comes in a T0-220AB package and is rated at 400 V, 16 A. The microcontroller triggers the triac by turning on Q1 for 2 ms at the start of a half-cycle. Q1 then pulls the gate on the triac low with respect to MT1 and the triac conducts current.
An RC circuit is used to translate the resistive value of the potentiometer into a measurable time. The 3-V zener diode (D4) ensures that fluctuations in the microcontroller VDD reference do not affect the accuracy of the time constant. (In reality, the ground reference actually fluctuates when current is drawn from C2 because VDD is referenced to the line voltage). The time it takes for the voltage to decay has a direct correlation to the setting of the potentiometer. The circuit works by first configuring GP1 as an output and charging C6. Once C6 is charged, GP1 is configured as a comparator input. The voltage on GP1 is compared to the internal band gap reference voltage of the microcontroller (approximately 0.6 V.) When the voltage of the decaying RC circuit falls below the reference voltage, the output on the comparator will go high. This output is read internally by the microcontroller. The time it takes for VOUT to trip the comparator is given by Equation 1.
t = –(RPOT1 + R12)C1n(VREF/Vz)
Where VREF is 0.6V and Vz is 3V
The potentiometer varies linearly from 0 to 25 kW. The resistance of the potentiometer has a linear relation to time. More precisely, calculating the time of decay using Equation 1 and given the range of the potentiometer yields a decay ranging from 3.53 ms to 7.56 ms. The RC time constant was chosen carefully so that the maximum time for the circuit to delay is just under one half-cycle time or 8.33 ms. This makes it possible to initiate the discharge of the circuit on a zero cross and measure the decay time of the output voltage before the next zero cross. Figure 7 shows what the waveform looks like on the GP1 read cycle.
The circuit described in Figure 5 assumes that the line and neutral signals are relatively free from noise. In the real world, noise on the AC lines can have a profound affect on the behavior of a microcontroller, especially, when it is not isolated from the AC lines. Noise in the MHz range is especially damaging because it can be in the tens of kilovolts. Designing in some noise filtering up front will save a lot of time and agony during the testing and certification phases of a project. Creating a robust solution is based on one premise: isolate the microcontroller from high frequency noise. Not only must the supply voltage and ground be isolated, but also all the microcontroller pins that are connected to the “noisy world.” Figure 8 shows the same circuit as before only with proper filtering incorporated into the design.
In this circuit, a π filter has been added between the main storage capacitor and the microcontroller. An additional ground reference has been added. Now two grounds exist – one in the noisy world and one in the quiet world. The microcontroller sits in the quiet world while the triac sits in the noisy world. Pins GP1 and GP3 previously connected directly to the noisy world. In the new circuit, a low-pass filter has been added to each of these traces. The 3 dB cut-off frequency for a RC filter is given in Equation 2.
The filters on the traces from the microcontroller to the zero cross detection point and bipolar junction transistor each have 3 dB cut-off frequencies of approximates 1 kHz. Ceramic capacitors are used as they are most effective for combating radio frequency interference.
The program loop for the firmware centers around the zero-cross event. When a zero cross is detected, the microcontroller first decides whether or not the triac should be on during the present half-cycle. The triac is turned on by driving GP2 high for 2 ms. During the positive half-cycle, GP1 is configured as an output and charges C6. During the negative half-cycle, GP1 is configured as an input to the PIC10F’s internal comparator.
The time it takes for the comparator to trip is measured using Timer0. This measurement is then used to decide how many half-cycles, out of a total of 10, the triac should be turned on. If the answer is anything other than zero, the microcontroller will turn on the status LED and start a 2 hour automatic shutdown timer. This timer is only reset if the potentiometer is turned back to the off position (no cycles on). Should the automatic shutdown timer flash, the triac will be switched off and remain off until someone either interrupts power to the device (i.e., unplugs it) or the potentiometer is turned to the off position and then back on. Software requirements are 129 12-bit instructions and 9 bytes of data memory.
The PIC10F204 thermostat implemented in here has many benefits over the adjustable mechanical thermostat it is designed to replace. These benefits include:
1. Better reliability due to minimal mechanical components.
2. Built in safety features like automatic shutdown.
3. Built in visual feedback to let the user know when the unit is on.
4. Flexible design and programability via In-Circuit Serial Programming (ICSP) (i.e., the same switch can be used in multiple applications).
5. Increased accuracy and good simmer performance.Other possibilities not given in this particular solution include:
1. Temperature feedback
Microchip Technology Inc.
• AN954, Transfomerless Power Supplies: Resistive and Capacitive, Condit, Reston, Microchip Technology Inc., 2004.
• AN521, Interfacing to AC Power Lines, Cox, Doug, Microchip Technology Inc., 1997.
• DL137/D, Revision 6, Thyristor Device Data, Triac and SCRs, Motorola, 1995