Order this document by AN1662/D Rev. 1 Freescale Semiconductor AN1662 Freescale Semiconductor, Inc... Low-Cost Universal Motor Phase Angle Drive System By Ivan Skalka Roznov System Application Laboratory Roznov pod Radhostem, Czech Republic Introduction This application note describes the design of a low-cost phase angle motor control drive system based on Motorola’s MC68HC05JJ6/MC68HC705JJ7 microcontroller (MCU) and the MAC4DC snubberless triac. The low-cost single-phase power board is dedicated for universal brushed motors operating from 1000 RPMs to 15,000 RPMs. This application note also explains how to design the software implementation using an MC68HC05 MCU. Such a low-cost MCU is powerful enough to do the whole job necessary for driving a closed loop phase angle system. Today this universal motor is the most widely used motor in home appliances such as vacuum cleaners, washers, hand tools, and food processors. The operational mode, which is used in this application, is closed loop and regulated speed. This mode requires a speed sensor on the motor shaft. Such a sensor is usually a tachometer generator. The kind of motor and its drive have a high impact on many home appliance features like cost, size, noise, and efficiency. Electronic control usually is necessary when variable speed or energy savings are required. © Freescale Semiconductor, Inc., 2004. All rights reserved. For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Freescale Semiconductor, Inc... MCUs offer the advantages of low cost and attractive design. They can operate with only a few external components and reduce the energy consumption as well as cost. This circuit was designed as a simple schematic using all features of a simple MCU. The MCU and this board may be used in a wide variety of applications. Figure 1. Low-Cost Motor Control Phase Angle Board The phase angle control technique is used to adjust the voltage applied to the motor (refer to Figure 2). A phase shift of the gate’s pulses allows the effective voltage, seen by the motor, to be varied. All required functions are performed by just two integrated circuits and a small number of external components. This allows a compact printed circuit board (PCB) design and a cost-effective solution. AN1662 2 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Added Value Using a Microcontroller LINE Voltage VOLTAGE Line Motor Voltage MOTOR VOLTAGE LINE VOLTAGE Line Voltage tdt d MOTOR Motor VOLTAGE Voltage GateSIGNAL Signal GATE Freescale Semiconductor, Inc... Gate SIGNAL Signal GATE Figure 2. Phase Angle Control Technique Added Value Using a Microcontroller Compared to a poor analog solution, an MCU-based drive shows many advantages. Some of them are: • Choice of different control algorithms • Choice of any shape of speed command (phase acceleration and deceleration) • Choice of any type of tachometer • Software that can make the hardware simpler • Diagnostic functions • Remote control by wire and communication protocol • Open for innovation Devices Universal motors are still used where brushes are accepted, and universal motors driven by triacs are used where a low price is required. This section contains information and descriptions about all the features of suitable MCUs and triacs. AN1662 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Freescale Semiconductor, Inc... MC68HC05JJ6/ MC68HC705JJ7 The MC68HC05JJ6 is an M68HC05-based MCU designed for low-cost applications. General features include: • 6.1 Kbytes of ROM • 224 bytes of RAM • 16-bit timer including an output compare and an input capture • 14 general-purpose input/output (I/O) pins • Simple serial input/output port (SIOP) in a 20-pin SOIC (small outline integrated circuit) or a DIP (dual in-line) package. In addition, the MC68HC05JJ6 has specific features including: • Two comparators which can be combined with the 16-bit programmable timer to create a 4-channel single slope analog-todigital (A/D) converter. • High-current source/sink port and an on-chip temperature measurement diode. The high-current source pins are important for this application. The MC68HC05JJ6 has six pins with 10-mA sink capability. The MC68HC705JJ7 has the same features but replaces the ROM with a 6.1-k one-time programmable EPROM and is more suitable for program development. MACx Triac Family The series MAC4 and MAC8–MAC16 triacs are specially designed for efficient motor drives. Triacs with low-enough trigger current for direct drive by an MCU (MAC4DS, MAC8S, and MAC15S) usually have a low dv/dt capability and may need to be snubbed. The MAC15S is the largest sensitive-gate triac in the market today. High dv/dt devices such as the MAC4DC, MAC9 and MAC16 are ideal for snubberless applications. They can turn off inductive loads without a snubber turn-off circuit, thereby saving the cost and space of extra components. The MAC4DCN triac is designed for low-cost, industrial and consumer applications such as temperature, light, and speed control. The main electrical parameters are found in Table 1. AN1662 4 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Circuit Table 1. Electrical Characteristics of the MAC4DCN Freescale Semiconductor, Inc... Parameter Value Peak repetitive reverse voltage VRRM 800-V max RMS current IT(RMS) 4-A max Peak on-state voltage (ITM = 6 A peak) VTM 1.3-V typ Continuous gate trigger current IGT MT2(–), G(–) IGT 25-mA typ Critical rate of rise off-state voltage dv/dt 1700-V/µs typ Circuit In Figure 3, the schematic of a phase angle motor control board is shown. As can be seen, the phase angle drive needs only two integrated circuits: the MCU and one comparator. The snubberless triac MAC4DC is used as the power device. This triac has a high dv/dt immunity and, therefore, there is no RC circuit around the triac. The MT1 pin of the triac is connected to VCC and the GATE pin is connected directly to the microcontroller. The triac’s turn-on level on pins PA3–PA5 is 0 V. This configuration was chosen for two reasons. The first is the current capability of the pins of port A. In the MC68HC705JJ7 General Release Specification, Freescale document order number HC705JJ7GRS/D, it can be found that the source capability is 5 mA and the sink capability is 10 mA. Our choice is the sink mode. The second reason is determined by the triac. A common law states that snubberless triacs with high dv/dt immunity need a higher gate trigger current IGT. The MAC4DC needs at least 25 mA typically in case of negative IGT. For an operational mode with positive IGT, the gate trigger current is much higher. Our choice is to use a negative IGT. Three pins, PA3–PA5, are connected together and are powerful enough to cover the amount of current needed by the gate and to turn on the triac reliably. AN1662 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note The power supply includes only a few components (D1, D4, R7, C1, and C2). The output voltage is +5 volts and despite its simplicity it is able to supply the microcontroller, the comparator, the external control panel, and also the triac. This circuit is powered directly from the line. Do not touch any parts of this board. When working with this board, do not connect any computer, scope, or development system. In this case, it is necessary to use an isolation transformer. Freescale Semiconductor, Inc... WARNING: Figure 3. Low-Cost Motor Control Phase Angle Drive The circuitry connected to pin PB6 is needed for the acquisition of a synchronization signal. This signal provides the most important information to the microcontroller, which is the zero crossing of the line voltage. The point of the zero crossing is fundamental for the calculation of any triac’s action. All actions and the functionality concerning the triac are controlled by software. AN1662 6 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Circuit Because this board provides the control algorithm in closed loop mode, some devices allow connection of a tachometer. The most frequently used tachometer has 16 poles and an output voltage of 5 volts to 20 volts RMS for a full scale working speed. An input filter protects the comparator against high voltage at high speed, and diode D3 protects the comparator against negative voltage. The output square wave signal from the comparator is connected to pin PB3. With this arrangement, the input capture feature of the microcontroller can be used. Freescale Semiconductor, Inc... The speed command can be set externally in the range of 0 volts to 3.5 volts. A simple external control panel (refer to Figure 4) should be linked with the phase angle power stage when the external commands are needed. The limits for the analog speed command (maximum 3.5 volts) are given by an internal A/D converter limitation. The connectors MP1-Speed, MP2-Start/Stop, and MP3-GND are provided on-board. NOTE: The control panel must be isolated from the user under all possible circumstances. VCC 4 R1 4 k7 SPEED GND START/STOP 1 0–3.5 VOLTS R2 10 kΩ SW1 START/STOP 3 2 STOP = OPEN, START = VCC Figure 4. External Control Panel The DIP switch, SW1, allows an option of the drive’s functionality and is discussed later. There are no pulldown or pullup resistors because these devices are provided directly on the chip. The appropriate resistors are enabled in a mask option register. AN1662 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Synchronization As is well known, the phase angle drive system needs to have information about the line voltage and its zero crossing points. The appropriate signal is connected to pin PB6. Only two resistors (R8 and R9), one capacitor (C9), and a diode (D2) (as overvoltage protection) are used. Due to its simplicity and its low-cost solution, the output signal is not a real square wave. Freescale Semiconductor, Inc... In Figure 4, the relationship between the line voltage and the synchronization signal can be seen. The positive half period and the negative half period are not identical. This situation causes a distortion of the motor current. Under this condition, the phase angle drive works but the triac is overloaded during one half period. Figure 5 also shows the current of the motor including the software adjustment. Fine correction can be done by software to avoid unequal half periods of the current. 11.38011.380 ms ms 8.620 ms 8.620 ms INPUT LINE VOLTAGE SYNCHRONIZATION ON PIN PB6 MOTOR CURRENT Figure 5. Synchronization Signal AN1662 8 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Control Algorithm Control Algorithm The basic principle of the phase angle control algorithm is simple: match the firing pulse time of the triac in relation with the zero crossing of the line voltage. A phase shift of this firing pulse produces a variable output voltage on the load. A structure with four interrupts has been chosen to ensure proper functionality and some additional CPU performance capacity. Freescale Semiconductor, Inc... Figure 6 shows a state diagram. The software consists of a control block and some subroutines like MAKE_ZERO, MAKE_PI, RAMPE, watchdog, and interrupt services routines. The control block is, in fact, a relatively short loop which makes a decision on which subroutines will be called. There is also a universal timing routine which works with the hardware (HW) timer and a unique register for every timed subroutine. The timing routine calculates the difference between the HW timer and a particular register and, in case of coincidence with the given number (time interval), it calls the appropriate subroutines. The same principle is used for all time conditions. A DIP switch with three connected switches (refer to Figure 7) is available on the board. Two of them are tested by the discussed software (switches 2 and 3) and one is free for customer use (switch 4). The control block tests the switch 2. This switch selects demo mode or start/stop mode. In demo mode, the drive starts automatically and runs in a 3-step endless loop. In start/stop mode, both the external START command and the analog external speed command are necessary. AN1662 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note RESET INITIALIZATION DONE MOTOR STOP DONE END OF CONTROL BLOCK RUN APPLICATION UPDATED DEMO SWITCH OFF DEMO SWITCH ON Freescale Semiconductor, Inc... DEMO TABLE HANDLER PUSH TEST START BUTTON PUSH-START DEMO CYCLE UPDATED CONTROL BLOCK TIME FOR RAMPE TIME FOR PI RTS MAKE_ZERO ZERO CROSSING RTS RAMPE RTS MAKE_PI TIME FOR WATCHDOG WATCHDOG 3 4 Figure 6. Program State Diagram ON — 50 HZ 1 ON 2 ON — DEMO CYCLE AVAILABLE OFF — 60 Hz OFF — START/STOP MODE NOT CONNECTED Figure 7. DIP Switch SW1 AN1662 10 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Control Algorithm MAKE_ZERO Subroutine The MAKE_ZERO subroutine is entered when the zero crossing of the line voltage occurs. The main job is to prepare the new value for the output compare interrupt service routine. The calculation is based on the half period of the line voltage. Since this time is different for 50 Hz and 60 Hz, switch 3 distinguishes between these two cases. The input value for the calculation is an output value from the PI controller. The recalculation is done according to the position of switch 3 and the known speed of the HW timer. Freescale Semiconductor, Inc... The second task of the MAKE_ZERO subroutine is to start the A/D converter. The A/D converter is needed for the start/stop mode when the external analog speed command, connected to pin PB4, needs to be converted. The A/D converter has several options, and it is based on the two on-chip voltage comparators and a selectable charge/discharge function. Voltages are resolved by measuring the time it takes an external capacitor to charge up to the level of the measured unknown input voltage. The external capacitor can be calculated from this expression: CEXT = (N x ICHG x P) / (VX x fOSC) Where: N = Number of counts during charge time 255 ICHG = Charge current 100 µA P = Prescaler value 8 VX = Maximum input voltage 3.5 V fOSC = Oscillator clock frequency 4 MHz CEXT = (255 x 100x10-6 x 8) / (3.5 x 4x106) = 14 nF From the several working modes available on the MC68HC705JJ7, option mode 1 with manual charge control and automatic discharge was chosen. The analog subsystem can generate interrupts. An analog interrupt occurs when there is a match in the input conditions for the voltage comparator. This analog interrupt is used to make achieving the result easy. AN1662 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note MAKE_PI Subroutine The MAKE_PI subroutine is entered only when two conditions are fulfilled: The time condition occurred, and the output compare occurred. Because the MAKE_PI subroutine is a time-consuming part of the software (700 µs), it is placed in the time window where no important actions are expected (refer to Figure 10). Freescale Semiconductor, Inc... The main job of the software is the calculation of the actual speed and the calculation of the PI controller. The input value for the speed calculation is a good, filtered, 16-bit output value from the input capture interrupt. A 32/16-bit division is used where the 32-bit number is a constant and the 16-bit number is the output from the input capture interrupt. The constant can be calculated from this expression: CONST = N x INCAPMin Where: CONST = Constant for division N = Maximal number of result 255 INCAPMin = Minimal number of counts between two edges of tachometer signal (250 for 15,000 RPMs and 4-MHz crystal) CONST = 255 x 250 = 63 750 (0000F906 hex) For the PI controller, a well-known equation is used: V = VZ_1 + P_CONST x (E - EZ_1) + I_CONST x E Where: V = Actual new value VZ_1 = V in last step P_CONST = Proportional constant E = command_speed — actual_speed EZ_1 = E in last step I_CONST = Integration constant The output from the PI controller provides the input value for the output compare interrupt service subroutine. AN1662 12 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Freescale Semiconductor, Inc... Application Note Interrupts RAMPE Subroutine The RAMPE subroutine is entered when a time event occurred. This subroutine in fact changes the slope of the command speed’s signal. The slope is the same for the rising and falling edges. The slope can be modified through a change in the time interval for the RAMPE subroutine. Watchdog Subroutine The watchdog subroutine is entered when the watchdog register has not been updated for approximately 4 seconds. The input capture interrupt service routine, as a result of the running motor, takes the responsibility for the watchdog register. By this arrangement, it is possible to protect the motor when the shaft is blocked. In this case, the watchdog will turn off the triac and will wait for a new START command. Interrupts As was mentioned in Control Algorithm, four interrupts are used (refer to Figure 8). They are: • The simplest interrupt is the timer overflow interrupt. The appropriate service routine is the timer overflow interrupt service routine (TOISR), and it enables the input capture interrupt. • The input capture interrupt service routine (ICISR) is allowed to run six times, and it calculates an average value of the time interval between the rising edges of the tachometer signal. • The analog interrupt service routine (ANISR) reads and stores the new value from the A/D converter. • The output compare interrupt service routine (OCISR) generates the pulses for the triac (refer to Figure 9). AN1662 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note ENABLE 6X IC RTI ANALOG INTERRUPT A/D CONVERSION RTI TIMER OVERFLOW INTERRUPT Freescale Semiconductor, Inc... RUN APPLICATION OUTPUT COMPARE INTERRUPT RTI SENSE TACHO SIGNAL INPUT CAPTURE INTERRUPT RTI MAKE TRIAC PULSE Figure 8. Interrupt Service Routines Figure 9. Timing of SW Subroutines AN1662 14 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Microcontroller Usage Microcontroller Usage Total RAM and ROM Used Table 2 shows how much memory was needed to run the phase angle drive. A significant part of the memory is still available. Freescale Semiconductor, Inc... Table 2. Memory Usage I/O Use Memory Available Used SRAM 224 bytes 54 bytes ROM 6.1 Kbytes 1.17 Kbytes Table 3 summarizes the use of the I/O pins. Three pins are still available. Table 3. I/O Pin Usages I/O Port A Port B Available Pins Used Pins Purpose PA0–PA5 PA0–PA2 PA3–PA5 DIP switch Triac PB0–PB7 PB0 PB3 PB4 PB6 PB7 External capacitor Tachometer External speed Synchronization External START Parts List and PCB Component parts are listed in Table 4. Figure 10 and Figure 11 show the printed circuit board (PCB) layout. AN1662 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Table 4. Parts List Freescale Semiconductor, Inc... Component Quantity Value/Rating Description U1 1 — IC, MC68HC05JJ6P or MC68HC705JJ7P U2 1 — IC, LM393N Q1 1 4 A, 800 V Triac, MAC4DCN-1 X1 1 4 MHz Resonator D1 1 1.0 A, 1000 V Diode, 1N4007 D2 1 5.1 V, 1.0 W Zener diode, 1N4733A D3 1 1.0 A, 20 V Schottky diode, 1N5817 D4 1 5.6 V, 1.0 W Zener diode, 1N4734A R6 1 150 Ω, 1/4 W Resistor R7 1 470 Ω, 1 W Resistor R8 1 220 kΩ, 1/4 W Resistor R9, R11, R12 3 47 kΩ, 1/4 W Resistor R15 1 3.3 kΩ, 1/4 W Resistor R16 1 2.2 kΩ, 1/4 W Resistor R17 1 4.7 kΩ, 1/4 W Resistor R18 1 470 Ω, 1/4 W Resistor R19 1 100 kΩ, 1/4 W Resistor 10 kΩ, 1/4 W Resistor R20 C1 1 470 mF, 25 V Capacitor electrolytic C2 1 330 nF, 400 V Capacitor C4 1 15 nF, 50 V Capacitor C5, C6 2 18 pF, 50 V Capacitor C7, C8, C11 3 100 nF, 50 V Capacitor C9 1 1 nF, 50 V Capacitor C10 1 220 nF, 50 V Capacitor F1 1 4A Fuse J1–J6 6 — Connector SW1 1 — DIP switch MP1–MP3 3 — Connector AN1662 16 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Freescale Semiconductor, Inc... Application Note Parts List and PCB Figure 10. PCB Layout Component Side Figure 11. PCB Layout Copper Side AN1662 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Application Note Freescale Semiconductor, Inc... Performance of the Sample Design The sample design performed with these measurements: • Input voltage — 220-volt RMS • Input current — 1 A-RMS without heatsink and without load • Motor — 400 W with tachometer • Demo mode — Automatic START; no speed reference needed • Start/Stop mode — START, external +5 volts, external speed reference 0 volt to 3.5 volts • Speed — 1000 to 15,000 RPMs Conclusion This application note describes a real application, which can be used in a low-cost product. The unused memory and some performance capacity are still available for other customer purposes. These facts make this application especially suitable for the appliance market. References The World Wide Web page for this application can be found on the ON Semiconductor’s Web site. Other references include: • MAC4DCM Data Sheet from ON Semiconductor • MC68HC05JJ6/JP6 General Release Specification, Freescale document order number HC05JJ6GRS/D • Single-Slope Analog-to-Digital (A/D) Conversion, Freescale document order number AN1708/D • MC68HC705JJ7 General Release Specification, Freescale document order number HC705JJ7GRS/D AN1662 18 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Freescale Semiconductor, Inc... Application Note References AN1662 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. N O N - D I S C L O S U R E Freescale Semiconductor, Inc... A G R E E M E N T R E Q U I R E D Application Note How to Reach Us: Home Page: www.freescale.com E-mail: [email protected] USA/Europe or Locations Not Listed: Freescale Semiconductor Technical Information Center, CH370 1300 N. Alma School Road Chandler, Arizona 85224 +1-800-521-6274 or +1-480-768-2130 [email protected] Europe, Middle East, and Africa: Freescale Halbleiter Deutschland GmbH Technical Information Center Schatzbogen 7 81829 Muenchen, Germany +44 1296 380 456 (English) +46 8 52200080 (English) +49 89 92103 559 (German) +33 1 69 35 48 48 (French) [email protected] Japan: Freescale Semiconductor Japan Ltd. Headquarters ARCO Tower 15F 1-8-1, Shimo-Meguro, Meguro-ku, Tokyo 153-0064 Japan 0120 191014 or +81 3 5437 9125 [email protected] Asia/Pacific: Freescale Semiconductor Hong Kong Ltd. Technical Information Center 2 Dai King Street Tai Po Industrial Estate Tai Po, N.T., Hong Kong +800 2666 8080 [email protected] For Literature Requests Only: Freescale Semiconductor Literature Distribution Center P.O. Box 5405 Denver, Colorado 80217 1-800-441-2447 or 303-675-2140 Fax: 303-675-2150 [email protected] Information in this document is provided solely to enable system and software implementers to use Freescale Semiconductor products. There are no express or implied copyright licenses granted hereunder to design or fabricate any integrated circuits or integrated circuits based on the information in this document. Freescale Semiconductor reserves the right to make changes without further notice to any products herein. Freescale Semiconductor makes no warranty, representation or guarantee regarding the suitability of its products for any particular purpose, nor does Freescale Semiconductor assume any liability arising out of the application or use of any product or circuit, and specifically disclaims any and all liability, including without limitation consequential or incidental damages. “Typical” parameters which may be provided in Freescale Semiconductor data sheets and/or specifications can and do vary in different applications and actual performance may vary over time. All operating parameters, including “Typicals” must be validated for each customer application by customer’s technical experts. Freescale Semiconductor does not convey any license under its patent rights nor the rights of others. Freescale Semiconductor products are not designed, intended, or authorized for use as components in systems intended for surgical implant into the body, or other applications intended to support or sustain life, or for any other application in which the failure of the Freescale Semiconductor product could create a situation where personal injury or death may occur. Should Buyer purchase or use Freescale Semiconductor products for any such unintended or unauthorized application, Buyer shall indemnify and hold Freescale Semiconductor and its officers, employees, subsidiaries, affiliates, and distributors harmless against all claims, costs, damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or death associated with such unintended or unauthorized use, even if such claim alleges that Freescale Semiconductor was negligent regarding the design or manufacture of the part. For More Information On This Product, Go to: www.freescale.com