AN1449 APPLICATION NOTE
ST6200C UNIVERSAL MOTOR DRIVE SOFTWARE
by Microcontroller Division Application Team
INTRODUCTION
Th is application note describes the software of a low-cost phase-angle motor control drive system based on a ST6200C microcontroller and a BTB16-600CW snubberless triac. The application has been developed by STMicroelectronics and is available as a low-cost evaluation board UMC01EVAL. Th is board can be widely used in many applications such as vacuum cleaners, power tools, food processors and lighting dimmers. The microcontroller implements the following functions:
s
Speed control: the motor speed is set by a potentiometer on the board. With a look up table, the MCU can convert speed commands to firing angle delay times. The power delivered to the motor can be adjusted by changing the firing angle with reference to the voltage zero crossing signal. S oft start: This reduces the motor inrush current at start-up. Mains Period Measurement: In order to reduce system cost, a RC oscillator is used on the UMC01EVAL board as the MCU clock source. However its frequency can vary up to +/-20% because it is highly dependent on power supply voltage and temperature. To control the motor accurately, the mains power line period is measured and used as a time base.
s s
AN1449/1001
1/11
1
ST62 00C UNIVERSAL MOTOR DRIVE SOFTWARE
1 HARDWARE DESCRIPTION
1.1 GENERAL INFORMATION The schematics of universal motor control board are shown in Figure 1. On this board, a low cost capacitive power supply generates +5V voltage for the ST6200C MCU and its application circu it. The motor speed control is managed by the ST6200C 8-bit MCU. The MCU clock is generated by on-board RC network. The internal 8-bit timer is used for the triac triggering control. The voltage zero crossing event is detected by two current limiting resistors (R6 & R7). Th e microcontroller triggers the snubberless triac BTB16-600CW directly with its 20mA outputs. Three high sink outputs can supply 60mA gate currents (IGT=35mA). This board is able to drive a universal motor up to 1500W. 1.2 BOARD SCHEMATICS Figure 1. UMC01EVAL Board Schematics
VC C J1 NEUTRAL
D1 BZX85C5.6 D2 1N4148
C2 220uF/16V
C1 100nF R2 3K R4 47K 1 2 3 4 5 6 U1 VD D OSCIN OSCOUT NMI VPP/TEST RST PB7/AIN4 PB6/AIN3 ST62T00 VSS PA1 PA2 PA3 PB0 PB1 PB3/AIN1 PB5/AIN2 16 R3 150R 15 14
R1 1R/2W
Q1 BTB16-600CW
13 12 11 10 9
C4 100nF R6 220K C3 470nF/400V
7 8
VC C
16Pin Socket
J3 R5 470R/1W R7 SPEED 220K 10K
MOTOR
J4
F1 J2 LINE FUSE 10A
The hardware environment of the MCU has the following features:
s s
The MCU oscillator is implemented by an on-board RC network. No external reset circuit is used, this function is handled by the Low Voltage Detector option of the ST6200C. The voltage zero crossing event is detected through current limiting resistors (R6 & R7). R1 is reserved for future use. It must be replaced by a jumper when the board is running in open loop mode. In closed loop, it is used as a shunt resistor. It can measure the motor peak current.
s s
2/11
2
ST62 00C UNIVERSAL MOTOR DRIVE SOFTWARE
2 MAIN PROGRAM
2.1 RC OSCILLATOR In most applications, the MCU internal clock is supplied by a quartz crystal or a ceramic resonator. On this board, for cost reasons, it has been chosen to generate the system clock with an external resistor (the capacitor is implemented internally). However as a result of this choice, clock accuracy is only about +/-20% because the RC oscillator frequency is highly dependent on supply voltage and temperature variations. For more details, please refer to the Clock and Timing Characteristics Section of the ST6200C datasheet. 2.2 MAINS PERIOD MEASUREMENT To obtain a more accurate clock source for driving the motor, the AC power line period is me asu re d by the microcontroller. It is used as a system clock reference. The voltage zero crossing detection is performed by the ST6200C NMI interrupt with two current limiting resistors (R6 & R7). The interrupt (falling edge only) is generated at each negative voltage zero cro ssin g event. It triggers the internal 8-bit Timer Counter Register (TCR) to measure the power line period. The result is stored in the T50HZ register. In 220V/50Hz applications, the value of T50HZ register corresponds to 20ms when the timer input clock division factor in the Timer Status Control Register (TSCR) is 64. The same value corresponds to 10ms when the timer input clock division factor is 32. 2.3 TIMING DEFINITION OF MAIN PROGRAM The basic principle of the phase angle control algorithm is very simple. The ST6200C can detect the beginning of a full wave by detecting the negative voltage zero crossing event, after which it can calculate the phase angle, load the phase delay time PHASE in the 8-bit Timer Coun ter Register (TCR) and start the timer counting. W h e n the timer expires, the Timer Counter Register (TCR) is reloaded with a value in T50N EW register which is equivalent to the duration of one half cycle (e.g. 10ms at 50Hz), after which the first TRIAC triggering pulse is generated. Be aware that the value in the T50HZ register must be compensated with a look up table (RCTAB) in order to eliminate the fluctuation of the RC oscillator frequency within one full wave cycle. The compensated value is stored in the T50NEW register. To obtain the duration of a half cycle, we can use the same value in the T50NEW register and divide the corresponding timer input clock frequency by 2. It can be easily implemented by selecting the division factor of prescaler bits in the Timer Status Control Register (TSCR). Th e time base T50HZ of the power line period is averaged every 16 full wave cycles (e.g. 320ms at 50Hz) in order to eliminate the influence of the RC oscillator. After that, the potentiometer measurement is performed with the internal A/D converter. The new speed command
3/11
ST62 00C UNIVERSAL MOTOR DRIVE SOFTWARE
goes through the ramp up or down subroutine and speed look up table (VREFTB). The new phase angle in the PHASE register for the next cycle is computed. In addition, as mentioned above, the full wave timer value in register T50HZ must be compensated with the look up table (RCTA B) at different phase angles. This new value is stored in the T50NEW register. When the half-cycle timer reaches zero, the second triac triggering pulse is generated. After that, the Timer Counter Register (TCR) is reloaded with 255 and starts counting. It is used as a capture to measure the duration from the second triggering pulse to the next voltage zero crossing event. When the next voltage zero crossing interrupt occurs, the timer will be stopped by software. The duration from the second gate pulse to the zero crossing interrupt is stored in the DELTAT register. The full wave time will be equal to the sum of DELTAT, T50NEW and PHASE. In total, one mains full wave period is divided into three parts: phase angle (PHASE register), half wave period (T50NEW register) and the rest (DELTAT register). The timing definition of main program is shown in Figure 2. Figure 2. Timing Definition of Main Program
ZV C Interrupt Get DELTAT Reload Timer Ti mer Interrupt Reload Timer Fir e TRIAC T50HZ Update Perfor m ADC Soft Start Calculate PHASE Timer Interrupt Me as ure DELTAT Fire TRIAC
Mains Voltage
N MI
Triac Pulse PA1/ PA2/ PA3
Timer
PHA SE
T50 NEW MA INS PERIOD
DE LTAT
4/11
ST62 00C UNIVERSAL MOTOR DRIVE SOFTWARE
3 GATE PULSES
3.1 GENERAL DESCRIPTION The gate current pulses are generated during the main program (refer to Figure 2). Appendix 1 gives the flowchart of the main program. As soon as a ZVC event is detected, the ST6200C reloads the timer with the phase angle delay time and starts the timer. When the timer reaches zero , the first gate triggering pulse is generated. The timer is reloaded and enabled with a value of one half-cycle. When the timer reaches zero, the second gate triggering pulse is generated within one full wave cycle. 3.2 PHASE ANGLE CALCULATION To eliminate the timer clock variations due to voltage and temperature drift, the timer clock must be synchronized with the line voltage zero crossing. The power line period is measured by the ST6200C internal 8-bit timer. The resulting half cycle period is stored in the T50HZ register and used as the system clock. This number is then divided by 256, which results in 256 steps per half wave. With this division, 256 discrete phase angles are possible. This results in a resolution of 0.7 degrees. The actual phase angle PHASE is calculated as follows:
T 50 H z × V r e f P H A S E = -----------------------------------256
Dividing by 256 is simply implemented by considering the Most Significant Byte of the multiplication result of T50Hz and speed reference (Vref). A look-up table relating the delay time to the power requirement contains 64 different levels. The conduction time of the triac can be varied from 1.6ms to 9.2ms for a 50Hz application. The user can easily adjust the minimum and maximum power levels by changing the look up table. 3.3 GATE PULSE GENERATION A universal motor is an inductive load. The motor current and input voltage are not in phase. The triac will turn off at the current zero crossing. To reduce component cost, the phase shift between current and voltage is not measured but can be adjusted by defining the maximum speed constant v_max. This constant should be decreased if the phase shift between voltage and current is too large.
5/11
ST62 00C UNIVERSAL MOTOR DRIVE SOFTWARE
3.4 INTERRUPT SERVICING TIME The timer is not started immediately when an interrupt request occurs. This is because some instructio ns are executed before starting the timer. For example, before starting to count the first phase angle time, the program must run the NMI interrupt routine, save the DELTAT result, reload the timer and restart the timer. This takes 33 CPU cycles. To take the code execution time into account, we should convert it to the timer counter value (Tcode). As we know, the MCU oscillator frequency (fCPU) is divided by 13 to drive the CPU core. Therefo r e , "N" CPU cycles execution time is 13xN/fCPU seconds. The MCU oscillator frequency (fCPU) is divided by 12 to drive the internal timer, and then it is divided by the division factor programmed in the TSCR register. In this software, the division factor is 32 during the main program. Therefore, one unit timer counter equals 12x32/fcpu seconds. We can easily work out the relationship between N cycles of code execution time and the timer counter value (Tcode), as shown below: N × 13 fcpu 13 T c o d e = --------------- × ----------------- = N × -------fcpu 12 × 32 384 For example, the code execution time for 33 cycles approximately equals one unit of the timer co u n t .
6/11
ST62 00C UNIVERSAL MOTOR DRIVE SOFTWARE
4 SUBROUTINES
4.1 POWER ON RESET After each RESET interrupt, a complete initialization procedure is executed. This subroutine co nfig ures the Port A & Port B, Timer, A/D Converter, Interrupt Option Register and Status Flag Registers. It waits 100ms for the supply stabilization, and then it measures the mains period. The flowchart of this subroutine is shown in Appendix 1. 4.2 SOFT START Th e soft start subroutine is entered when an acceleration or deceleration event occurs. The soft start feature enhances the life of bulbs, reduces coil stresses in motors, and extends the life of most loads. It can reduce the inrush current and prevent voltage fluctuations and flicker in the power supply (Refer to Flicker Norm EN61000-3-3). This subroutine in fact changes the slope of the speed command. The slope is the same for the accelerating and decelerating edge. It can be modified by changing the step constant. This flowchart is shown in Appendix 3.
5 CONCLUSION
This application note describes the software of a low cost universal motor control system. It is intend to help you to use this software as a basis for developing your own motor drive and to adapt it to your own requirements. The software is tested with the Raisonance RIDE ST6 Version 6.0.1 Assembler. For other assemblers the software must be adapted.
7/11
ST62 00C UNIVERSAL MOTOR DRIVE SOFTWARE
APPENDIX 1 - POWER ON RESET FLOWCHART
Figure 3. Power on Reset Flowchart
RESET
T i m e r & A D C In i t i a l i s a t i o n
R e g i s t e r s In i t i a l i s a t i o n S t a t u s F l a g In i t i a l i s a t i o n
P O R T A & B C o n f ig u r a t io n I n t e r r u p t O p ti o n R e g is t e r In i t i a l i s a t i o n W a it 1 0 0 m s M e a s u r e M a in s P e r io d (T 5 0 H z ) S e t M in i m u m M o t o r S p e e d P h a s e A n g l e C a lc u la tio n
M A IN _ P R O G
8/11
ST62 00C UNIVERSAL MOTOR DRIVE SOFTWARE
APPENDIX 2 - MAIN PROGRAM FLOWCHART
Figure 4. Main Program Flowchart
M AI N_ P R OG
W ait for ZVC event
Pro ces s Acceleration or Deceleration Soft Start G et Next Speed Command MVOLD Proc es s Speed Look Up Table Calcu la te the next phase angle time (PHASE) M ak e Half Cycle Time Symmetrical Compensation T 50N E W
Sa ve TCR in DELTAT Load Timer with Phase Angle R es tart Timer Wait for Timer Interrupt Load Timer with T50NEW R es tart Timer G enerate TRIAC Triggering Pulse on PA1/PA2/PA3
16 times full wave cycles passed? Yes M a ke the average of T50HZ U pdat e T50HZ Register
No
W ait for Timer Interrupt
Conf igure Timer to Measure DELTAT Gene rat e TRIAC Triggering Pulse on PA1/PA2/PA3
C onf ig ure and Perform A/D Converter
Ge t New Speed Command M VN E W
M A I N_ P R O G
9/11
ST62 00C UNIVERSAL MOTOR DRIVE SOFTWARE
APPENDIX 3 - SOFT START FLOWCHART
Figure 5. Soft Start Flowchart
SOFT START
Get New Speed Command MVNEW
Accelerate
Accelerate or Decelerate Process?
Decelerate
Process Ramp Up
Process Ramp Down
Within A/D Converter Accuracy? No Yes Yes
Within A/D Converter Accuracy? No Within one Step Range?
Within one Step Range? No MVOLD = MVOLD + STEP
No MVOLD = MVNEW MVOLD = MVOLD - STEP
SPEED PROCESS
10/11
ST62 00C UNIVERSAL MOTOR DRIVE SOFTWARE
"THE PRESENT NOTE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT OF SUCH A NOTE AND/OR THE USE MADE BY CUSTOMERS OF THE INFORMATION CONTAINED HEREIN IN CONNEXION WITH THEIR PRODUCTS."
Information furnished is believed to be accurate and reliable. However, STMicroelectronics assumes no responsibility for the consequences of use of such information nor for any infringement of patents or other rights of third parties which may result from its use. No license is granted by implication or otherwise under any patent or patent rights of STMicroelectronics. Specifications mentioned in this publication are subject to change without notice. This publication supersedes and replaces all information previously supplied. STMicroelectronics products are not authorized for use as critical components in life support devices or systems without the express written approval of STMicroelectronics. The ST logo is a registered trademark of STMicroelectronics 2001 STMicroelectronics - All Rights Reserved. Purchase of I2C Components by STMicroelectronics conveys a license under the Philips I2C Patent. Rights to use these components in an I2C system is granted provided that the system conforms to the I2C Standard Specification as defined by Philips. STMicroelectronics Group of Companies Australia - Brazil - Canada - China - Finland - France - Germany - Hong Kong - India - Israel - Italy - Japan Malaysia - Malta - Morocco - Singapore - Spain - Sweden - Switzerland - United Kingdom - U.S.A. http://www.st.com
11/11
|