T. CASTAGNET
INTRODUCTION
Home appliance applications are requiring more and more electronic control in order to meetnew requests and constraints of consumers.
Microcontrollers have been typically limited to high end applications because theirperformance appears to be overrated when related to the functions of the application. Inreality, home appliances require microcontrollers which trade closely between the compromisebetween cost and performance.
An a.c. universal motor is a cost optimized solution for home appliance applications includingfood processor and drill applications.
This Application Note shows that the capabilities of simple 8-bit microcontroller allows thedesign of cost effective speed drive controller with increased functionality. When associated toa triac these microcontrollers become key components in the design of a sensorless speedcontrol.
1THE CONTROL OF THE MOTOR SPEED
An a.c. universal motor is a brush motor with a serial excitation. Its stator windings areconnected in series with the rotor, and its flux is proportional to the motor current. The motortorque is theoretically proportional to the square of the current, so it is always positive: thespeed direction is insensitive to the current direction, and the motor can be supplied in a.c. ord.c. modes. Control of the speed is obtained by adjustment of the motor voltage. This controlis achieved by a phase angle method in a.c. mode, or by a Pulse Width Modulation method ind.c. mode.
AN416 / 02,94SENSORLESS MOTOR DRIVE WITH THE ST62 MCU + TRIAC
Figure 1. The triac is a key device for thea.c. drive of the universal motor.Figure 2. A d.c. drive for the universalmotor: the P.W.M. chopper with IGBT.MMFor a fixed motor voltage the motor characteristic shows that the motor speed changes whenthe torque is varied: the control of the speed requires feed-back of the speed itself.
Figure 3. Universal motor torque T versusthe motor current Imot.Figure 4. Universal motor characteristicspeed torque (S,T) for a fixed motorvoltage Umot.STT = K.Imot ²Umot is fixed ImotSn: theoretic: realTnTThe tachogenerator is a classical speed sensor solution for home appliances. When theaccuracy of the speed is not a critical parameter, speed control is also possible without anyexternal speed sensors: thus reducing the number of components in the speed drive.
2/22SENSORLESS MOTOR DRIVE WITH THE ST62 MCU + TRIAC
Figure 5. Speed measurement schematicbased on tachogenerator sensor.Figure 6. Evaluation of the speed Sversus current Imot & voltage Umot of theSVccUmot : U1 < U2 SVsSnU2NSU1I1I2ImotThe back electromotive force (b.e.m.f.) of the motor is a function of the speed and of thecurrent. In the first approach it behaves as a resistance proportional to speed.
When the sensor is removed, the speed of the motor is determined by relating the averagemotor voltage and the average motor current. The controller defines the motor voltage by thetriac triggering time (a.c. mode), or by the chopper duty cycle (d.c. mode). A shunt resistorallows the peak motor current to be sensed.
Such a control method is feasible despite potential motor saturation and the brush voltage.The relations are not linear, however a microcontroller can solve the relations by using look uptables for calculations.
To improve the behavior of the speed drive on dynamic operations, the controller can alsoconsider the motor acceleration: this acceleration is represented by the motor currentvariation, ∆IMOT.This control method can be applied to the home appliance applications when the requirementon the speed accuracy is not very high. The sensor is not required, so the cost of the drive isreduced and its reliability is improved.
3/22SENSORLESS MOTOR DRIVE WITH THE ST62 MCU + TRIAC
2AN APPLICATION EXAMPLE
A basic speed drive has been designed with a 500 W a.c. universal motor. An 8 Amp - 600 VSNUBBERLESS triac drives the motor from the 230 V - 50 Hz mains. This drive is adapted toa drill application.
The speed drive control is fulfilled by an ST6220 microcontroller. This 8-bit microcontroller isable to calculate and to control the motor speed with no external sensor by using its on-chipanalog/digital converter (A/D) for the current measurement and its 8-bit timer for the triactriggering control.
Figure 7. Application diagram of a speed drive for an 500 W a.c. universal motor.BTB 08 600 CWN0.2 / 2 W3 K10047 nF100 uFVsSENSGATEOSCOUTOSCIN0 CROSS150M4 MHz5V6ST6220 hwd GNDLIMREF2x33pF1N400420 k100 kL2 x 8.2 k / 1W100 k2 MA shunt resistor measures the peak motor current: it is connected in series with the triac, andis referred to the positive supply polarity. Two potentiometers define the speed reference andthe torque limit. Two resistors allow the zero crossing of the line voltage to be captured.The microcontroller triggers the triac directly with its 20 mA outputs. At the triggering pointthree outputs supply a 50 mA gate current during 2 instruction cycles (24 µs): this pulse willsecure the triggering at low temperature or on accidental dI/dt. The two outputs then remainon during 500 µs, supplying the gate triggering current (IGT = 35 mA) until the triac latches. Thetriac driver consumption then becomes less than 2 mA.
An auxiliary supply generates a voltage of 5.6V: the low consumption of the HCMOSmicrocontroller and the pulse mode triac triggering minimize the total consumption (ICC < 5mA). So the required current is supplied by two 8.2 kΩ/1W decoupling resistors.
4/22SENSORLESS MOTOR DRIVE WITH THE ST62 MCU + TRIAC
Figure 8a. Triac triggering with doublepulse mode: diagram.BTB08 600CWFigure 8b. Triac triggering with doublepulse mode: chronogram.PA0PA1/2ST 6220PA0GATE PULSE24 µs50 mA35 mAPA 1/2500 µsThe control program achieves speed control and torque limitation. In addition to thesefunctions, a current measurement task and a.c. phase control are also made by the software.
Figure 9. Block diagram of the ST622x microcontrollers.A/DCONVERTER8 BITSTIMERPORT APORT BPORT C8 BITS DATA BUSWATCHDOGTIMER4 kBROM8 BITSCPU64 BYTESRAM20 or 28 pins packageThe speed control determines the motor voltage to be set and the triac triggering delay timeTD. At each mains cycle the A/D converter reads the value of the first potentiometer with a 64step scale. This value defines the speed reference by the means of a 64 byte look up table.The controller compensates for the effect of the motor current on the speed: it determines thecurrent correction through a 64 byte look up table.
5/22SENSORLESS MOTOR DRIVE WITH THE ST62 MCU + TRIAC
Finally it calculates the time TD by a combination between the speed reference and the currentcorrection.
The timer organizes the phase angle control. It is synchronized to the zero crossing of themains voltage. It delays the triac triggering to TD with an 0.5 % resolution and then generatesthe 500µs gate triggering pulse.
Figure 10. Flow chart of the speed control algorithm.INITIALIZATIONWAIT ZERO VOLTAGE CROSSINGYESIS THE CURRENTSTABLE ?NOTORQUE LIMITATIONCALCULATE TRIGGERING DELAY TIMELOAD TIMER FOR TRIGGERINGNOTD < 4 ms ?YESWAIT TRIAC TRIGGERINGAND CURRENT SENSINGGET SPEED REFERENCE ANDMAXIMUN TORQUE LIMITThe motor current measurement is managed by software, saving the need for external peakdetector components. After the triac is triggered, the timer synchronizes the A/D converter toread the shunt resistor. This read is done when the peak motor current is maximum. The peakcurrent instant time TC is determined versus the previous motor current value by the means ofa 64 bytes look up table.
6/22SENSORLESS MOTOR DRIVE WITH THE ST62 MCU + TRIAC
Figure 11. Flow chart of the 8 bits timer subroutine operation.TIMER INTERRUPTSTOP TIMERYESEND OF GATE OF GATE PULSE ?NOSWITCH OFF TRIAC GATETRIGGER TRIACSENSE THE CURRENTNOEND OF SENSE DELAY ?YESPROGRAMSENSE DELAYPROGRAM PULSE WIDTHEND OF INTERRUPTFigure 12. Measurement of the peak motor current with software peak detector.0 CROSSINGGATE PULSET cImotA/D CONV(SHUNT READ)The torque limitation controls the applied force of the drilling tool. The A/D converter reads thevalue of the second potentiometer to determine the requested torque limit on a 64 step scale.When the motor current is higher than this limit, the motor voltage is limited to a maximumvalue by limiting the delay time TD.
The total controller program occupies 640 bytes of ROM Memory, including the look up tablesof the speed reference, of the current correction, and of the current sense delay time.
7/22SENSORLESS MOTOR DRIVE WITH THE ST62 MCU + TRIAC
This simple program is designed for one application. To change it for another application ormotor, only the two look up tables related to the current (128 bytes) need to be modified. Thismicrocontroller plus triac board can thus drive several motor types, or the performance of theboard can be optimized for one or several fixed speeds. This flexibility is possible because ofthe MCU and of its 4 KByte memory size.
The speed of the designed drive ranges from 4000 to 25000 RPM. When the speed referenceis 5000 RPM, the speed decreases down to 3500 RPM at 5A peak; it then increases up to4500 RPM at 8A peak.
Figure 13. Variation of the speed S versus the peak motor current that represents the motorload.S( RPM )5000 Imot c. (A)0148The torque limitation is mainly effective at low speed: the torque can vary greatly and candecrease the quality of work of the tool. At high speed this limitation becomes uselessbecause the torque and the current are naturally limited by the high impedance of the motor.
8/22SENSORLESS MOTOR DRIVE WITH THE ST62 MCU + TRIAC
3CONCLUSION
This note presents a sensorless speed controller for an a.c. universal motor, using aSNUBBERLESS triac and an ST6220 microcontroller. The use of such a microcontrollerpermits the designer to reconsider the design of the brush motor speed drives: it also offersother methods to control the motor and simplifies the drive circuit by reducing the number ofcomponents used.
Moreover these ST62 microcontrollers increase the flexibility of the designed circuit. The samehardware circuit can fulfill the control of various motor types by changing only two look-uptables. Other functions such as the user interface (keyboard, display) can be easily added bysoftware to the power control.
The same approach can be extended to motor control in D.C. mode where an IGBT/MOSFETchopper and microcontroller control by P.W.M. are designed.
This study has been made with the collaboration of the company B.F.E. (France), which hasdevelopped the program and the demonstration board.4REFERENCES
[1] - Power control with triacs and ST6210 MCU
AN 392 - Ph. Rabier and L. Perier (SGS-THOMSON Microelectronics) [2] - Digital control for brush DC motor
T. Castagnet and J. Nicolai (SGS-THOMSON Microelectronics)International Appliance Technics, May 93[3] - Controlling a Brush DC motor with an ST6265
AN414 - J. Nicolai and T. Castagnet (SGS-THOMSON Microelectronics)PCIM Nuremberg, June 93
[4] - Improved universal motor drives
J.M. Bourgeois, J.M. Charreton, and P. Rault (SGS-THOMSON Microelectronics) AN422 - Improved Universal Motor Drive with ST62[5] - Improvement in the triac commutation
AN 439 - P. Rault (SGS-THOMSON Microelectronics) [6] - Data books of \" SCRs and TRIACS\" (DBSCRTRI/2)
and \" ST62XX MICROCONTROLLERS \" (DBST6ST/3)(SGS-THOMSON Microelectronics)
9/22SENSORLESS MOTOR DRIVE WITH THE ST62 MCU + TRIAC
Appendix 1. Sensorless speed control for the universal motor: customization of the controlprogram.
The software of the motor control is provided in appendix 3 and is named sens01.asm. It canbe adapted to an application by adjustment of the three look up tables (speed reference, peakcurrent instant time, and current compensation).
During the adjustments of the speed range and of the peak current detection the currentcompensation should be inhibited by clearing the current correction register INDEX.Adjustment of the no load speed range
The potentiometer connected to PB2 (pin 13) defines the speed reference S in conjunctionwith a 64 byte look up table VITT. This reference corresponds to the motor voltage UMOT andto the triggering delay time TD_O at no load.
The table VITT contains all no load delay times TD_O to define the speed range of the drive.The table values are defined by the full and minimum speed operation:
- the minimum triggering delay time (full speed) is defined by the motor power factor; the triaccan only be triggered when its anode current is cancelled;
- the maximum triggering delay time (minimum speed) is chosen to keep sufficient motormagnetization, so as to maintain a relationship between motor torque and current.
The true decimal values of the tables are calculated by dividing the triggering delay time TD_Oby the basic counting step of the timer (48 µs).
Figure 1. Variation of the no load speed versus the reference voltage given by the speedpotentiometer.So (rpm)30,00025,00020,00015,00010,0005,000001234REF So (V)55.610/22SENSORLESS MOTOR DRIVE WITH THE ST62 MCU + TRIAC
Figure 2. Variation of the no load triac triggering delay time vs the speed reference voltage.Tdo (ms)7654321001234555.6Ref So (V)Adjustment of the peak current detection
The peak current detection is made with the A/D converter connected on PB1 (pin 14). Thetimer synchronizes this operation to the triac triggering. The counted value is issued from a 64byte look up table RTMES and it is defined versus the previous peak motor current IMOT C.
The table RTMES is optimized experimentally at the lowest speed SMIN. The peak currentinstant TC after triggering is registered by test for several current values which are chosenbetween 1 A (8d numeric) and 8 Apk (64d numeric). For each case the decimal table value iscalculated by subtracting 650µs (triac triggering task duration) to the peak current instant TC,and by dividing the result by the basic timer step (48 µs).
Figure 3. Experimental plotting of the peak current instant TC versus the peak motor currentIMOT C at SMIN = 5000 RMP.Tc (ms)2,52,42,32,22,121,91,81,7024Imot c. (A)681011/22SENSORLESS MOTOR DRIVE WITH THE ST62 MCU + TRIAC
The other values of the table are calculated by linear interpolation on these 4 experimentalpoints. The resulting table is fine tuned by a final test. The table is optimized for a speed SMIN,but can extended to a larger speed range.Adjustment of the current compensation
Figure 4. Motor voltage waveforms with no load and nominal load.UmotUmotTdTd oC ( Imot c. )Speed control is done with a basic current compensation. When the load (and the motorcurrent) increases, the controller has to increase the motor voltage: it increases the b.e.m.f. tomaintain the motor speed.
The controller defines a current correction versus the peak motor current IMOT_C: C(IMOT_C). Thetriggering delay time TD is calculated by subtracting the no load triggering delay time TD_O bythis current correction:
TD_O = TD + C(IMOT_C)
The current correction values are stored in the current compensation table COUPLE. Thistable is optimized for the lowest operational speed SMIN, and its use could be applied to alarger speed range. The table calculation is done in two steps.
12/22SENSORLESS MOTOR DRIVE WITH THE ST62 MCU + TRIAC
Figure 5. Plotting of the current correction C(IMOT_C) issued form the COUPLE look up table.C ( Imot c) (ms)3.51Imot c. (A)0148: FINAL COMPENSATION: PRELIMINARY COMPENSATIONIn the first step the current corrections C(IMOT_C) are determined experimentally to obtain a purecompensation of the current influence, and to maintain the speed round SMIN. The INDEXregister is loaded with an immediate value C, and the peak motor current is measured on testwhen the motor speed is at SMIN. The numeric current value defines directly the location of Cin the table COUPLE. This test is done for several immediate INDEX values which are chosenbetween 0 and 80d (3.8 ms). The other values of the table are calculated by linearinterpolation on these experimental points.
In the second step the effect of the preliminary defined compensation is reduced on lowermotor current operation to give a good speed stability on dynamic operation. The currentcorrections which are decoded on lower motor current (less than 5 Apk), will be reduced andthe resulting table will be tested on the speed drive. On the higher current range thecorresponding corrections will be increased to maintain the speed in its operational range.
The resulting table offers a non linear current compensation that gives a good compromisebetween the speed stability at lower current and the speed decreasing at higher current.
13/2214/22P3NeutralC1D1BZX55B5V6U11VDDTIMEROSCINPA1PA2PA316R2100ΩBTB08600CW17T1OSCOUTNMIVPP/TESTRESETPB7PB6PB5PB411R12.7KPB213PB312PB015PB11418X14MHz234C35678R933K10933pFVSS20PA019R3150Ω0.2Ω / 1%R4100nFC51mF/6V3Appendix 2. Circuit diagram
C233pFST6210BP5R522KP1100KP2100KR62MC4500W68nFMot1SENSORLESS MOTOR DRIVE WITH THE ST62 MCU + TRIAC
MOTORR8R7D2P4Mot28.2K/1W8.2K/1W1N4007P6LineSENSORLESS MOTOR DRIVE WITH THE ST62 MCU + TRIAC
Appendix 3. Software example program.
;**************************** SENS 01 ************************************;* *;* SGS THOMSON MICROELECTRONICS *;* *;*************************************************************************;* SENSORLESS UNIVERSAL BRUSH MOTOR CONTROL *;* VERSION 2.0 *;* DECEMBER 1993 *;*************************************************************************;* This program was developped with the partnership of the company *;* B.F.E. . The address of our consultant is : *;* Raymond PORTIER, B.F.E. *;* 24, avenue du General LECLERC, 65200 Bagneres de Bigorre *;* Tel : (33).62.91.03.00 Fax : (33).62.91.03.87 *;*************************************************************************;* Circuit configuration and key features are : *;* - ST6220 microcontroller is designed in *;* - oscillator frequency : 4 MHz *;* - hardware watchdog device is implemented *;* - line zero crossing detection on PB0 with interrupt *;* - speed reference on PB2 ; torque limitation on PB3 *;* - torque limitation is stopped *;* - triac triggering delay time is between 0.4 and 6.5 ms *;* - triac gate drive on PA1, PA2 with boost on PA0 *;* - motor current detection on PB1 with ADC *;* - current shunt is 0.2 Ohms and detectable peak current is less *;* 8 Amps *;* - motor current detection time is shown by PA3 pointer *;* - soft start operation *;* *;*************************************************************************.W_ON
;************************** REGISTER DECLARATION *************************X .def 080h!M ; Index register.Y .def 081h ; Index register.
V .def 082h ; Short direct register.W .def 083h ; Short direct register.A .def 0ffh!M ; Accumulator.
PRA .def 0C0h ; Port a data register.PRB .def 0C1h ; Port b data register.PRAD .def 0C4h ; Port a direction register.PRBD .def 0C5h ; Port b direction register.•PRAO .def 0CCh ; Port a option register.PRBO .def 0CDh ; Port b option register.IOR .def 0C8h ; Interrupt option register.DRWR .def 0C9h!M ; Data rom window register.ADR .def 0D0h!M ; A/D result register.ADCR .def 0D1h ; A/D control register.
TPSC .def 0D2h ; Timer 1 prescaler register.TCR .def 0D3h ; Timer 1 counter register.
TSCR .def 0D4h ; Timer 1 status control register.WDR .def 0D8h ; Watchdog register.
15/22SENSORLESS MOTOR DRIVE WITH THE ST62 MCU + TRIAC
;*********************** DATA RAM REGISTERS ******************************VALR .def 099h!M ; motor current registerLOOP .def 087h ; counter
DX .def 088h ; back up of XDY .def 089h ; back up of YDXb .def 08Ah ; back up of XDYb .def 08bh ; back up of Y
FLIT .def 08ch ; motor control flag register ; b0 indicates 0 crossing pulse ; b2 indicates timer operation on ; triac triggering
; b3 indicates line polarity versus Vdd ; b4 indicates timer operation on ; current sensing delay ; b7 indicates timer operation ; b1, b5, b6 are unused hereDVALR .def 08eh ; previous VALR register valueCOMPT .def 08dh ; soft start counter
DPRB .def 08fh ; back up of port B data register
INDEX .def 091h ; motor current compensation registerADCcou .def 092h ; torque limitation registerADCcou1 .def 093h
ADCvit .def 094h!M ; speed reference registerADCvit1 .def 095h
DA .def 096h ; back up of ADAb .def 097h ; back up of A
;*********************** EQUATE DEFINITION *******************************OFSET .equ 008h ; offset subtracted from motor current ; in current compensation calculationOFSET1 .equ 007h ; offset subtracted from motor current ; in measure delay time calculationTGATE .equ 008h ; triac gate pulse duration 08h=385usTDTIM .equ 053h ; time limit to define priority between ; timer & potentiometers subroutinesTDMIN .equ 008h ; minimum trig. delay time 08h=385usTDMAX .equ 09ch ; maximum trig. delay time 9ch=9.0 msSTART .equ 002h ; step of soft start operation
;******************* BEGINNING OF PROGRAM AREA *************************** .org 0800h
;*************************************************************************;* SPEED REFERENCE TABLE *;*************************************************************************VITT .BYTE 86H,84h,82H,80H,7eH,7cH,7aH,78H .BYTE 76H,74h,72H,70H,6eH,6cH,6aH,68H .BYTE 66H,64h,62H,60H,5eH,5cH,5aH,59H .BYTE 58h,57H,56H,55H,54H,53H,52H,51H .BYTE 4fH,4dH,4bH,49H,47H,45H,43H,41H .BYTE 3fH,3dH,3bH,39H,37H,35H,33H,31H .BYTE 2fH,2dH,2bH,29H,27H,25H,23H,21H .BYTE 1fH,1dH,1bH,19H,17H,15H,13H,11H
;*************************************************************************;* CURRENT COMPENSATION TABLE *;*************************************************************************COUPLE .BYTE 00H,01H,01h,02H,03H,04H,04H,05H .BYTE 06H,07H,07H,08H,09H,0ah,0aH,0bH .BYTE 0cH,0dH,0dh,0eH,0fH,10H,10H,11H .BYTE 12H,13H,13H,14H,15H,16H,16H,17H
16/22SENSORLESS MOTOR DRIVE WITH THE ST62 MCU + TRIAC
.BYTE 18H,19H,19h,1aH,1bH,1cH,1dH,1eH .BYTE 1fH,20H,21H,22H,23H,24H,25H,26H .BYTE 27H,29H,2ah,2bH,2cH,2eH,2fH,30H .BYTE 31H,33h,34H,35H,37H,38H,3bH,3eH
;*************************************************************************;* PEAK CURRENT INSTANT TIME TABLE *;*************************************************************************RTMES .BYTE 0aH,0ah,10H,10H,10H,11H,11H,11H .BYTE 12H,12H,12H,13H,13H,13H,14H,14H .BYTE 14H,14H,14H,15H,15H,15H,15H,15H .BYTE 16H,16H,16H,16H,16H,17H,17H,17H• .BYTE 17H,17H,17H,18H,18H,18H,18H,18H .BYTE 18H,19H,19H,19H,19h,19H,1aH,1aH .BYTE 1aH,1aH,1bH,1bh,1bH,1cH,1cH,1cH .BYTE 1dH,1dH,1eH,1eH,1fH,20H,20H,21H
;*************************************************************************;* INITIALIZATION *;*************************************************************************start ldi WDR,0feh ; watchdog initialization ldi X,084h
raz clr A ; clear the RAM ld (X),A inc X ld A,X cpi A,0d5h jrc raz
INIT ldi PRA, 0fh ; port A in push pull output ldi PRAD, 0fh ; connected at Vdd ldi PRAO, 0fh
ldi PRB, 0eh ; PB0 in interrupt input, PB1 in analog ldi PRBD, 00h ; input, PB4/5/6/7 in pull up inputs, ldi PRBO, 03h ; PB2/3 in HI input
ldi ADR,00h ; A/D conv. initialization ldi ADCR,00h ; ADC is stopped
ldi FLIT, 00h ; clear logic and application registers ldi COMPT, 0ah ; ldi INDEX, 00h ; ldi VALR, 00h ;; ldi DVALR, 00h ; ldi ADCvit, 09fh ;
ldi IOR,10h ; interrupt validation
; PB0 interrupt on falling edge reti
;*************************************************************************;* MAIN PROGRAM *;*************************************************************************;*********************** SOFT START TASK ********************************SOFT1 jrr 0,FLIT,SOFT1 ; wait 0 crossing ( # 1 ) res 0,FLIT call VIT
ldi A,TDMAX
; ld A,ADCvit ; ENABLE THIS INSTRUCTION TO INHIBIT
17/22SENSORLESS MOTOR DRIVE WITH THE ST62 MCU + TRIAC
; THE SOFT START
SOFT2 jrr 0,FLIT,SOFT2 ; wait 0 crossing ( # 2,.., n-1 ) res 0,FLIT ; reset b0 of FLIT ld TCR,A ; load timer register
ldi TSCR,01111100b ; start timer with interrupt & PSC = 16 set 7,FLIT ; control timer cycle with b7 indicatorATINI jrs 7,FLIT,ATINI ; wait end of timer operation subi A, START cp A, ADCvit jrnc SOFT3 jp SOFT4SOFT3 jp SOFT2
SOFT4 ld A, ADCvit
;***************** MAIN MOTOR CONTROL PROGRAM ****************************MAIN jrr 0,FLIT,MAIN ; wait 0 crossing ( # n ) res 0,FLIT
MAIN1 ldi DRWR,COUPLE.W ; define motor current compensation ld A, VALR ; A <= VALR motor current measure subi A, OFSET ; A <= VALR - OFSET , jrnc MAIN4 clr A
MAIN4 cpi A, 040h ; check VALR to max. value jrc MAIN3
ldi A, 03fh ; limit VALR to its max. value
MAIN3 addi A, 040h
ld X, A ; load VALR@ in X register
MAIN2 ld A, (X) ; calculate current compensation data; ****** TORQUE LIMITATION TASK ******
jp MAINc ; ENABLE THIS INSTRUCTION TO STOP ; TORQUE LIMITATION cp A, ADCcou ; jrc MAINc
ld A, ADCcou ; limit to the max. requested torque; ******** SPEED CONTROL TASK ********MAINc ld INDEX,A
; ldi INDEX,00h ; ENABLE THIS INSTRUCTION TO INHIBIT ; CURRENT COMPENSATION
MAIN5a ld A, ADCvit ; load speed reference
sub A, INDEX ; substrate current comp. to speed ref. jrnc MAIN5
ldi A, TDMIN ; limit trig. delay time to min. value; ***** PHASE ANGLE CONTROL TASK *****
MAIN5 ld TCR,A ; load timer for triac triggering delay ldi TSCR,01111100b ; start timer with interrupt & PSC = 16 set 7,FLIT ; b7 <= 1, b7 indicates timer operation; ****** DELAY TIME CONTROL ******
cpi A, TDTIM ; if Tdelay > TDMIN,
jrc MAINm ; then read references before triggering
18/22SENSORLESS MOTOR DRIVE WITH THE ST62 MCU + TRIAC
; ****** SPEED REFERENCE & TORQUE LIMIT TASK *****
jrr 3,FLIT,ATfin ; read potentiometer when Vac is > 0 call VIT ; read speed ref. & torque lim.ATfin jrs 7,FLIT,ATfin ; wait end of timer operation JP MAIN
MAINm jrs 7,FLIT,MAINm ; wait end of timer operation
jrr 3,FLIT,FIN ; read potentiometer when Vac is > 0 call VIT ; read speed ref. & torque lim.FIN jp MAIN
;*************************************************************************;* PROGRAM SUBROUTINES *;*************************************************************************;*************** CURRENT MEASUREMENT SUBROUTINE *************************ADC ldi PRB, 0eh ; PB1 in A/D input ldi PRBD, 00h ldi PRBO, 03h
ldi ADCR, 30h ; start conversion
ADC1 jrr 6,ADCR,ADC1 ; wait end of conversion ld A, ADR ; A <= ADR
com A ; complement A/D result to obtain ; current measure referred to Vss
ADC2 ld VALR, A ; update motor current measure in VALR ret
;******** SPEED REFERENCE & TORQUE LIMITATION MEASURE SUBROUTINE *********; ****** SPEED REFERENCE MEASUREMENT TASK *******
VIT ldi PRB, 0eh ; PB2 input connected on A/D converter ldi PRBD, 00h ldi PRBO, 05h
ldi ADCR, 30h ; A/D conversion start
VITadc jrr 6,ADCR,VITadc ; wait at end of conversion ld A, ADR ld ADCvit, A
ldi X, ADCvit ldi ADCvit1,00h call DIV4
ldi DRWR,VITT.W ; convert measured value in ld A, ADCvit1 ; triac triggering delay time addi A, 40h ld X, A ld A, (X) ld ADCvit,A
; ****** TORQUE REFERENCE MEASUREMENT TASK ******
COU ldi PRB, 0eh ; PB3 input connected on A/D converter ldi PRBD, 00h ldi PRBO, 09h
ldi ADCR, 30h ; A/D conversion start
COU1 jrr 6,ADCR, COU1 ; wait at end of conversion ld A, ADR ld ADCcou, A
ldi X, ADCcou ldi ADCcou1,00h call DIV4
19/22SENSORLESS MOTOR DRIVE WITH THE ST62 MCU + TRIAC
ldi DRWR,COUPLE.W ; convert measured value in ld A, ADCcou1 ; triac triggering delay time addi A, 40h ld X, A ld A, (X) ld ADCcou,A
FVIT ldi PRB, 0eh ldi PRBO, 03h ret
;****************** DIVISION BY 4 SUBROUTINE *****************************DIV4 ldi LOOP, 06hDIV42 ld A,(x) sla A
ld (X),A inc X
ld A,(X) rlc A
ld (X),A dec LOOP jrz DIV41 dec X
jp DIV42DIV41 ret
;************* REGISTER CONTEXT SAVING SUBROUTINE ************************SR ld DA, A ; A-->DA ld A, X ; X-->A ld DX, A ; A-->DX ld A, Y ; Y-->A ld DY, A ; A-->DY ret
;************* REGISTER CONTEXT RESTORING SUBROUTINE *********************RSTR ld A,DX ; DX-->A ld X,A ; A-->X ld A,DY ; DY-->A ld Y,A ; A-->Y ld A,DA ; DA-->A ret
;************* REGISTER CONTEXT SAVING SUBROUTINE ************************SRb0 ld DAb,A ; A-->DAb ld A, X ; X-->A ld DXb,A ; A-->DX ld A, Y ; Y-->A ld DYb,A ; A-->DY ret
;************* REGISTER CONTEXT RESTORING SUBROUTINE *********************RSTRb0 ld A,DXb ; DX-->A ld X,A ; A-->X ld A,DYb ; DY-->A ld Y,A ; A-->Y ld A,DAb ; DAb-->A ret
;****************** TIMER INTERRUPT SUBROUTINE ***************************
20/22SENSORLESS MOTOR DRIVE WITH THE ST62 MCU + TRIAC
ITIM ldi TSCR,00h ; stop the timer call SR ; save context jrs 2,FLIT,ITIM1 ; 2nd interrupt ? jrs 4,FLIT,ITIM2 ; 3rd interrupt ?
set 2, FLIT ; 1st interrupt ; b2 <= 1 ldi PRA, 00h ; TRIGGER THE TRIAC WITH BOOST nop ;
ldi PRA, 01h ; REDUCE GATE CURRENT and wait at triac ; latching ( PA0 turns off ) ldi TCR, TGATE ; load timer triac triggering ldi TSCR, 01111100b ; start timer & PSC = 16 jp FTIM
ITIM1 res 2, FLIT ; 2nd interrupt
ldi PRA, 07h ; STOP THE TRIAC GATE PULSE : pA to Vdd set 4, FLIT ; prepare 3rd interrupt ldi DRWR, RTMES.W ; current measure delay time ld A, VALR
subi A, OFSET1 ; A <= VALR - OFSET1 jrnc ITIM3 clr A
ITIM3 cpi A, 040h jrc ITIM4
ldi A, 03fhITIM4 addi A, 040h ld X, A ld A, (X)
ld TCR, A ; load timer with maesure. delay time ldi TSCR,01111100b ; start timer & PSC = 16 jp FTIM
ITIM2 res 4, FLIT ; 3rd interrupt
jrs 3,FLIT,FTIM1 ; sense motor current when Vac < 0 ldi PRA, 0fh ; pointer for current measure test call ADC ; if negative, measure shunt voltage ldi PRA, 07h ; end of pointer ( optional )FTIM1 res 7, FLIT ; END OF TIMER OPERATION
FTIM call RSTR ; restore context reti
;****************** 0 CROSSING INTERRUPT SUBROUTINE **********************IPB ldi WDR, 0feh ; watchdog control call SRb0 ; save context
jrr 3,FLIT,IPB1 ; test on line half cycle polarity res 3, FLIT ; negative half cycle operation ldi IOR, 30h ; prepare rising edge interrupt jp IPB2
IPB1 set 3, FLIT ; positive half cycle operation ldi IOR, 10h ; prepare falling edge interruptIPB2 set 0, FLIT ; 0 crossing indicator validation call RSTRb0 ; restore context reti
;********************* UNUSED INTERRUPT ADDRESSES ************************
21/22SENSORLESS MOTOR DRIVE WITH THE ST62 MCU + TRIAC
IADC retiIPA retiIMNI reti
;*********************** INTERRUPT VECTORS ******************************* .org 0ff0h
jp IADC ; adc jp ITIM ; timer
jp IPB ; port b and c jp IPA ; port a .org 0ffch
jp IMNI ; non maskable interrupt vector jp start ; reset interrupt vector
;************************************************************************* .eject .end
THE SOFTWARE INCLUDED IN THIS NOTE IS FOR GUIDANCE ONLY. SGS-THOMSON SHALL NOT BE HELDLIABLE FOR ANY DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMSARISING FROM USE OF THE SOFTWARE.
Information furnished is believed to be accurate and reliable. However, SGS-THOMSON Microelectronicsassumes no responsability for the consequences of use of such information nor for any infringement ofpatents or other rights of third parties which may result from its use. No license is granted by implication orotherwise under any patent or patent rights of SGS-THOMSON Microelectronics. Specifications mentionedin this publication are subject to change without notice. This publication supersedes and replaces allinformation previously supplied. SGS-THOMSON Microelectronics products are not authorized for use ascritical components in life support devices or systems without the express written approval ofSGS-THOMSON Microelectronics.
© 1994 SGS-THOMSON Microelectronics - All Rights Reserved
Purchase of I2C Components by SGS-THOMSON Microelectronics, conveys a license under the PhilipsI2C Patent. Rights to use these components in an I2C system, is granted provided that the system conforms
to the I2C Standard Specifications as defined by Philips.SGS-THOMSON Microelectronics GROUP OF COMPANIES
Australia - Brazil - France - Germany - Hong Kong - Italy - Japan - Korea - Malaysia - Malta - Morocco The Netherlands - Singapore - Spain - Sweden - Switzerland - Taiwan - Thailand - United Kingdom -
22/22
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- sceh.cn 版权所有 湘ICP备2023017654号-4
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务