Home

STR750 AC induction motor IFOC software library V1.0

image

Contents

1. UMO324 Getting started with the library Start up torque ramp parameters See Section 3 1 Open loop and Section 3 2 Closed loop on page 29 for details define STARTUP TIMEOUT Define here in ms the overall time allowed for start up define STARTUP RAMP DURATION Define here in ms the duration of the torque ramp up define STARTUP FINAL TORQUE Define here in q1 15 format the final reference value for torque ramp up closed loop only tdefine TACHO SPEED VAL Define here in 0 1Hz the lowest speed for tachogenerator reading validation Linear variation of PID constants according to mechanical speed Refer to Section 4 8 5 Adjusting speed regulation loop Ki Kp and Kd vs motor frequency on page 87 2 2 3 Incremental encoder parameters MC encoder param h The MC encoder parameter h header file is to be filled out if position speed sensing is performed by means of a quadrature square wave relative rotary encoder define ENCODER PPR Define here the number of pulses generated by a single channel for one shaft revolution actual resolution will be 4x define TIMERO HANDLES ENCODER To be uncommented if the two sensor output signals are wired to TIMERO input pins define TIMER1 HANDLES ENCODER to be uncommented if the two sensor output signals are wired to TIMER1 input pins define TIMER2 HANDLES ENCODER To be uncommented if the two sensor output signals ar
2. 4 4 3 Detailed explanation about indirect field oriented control IFOC Consider the voltage equations of an induction machine being transformed on a q d reference frame that is synchronous with the rotor flux A about reference frame theory see 1 where r A Shiu t L Lit Loy A A A A As Li Ln PER lar A A E A qr Li qr L lar fuus dt gt m Ax Luc Lp fi lay gt A A By choosing the phase of the rererance System in such a way to arrange the rotor flux exactly on the d axis we will have Ag 0 hae r Ti 61 105 Library functions UM0324 With this choice the electromagnetic torque can be written as 3L T gt Pin y 2 2 9 E i e as a product of a flux and a current component P number of stator poles Let s investigate further on the rotor flux Ag Considering the d axis rotor flux equation Ar Ar Ar Ar Ad Liha L Gg ttu then the equation for ig is Ar Ar 2 Ar Ad L dr 7 L y Combining the latter with the d axis rotor voltage equation leads to di r Ar ar 2 F A Li 0 dt L dr m ds r d 2 m A d EA lis dt L TIL TI m r m r where 1 is the rotor time constant 1 L r Therefore a lag in flux response is caused to this first order transfer function between i and Ag The Calclm routine performs a numerical integration using Euler s method w
3. n 1st A D 2n conversions chain AIMO oco 1 0r pene 4st TIMO OCR2 value OMA IFOC algorithm execution Tuning delay parameters and sampling stator currents in three shunt resistor topology Figure 23 shows one of the three inverter legs with the related shunt resistor Figure 23 Inverter leg and shunt resistor position To indirectly measure the phase current I it is possible to read the voltage V providing that the current flows through the shunt resistor R It is possible to demonstrate that whatever the direction of current l it always flows through the resistor R if transistor T2 is switched on and T1 is switched off This implies that in order to properly reconstruct the current flowing through one of the inverter legs it is necessary to properly synchronize the conversion start with the generated PWM signals This also means that current reading cannot be performed on a phase where the duty cycle applied to the low side transistor is either null or very short 43 105 Library functions UM0324 Note 44 105 Fortunately as discussed in Section 4 2 4 to reconstruct the currents flowing through a generic three phase load it is sufficient to simultaneously sample only two out of three currents the third one being computed from the relation given in Section 4 2 4 Thus depending on the space vector sector the A D conversion of voltage V will be performed only on the two phases where t
4. Clamp Output value to unsigned PI D lower limit PI D upper limit Set Saturated Output Flag Reset Saturated Output Flag return Output value signed 16 bit Additional or up to date technical literature More information can be found on the ST website www stmcu com More specifically the latest documents and software can be found directly at http www stmcu com inchtml pages str750 html In addition FAQ and Forums can be found directly at http www stmcu com forumsid 17 html for STR7 general enquiries http www stmcu com forumsid 13 html for motor control related enquiries References 1 P C Krause O Wasynczuk S D Sudhoff Analysis of Electric Machinery and Drive Systems Wiley IEEE Press 2002 2 T A Lipo and D W Novotny Vector Control and Dynamics of AC Drives Oxford University Press 1996 103 105 Revision history UMO324 6 104 105 Revision history Date 9 Feb 2006 Revision 4 Initial release Changes UM0324 Please Read Carefully Information in this document is provided solely in connection with ST products STMicroelectronics NV and its subsidiaries ST reserve the right to make changes corrections modifications or improvements to this document and the products and services described herein at any time without notice All ST products are sold pursuant to ST s terms and conditions of sale Pur
5. Lv UM0324 YZ User manual STR750 AC induction motor IFOC software library V1 0 Introduction This user manual describes the AC induction motor IFOC software library an Indirect Field Oriented Control IFOC Firmware Library for 3 phase induction motors developed for the STR750 microcontroller This 32 bit ARM cored ST microcontroller comes with a set of peripherals which make it suitable for performing both permanent magnet and AC induction motors FOC In particular this manual describes the STR750 software library developed to control AC induction motors equipped with an encoder or tacho generator in both open and closed loop The control of a permanent magnet PM motor in sinewave mode with encoder is described in the UM0312 User Manual The AC IM IFOC software library is made of several C modules compatible with the IAR EWARM toolchain It will allow you to quickly evaluate both the MCU and the available tools In addition when used together with the STR750 motor control starter kit STR750 MCKIT and an AC induction motor you will be able to get a motor running in a very short time It also eliminates the need for time consuming development of IFOC and speed regulation algorithms by providing ready to use functions that let you concentrate on the application layer A prerequisite for using this library is basic knowledge of C programming AC motor drives and power inverter hardware In depth know how of STR750 functions is
6. See also Figure 54 on page 103 shows the PID block diagram PID Reset Integral terms Synopsis void PID Reset Integral terms void Description The purpose of this function is to reset all the integral terms of the torque flux and speed PID regulators PID Speed Coefficients update Synopsis void PID Speed coefficients update s16 motor speed Description This function automatically computes the proportional integral and derivative gain for the speed PID regulator according to the actual motor speed The computation is done following a linear curve based on 4 set points See Section 4 8 5 on page 87 for more information Functions called None Caution Default values for the four set points are declared and can be modified in the MC Control Param h file see Section 2 2 2 on page 19 PID Integral Speed update Synopsis void PID Integral Speed update s32 value Description The purpose of this function is to load the speed integral term with a default value Ti 85 105 Library functions UM0324 4 8 3 Note 4 8 4 86 105 PID regulator theoretical background The regulators implemented for Torque Flux and Speed are actually Proportional Integral Derivative PID regulators see note below regarding the derivative term PID regulator theory and tuning methods are subjects which have been extensively discussed in technical literature This section provides a basic reminder of the theory PID regulat
7. This software library uses the PU Per Unit system to express current values They are always referred to a base quantity that is the maximum measurable current Imax which for 99 105 Additional information UM0324 A 4 100 105 the proposed hardware can be estimated approximately at Ima 0 6 Rsnunt so the per unit current value is obtained by dividing the physical value by that base S l Loy max In this way ip is always in the range from 1 to 1 Therefore the q1 15 format which ranges from 1 to 0 999969482421 875 with a resolution of 0 00003051 7578125 is perfectly suitable taking care of the overflow value 1 1 21 and thus extensively used Thus the complete transformation equation from SI units is gt ie oo EL 20 MAX Tacho based speed measurement flow charts This section summarizes the main tasks achieved in the tacho capture interrupt in the form of flow charts The purpose of these flow charts is to help understand how the automatic prescaler adjustment is done Figure 50 Tacho capture overview Cnt Index 0 Index See no overflow diagram See overflow diagram Did the timer overflow Increase resolution if possible Decrease resolution if possible Ye Init rolling average No Clear interrupt flag Copy last value into the who
8. and Vga then must be transformed back to a stator frame through Reverse Park conversion and finally drive the power stage In order to correctly perform Park and Reverse Park transformation it is essential to accurately estimate the rotor flux position 9 because currents have to be oriented in phase and in quadrature with rotor flux To manage this task function Calclm is called to provide Im that is the estimated value of the rotor flux as a response to the variation of input current i see Calclm function description function CalcRotFIxSlipFreq see CalcRotFIxSlipFreq function description evaluates rotor flux slip frequency a relying on known rotor time constant if using a tachogenerator the rotor flux position 8 is calculated by integrating the sum of a and rotor electrical speed Figure 37 while with an incremental encoder 6 is determined by summing the rotor electrical angle and the integral of Figure 36 None None 57 105 Library functions UMO324 58 105 Functions Calclm CalcRotFIxSlipFreg called Clarke Park RevPark Circle Limitation Figure PID Torque Regulator PID Flux Regulator If working with encoder ENC Get Electrical Angle if Working with tachogenerator TAC_GetRotorFreq if working with ICS SVPWM_lIcsGetPhaseCurrentValues SVPWM_IcsCalcDutyCycles if working with three shunt SVPWM_3ShuntGetPhaseCurrentValues SVPWM_
9. PWM TIMO peripherals In particular the DMA ADC PWM and TIMO peripherals are configured to perform two synchronized A D conversions per PWM switching period Refer to Section 4 2 3 for further information None None It must be called at main level Standard library MRCC_PeripheralClockConfig GPIO Init EIC IRQlInit EIC IRQCmd DMA Init DMA Cmd TIM DMAConfig DMA Delnit ADC DMACmd PWM Delnit PWM Structlnit PWM Init PWM TRGOSelection PWM ClearFlag PWM ITConfig PWM ResetCounter ADC Structlnit ADC Init ADC Cmd ADC StartCalibration ADC_ConversionCmd TIM Init TIM SynchroConfig TIM ResetCounter PWM Cmd Motor control library SVPWM_3ShuntCurrentReadingCalibration UMO324 Library functions SVPWM_3ShuntCurrentReadingCalibration Synopsis void SVPWM_3ShuntCurrentReadingCalibration void Description The purpose of this function is to store the three analog voltages corresponding to zero current values for compensating the offset introduced by the amplification network Input None Returns None Note This function must be called before PWM outputs are enabled so that the current flowing through inverter legs is zero When using STR750 MC Kit the power board MB459B must be supplied before the control board MB469B This way the current sensing conditioning network will reach steady state before performing calibration Functions called Standard library ADC GetFlagStatus ADC_ConversionCmd
10. SVPWM implements an advanced modulation method that reduces current harmonics thus optimizing DC bus exploitation e The current reading block allows the system to measure stator currents correctly using either cheap shunt resistors or market available isolated current Hall sensors ICS e The speed reading block handles tachogenerator or incremental encoder signals in order to acquire properly rotor angular velocity or position ky UMO324 Getting started with the library e The PID controller block implements a proportional integral and derivative feedback controller to achieve speed torque and flux regulation Figure 7 FOC structure rotor flux stator stator dag frame d q frame a b c frame IFOC Model Toqee ios ca scc S OMIT 1 command s I nwm signal i Flux command T ids 1 ia ib i ia 5 current READING i SPEED i i 9 READING ME CALCULATION i EE N ee ee e A 1 2 2 How to customize hardware and software parameters It is quite easy to set up an operational evaluation platform with a drive system that includes the STR750 MCKIT featuring the STR750 microcontroller where this software runs and an AC induction motor This section explains how to quickly configure your system and if necessary customize the library accordingly Follow these steps to accomplish this task 1 Gather all the information that is needed regarding the hardware in use m
11. used or ENCODER CL ENABLE if an encoder is used Then the speed PID regulator is enabled and takes control of the torque reference 29 105 Running the demo program UM0324 3 3 Caution 30 105 However if the motor does not reach the above mentioned speeds before STARTUP RAMP DURATION the final torque reference value STARTUP FINAL TORQUE is further applied until STARTUP TIMEOUT Finally in the case where the speeds that enable the closed loop are not reached before STARTUP_TIMEOUT the state machine goes into FAULT state for two seconds and the error message Start up failed is displayed on the LCD In this case it is strongly advised to check speed sensor feedback connections first and then if necessary to increase STARTUP FINAL TORQUE if the load torque is too high With reference to Figure 15 note that parameters TACHO SPEED VAL ENCODER CL ENABLE STARTUP FINAL TORQUE STARTUP RAMP DURATION and STARTUP TIMEOUT are fully configurable so that you can customize the start up depending on the motor and load conditions Parameters definitions are done in the MC Control Param h header file Figure 15 Closed loop start up strategy Torque reference Max applicable _________q _______________ 22222 2 22 torque STARTUP RAMP DURATION STARTUP TIMEOUT t Speed Target speed set by joystick TACHO SPEED VAL ______ ENCODER
12. 4 9 1 OVCINIQW m 89 4 9 2 List of non empty interrupt service routines 89 PWM EM IROHandler irls ic deekr evade eee Gd eles ae bi IEEE 89 ADC TROH amp mdLl8r s icdc4 iS Desh evecare Gl ed Se we ade ee 90 4 10 General purpose time base 75x TBtimer module 90 4 10 1 COVOIVIOW scene kde eed ide dae ahd Re eR Ue ee Mean bake 90 4 10 2 List of available functions and interrupt service routines 90 TB cStartUpIDdE g co ile al Wo oe Xe Xe mo So acu ox 3d TB Timebase Timer Init Verid R4 ee p DE bee ee 91 TB WAT Bids secede axe dee Ru Ste ar eeu e neck xe E Lu ites Dar dela dled 92 TB Set Delay 500us TB Set DisplayDelay 500us TB Set Startup Timeout 2 l222l12 01 48 i90 b 9 a 92 TB StartUp Timeout IsElapsed TB Delay IsElapsed TB DisplayDelay IsElapsed elle tenes 92 TB TROMANGLEP vse gu wee a Gite ke dd he BERS Led RE use Rv edhe 93 4 11 Application layer rre nee eset seemed e oe 93 5 MISRA compliance i e icy macie a den sean kee lac 94 5 1 Analysis method sk ue paradas POE 94 5 2 Limitations a si aata iaa aiea a aa IRR RR 3 ns 94 5 2 1 MISRA compliance for AC IM library files 94 6 105 77 UM0324 Contents 5 2 2 MISRA rule deviations 00000 ee 96 Appendix A Additional information 00 cece eee 97 A 1 Adjusting CPU load related to IFOC algorithm execution 97 A 2 X Selecting PWM frequency for 3
13. 8KB three shunt resistors for current reading tacho generator for speed feedback 8 2KB for LCD joystick management These figures are for information only this software library may be subject to changes depending on the final application and peripheral resources Note that it was built using robustness oriented structures thus preventing the speed or code size from being fully optimized Related documents Available on www st com STR750 User Manual STR750 Datasheet STR750 Standard Library User Manual STR7 Flash Programming Manual Available on www arm com ARM7TDMI S Rev 4 Technical Reference Manual ARM DDI 0234A UM0324 Contents Contents 1 Getting started with tools 0 0c eee eee 11 1 1 Working environment iid a 11 12 Sottware tools cesse uw ERROR X A E dyes ka kas 11 1 3 Library source code o2 148 8 ee st uk bbe Loeb REG n xx doe RR Rd 12 1 3 1 Download sisas tic ub edet beer RUP booa EU ees HE nt da 12 1 3 2 File Structure vo egbi e adie haved e be S 12 1 3 3 Starting the IAR toolchain oooooccccoccccoo ee 13 1 4 Customizing the workspace for your STR750X derivative 13 1 4 1 Inkarm xxx xcl file internal external flash or RAM based project 13 1 4 2 Extended linker file setting llle 14 2 Getting started with the library sees 16 2 1 Introduction to AC induction motor FOC drive 04 16 2 2 How to customize hardware and software pa
14. ADOC Init ADC ClearFlag ADC_ITConfig Motor control library SVPWM_3ShuntCalcDutyCycles SVPWM_3ShuntGetPhaseCurrentValues Synopsis Curr_Components SVPWM_3ShuntGetPhaseCurrentValues void Description This function computes current values of Phase A and Phase B in q1 15 format starting from values acquired from the A D Converter peripheral Input None Returns Curr Components type variable Note In order to have a q1 15 format for the current values the digital value corresponding to the offset must be subtracted when reading phase current A D converted values Therefore the function must be called after SVPWM_3ShuntCurrentReadingCalibration Functions called None Ti 37 105 Library functions UM0324 SVPWM_3ShuntCalcDutyCycles Synopsis void SVPWM_3ShuntCalcDutyCycles Volt_Components Stat_Volt_Input Description After execution of the IFOC algorithm new stator voltage components Va and Vg are computed The purpose of this function is to calculate exactly the three duty cycles to be applied to motor phases from the values of these voltage components Moreover once the three duty cycles to be applied in next PWM period are known this function sets the DMA ADC and TIMO peripherals for the next current reading In particular depending on the duty cycle values the delay for the two current samplings are computed see Section 4 2 5 on page 43 Refer to Section 4 2 3 for information on the theoretical appr
15. CL ENABLE Closed Loop t enabled Setting up the system when using ICS sensors The default configuration provides for the use of three shunt resistors and tacho generator Section 3 3 1 describes how to change the firmware configuration from three shunt resistors to two ICS stator current reading This section gives you information about how to provide the STR750 with ICS feedback signals and to properly customize the firmware When using two ICS for stator current reading you must ensure that the conditioned sensors output signal range is compatible with the STR750 supply voltage UM0324 Running the demo program 3 3 1 3 3 2 Connecting the two ICS sensors to the motor and to STR750 In order for the implemented IFOC algorithm to work properly it is necessary to ensure that the software implementation of the 75x svpwm ICS module and the hardware connections of the two ICS are consistent As illustrated in Figure 16 the two ICS must act as transducers on motor phase currents coming out of the inverter legs driven by STR750 PWM signals PWM1 Phase A and PWMe Phase B In particular the current coming out of inverter Phase A must be read by an ICS whose output has to be sent to the analog channel specified by the PHASE A CHANNEL parameter in MC pwm ics prm h Likewise the current coming out of inverter Phase B must be read by the other ICS and its output has to be sent to the analog channel specified by the PHA
16. Figure 52 Figure 53 Figure 54 10 105 Transformation from an abc stationary frame to a qd rotating frame 69 Circle limitation working principle ooooccoococcoo BI 71 Automatic tacho timer prescaler decrease 20 00 82 Automatic tacho timer prescaler increase llle 82 PID general equation 0 0 RR I I uh 86 Time domain to discrete PID equations llis 87 Linear curve for coefficient computation lille 88 AD conversions for three shunt topology stator currents reading and IFOC algorithm execution when REP RATE 3 lese nunan naana 97 AD conversions for three shunt topology stator currents reading and IFOC algorithm execution when REP RATEZ1 sslll eer rr 98 Tacho capture overview llli hn 100 Processing captured value when timer did not overflow 0 0 00 eae 101 Processing captured value when timer did overflow llle 101 Torque flux control loop block diagram silii 102 Speed control loop block diagram 0 0c eee 103 UM0324 Getting started with tools 1 1 1 2 Getting started with tools To develop an application for an AC induction motor using the AC IM IFOC software library you must set up a complete development environment as described in the following sections A PC running Windows XP is necessary Working environment The AC IM IFOC software library was fully
17. IFOC algorithm in the proposed implementation the stator current sampling frequency and the IFOC algorithm execution rate coincide Note HEP RATE must be an odd number if currents are measured by shunt resistors see Section A 2 Selecting PWM frequency for 3 shunt resistor configuration on page 98 for details its value is 8 bit long Speed regulation loop frequency define PID SPEED SAMPLING TIME The speed regulation loop frequency is selected by assigning one of the defines below define PID SPEED SAMPLING 500us 0 min 500us define PID SPEED SAMPLING 1ms 1 define PID SPEED SAMPLING 2ms 3 4 1 500uS 2ms define PID SPEED SAMPLING 4 5ms 6 define PID SPEED SAMPLING 10ms 15 define PID SPEED SAMPLING 127ms 255 max 255 1 500us 127ms 19 105 Getting started with the library UM0324 20 105 Speed controller setpoint and PID constants initial values define PID_SPEED_REFERENCE Define here in 0 1Hz the mechanical rotor speed setpoint at startup in closed loop mode define PID_SPEED_KP_DEFAULT The proportional constant of the speed loop regulation signed 16 bit value adjustable from 0 to 32767 define PID SPEED KI DEFAULT The integral constant of the speed loop regulation signed 16 bit value adjustable from 0 to 32767 define PID SPEED KD DEFAULT The derivative constant of the speed loop regulation si
18. MISRA compliance using the IAR Embedded Workbench toolchain The IAR Systems implementation is based on version 1 of the MISRA C rules dated April 1998 Limitations Compliance tests were performed on required MISRA rules only and not on advisory rules Due to the extensive use of the STR750 standard library which itself is not fully MISRA compliant as of September 2006 the interaction through function calls for example between the standard library and AC IM library modules necessarily induces non compliances MISRA compliance for AC IM library files Table 3 shows the compliance with the MISRA required rules of each AC IM IFOC software library module excluding STR750 Standard Library modules Table 3 MISRA compliance of AC IM library files Module name Pesca Deviation MC Clarke Park h Yes MC qmath h Yes MC const c Yes MC const h Yes MC type h Yes 75x TBTimer c Yes 75x TBTimer h Yes MC Globals c Yes MC Globals h Yes MC Display c Yes MC Display h Yes MC AC motor param h Yes 75x MClib h Yes MC Control Param h Yes UM0324 MISRA compliance 4 Table 3 MISRA compliance of AC IM library files MISRA Module name compliant Deviation 75x_conf h Yes 75x MCconf h Yes MC encoder param h Yes MISRA rule 45 non compliance due to 75x svpwm 3shunt c STR750
19. OR ENVIRONMENTAL DAMAGE ST PRODUCTS WHICH ARE NOT SPECIFIED AS AUTOMOTIVE GRADE MAY ONLY BE USED IN AUTOMOTIVE APPLICATIONS AT USER S OWN RISK Resale of ST products with provisions different from the statements and or technical features set forth in this document shall immediately void any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever any liability of ST ST and the ST logo are trademarks or registered trademarks of ST in various countries Information in this document supersedes and replaces all information previously supplied The ST logo is a registered trademark of STMicroelectronics All other names are the property of their respective owners 2007 STMicroelectronics All rights reserved STMicroelectronics group of companies Australia Belgium Brazil Canada China Czech Republic Finland France Germany Hong Kong India Israel Italy Japan Malaysia Malta Morocco Singapore Spain Sweden Switzerland United Kingdom United States of America www st com 105 105 q
20. Sector 6 39 105 Library functions UM0324 With the following definitions for U 2 43 T V U T i V pera and X U _ U VERE 2 z U ge U Z literature demonstrates that the space vector sector is identified by the conditions shown in Table 1 Table 1 Sector identification Y lt 0 Y gt 0 Z lt 0 Z gt 0 Z lt 0 Z gt 0 X lt 0 X 0 X lt 0 X gt 0 Sector V IV IH VI l I The duration of the positive pulse widths for the PWM applied on Phase A B and C are respectively computed by the following relationships Sector IV T X Z AN 3 t h Z te t X Sector Il V T Y Z uc t t Z t t Y 40 105 ky UM0324 Library functions 4 2 4 Sector III VI _T X Y NC E t t X t t Y Where T is the PWM period Now considering that the PWM pattern is center aligned and that the phase voltages must be centered at 50 of duty cycle it follows that the values to be loaded into the PWM output compare registers are given respectively by Sector IV fnit ev 4 2 TimePhB TimePhA Z TimePhC TimePhB X Sector Il V Tipe fee 4 2 TimePhB TimePhA Z TimePhC TimePhA Y Sector III VI TimePhA TE hTimePhB TimePhC X TimePhC TimePhA Y Current sampling in three shunt topology and general purpose A D conversions The three currents l4 lo and l5 flowing through a three phase system follow the mathematic
21. TIMx UP IRQHandler interrupt routine Synopsis Description Functions called Note See also void TIMx UP IRQHandler void This is the encoder timer TIMER 0 1 or 2 update routine An interruption is generated whenever an overflow underflow of the counter value occurs TIM CNT The Encoder Timer Overflow variable is then incremented None This is an interrupt routine STR750 Datasheet Synchronizable Standard Timer 75 105 Library functions UM0324 4 7 4 7 1 Tachogenerator feedback processing 75x_tacho c module List of available functions and interrupt service routines The following is a list of available functions as listed in the 75x_ encoder h header file TAC TachoTimerlnit on page 76 TAC InitTachoMeasure on page 77 TAC_GetRotorFreqinHz on page 77 TAC GetHRotorFreq on page 78 GetLastTachoPeriod on page 78 GetAvrg TachoPeriod on page 78 TAC_IsTimedOut on page 79 TAC ClrTimeOut on page 79 TAC GetCaptCounter on page 79 TAC_CirCaptCounter on page 80 TAC_StartTachoFiltering on page 80 TAC ValidSpeedlnfo on page 80 TIMx IC12 IRQHandler on page 81 TIMx UP IRQHandler on page 81 TAC TachoTimerInit 76 105 Synopsis void TAC_TachoTimerlnit void Description The purpose of this function is to initialize the timer that will perform the tacho signal period measurement the timer can be chosen in the 75x tacho prm h file The peripheral clock and the capture interrupt are enabled and the timer
22. The figures above were measured using the MB459 board This evaluation platform is designed to support several motor driving topologies PMSM and AC induction and current reading strategies single and three shunt resistors Therefore the figures provided in Table 2 should be understood as a starting point and not as a best case You can further increase the maximum applicable duty when using your own hardware system by editing the following definitions in the MC pwm 3shunt prm h header file define HOLD TIME 0xA0 2 67usec 1 60MHz units define DMA TIME Ox2A 0 7usec define SAMPLING_TIME 0x60 1 6usec define TNOISE 0x9c 2 6usec define TRISE 0x9c 2 6usec 51 105 Library functions UM0324 4 3 4 3 1 4 3 2 52 105 Isolated current sensor reading and space vector PWM generation 75x svpwm ICS module Overview Two important tasks are performed in the 75x svpwm ICS module e Space vector pulse width modulation SVPWM e Ihree phase current reading when two isolated current sensors ICS are used In order to reconstruct the currents flowing through a three phase load with the required accuracy using two ICS it is necessary to properly synchronize A D conversions with the generated PWM signals This is why the two tasks are included in a single software module List of available functions and interrupt service routines The following is a list of
23. are widely used to read the rotor position of electric machines As the name implies incremental encoders actually read angular displacements with respect to an initial position if that position is known then rotor absolute angle is known too Quadrature encoders have two output signals represented in Figure 17 as TI1 and TI2 With these and with the STR750 standard timer in encoder interface mode it is possible to get information about rolling direction Figure 17 Encoder output signals counter operation forward jitter backward jitter forward I SM A e emos emm rg ees TI2 To es el cee sae sep 5 COUNTER up down up SUL LETT E In addition rotor angular velocity can be easily calculated as a time derivative of angular position To set up the AC IM IFOC software library for use with an incremental encoder simply modify the 75x MCconf h and MC encoder param h header files according to the indications given in Section 2 2 1 on page 18 and Section 2 2 3 on page 21 respectively However some extra care should be taken concerning what is considered to be the positive rolling direction this software library assumes that the positive rolling direction is the rolling direction of a machine that is fed with a three phase system of positive sequence Because of this and because of how the encoder output signals are wired to the microcontroller input pins it is possible to have
24. is initialized in clear on capture mode Functions called MRCC_PeripheralClockConfig Note EIC IROlnit TIM Delnit TIM Structlnit TIM Init TIM ClearFlag TIM ITConfig TIM ResetCounter Tim Cmd The timer starts counting at the end of the routine See also STR750 datasheet synchronizable standard timer UM0324 Library functions TAC InitTachoMeasure Synopsis Description Input Output Functions called Note See also TAC GetRotorFreqinHz Synopsis Description Input Output Functions called Note Caution void TAC InitTachoMeasure void This function clears the software FIFO where the latest speed data are stored This function must be called every time the motor is started to initialize the speed measurement process None None TIM ITConfig TIM ResetCounter TIM Cmd TIM ITConfig The first measurements following this function call are done without filtering the rolling average mechanism is disabled STR750 datasheet synchronizable standard timer u16 TAC_GetRotorFreqInHz void This routine returns the rotor frequency with 0 1Hz definition The result is given by the following formula Frotor K x Fosc Capture number of overflow x FFFF where K depends on the number of motor and tacho pole pairs None Rotor mechanical frequency with 0 1Hz resolution unsigned 16 bits direction cannot be determined using a tacho GetAvrgTachoPeriod GetLastTachoPeriod both pr
25. only required for customizing existing modules and for adding new ones for a complete application development The figure below shows the architecture of the firmware It uses the STR750 Standard Library extensively but it also acts directly on hardware peripherals when optimizations in terms of execution speed or code size are required APPLICATION LAYER STR750 Speed Flux and IFOC Drive Torque PIDs Std User Speed Current Library Interface feedback feedback Motor Control Library Peripherals February 2007 Rev 1 1 105 www st com UM0324 Note 2 105 AC IM IFOC software library V1 0 features CPU running at 60MHz Speed feedback Tacho generator Quadrature incremental encoder Current sampling method 2isolated current sensors ICS 3 shunt resistors placed on the bottom of the three inverter legs Current regulation for torque and flux control PIDs sampling frequency adjustable up to the PWM frequency Speed control Open loop operation Closed loop operation PID regulation with 0 5ms to 127ms sampling time 16 bit space vector PWM generation frequencies PWM frequency can be easily adjusted Centered PWM pattern type 11 bits resolution at 14 6Khz Free C source code and spreadsheet for look up tables CPU load below 3096 IFOC algorithm refresh frequency 8KHz Motor control modules developed in accordance with MISRA C rules Code size 22
26. shunt resistor configuration 98 A 3 Fixed point numerical representation llle 99 A 4 Tacho based speed measurement flow charts 100 AS PID block diagrams ica eds eR REIR a a EE Rund 102 A 6 X Additional or up to date technical literature 103 A 7 References Lusso 3o A SUR aU Rea gah ee ds 103 6 Revision history issasusekkkwssabek ebuada A Ra ua 104 STA 7 105 List of tables UM0324 List of tables Table 1 Sector identification 0 0 eee 40 Table 2 PWM frequency vs maximum duty cycle relationship lille 51 Table 3 MISRA compliance of AC IM library files 0000 cee eee 94 Table 4 System performance when using STR750 MCKIT 0 00 cece eee eee 99 8 105 ky UM0324 List of figures List of figures Figure 1 Figure 2 Figure 3 Figure 4 Figure 5 Figure 6 Figure 7 Figure 8 Figure 9 Figure 10 Figure 11 Figure 12 Figure 13 Figure 14 Figure 15 Figure 16 Figure 17 Figure 18 Figure 19 Figure 20 Figure 21 Figure 22 Figure 23 Figure 24 Figure 25 Figure 26 Figure 27 Figure 28 Figure 29 Figure 30 Figure 31 Figure 32 Figure 33 Figure 34 Figure 35 Figure 36 Figure 37 Figure 38 Figure 39 Figure 40 ky JTAG interface for debugging and programming 202 cece ee eens 11 Eile str ctil amp arx s Rx A cha eee whet Pen RUDI RA
27. standard library function call see Section 5 2 2 75x svpwm 3shunt h Yes 75x svpwm ics c Yes 75x svpwm ics h Yes Main c Yes 75x encoder c Yes 75x encoder h Yes 75x it c Yes 75x lcd c Yes 75x lcd h Yes MC Keys c Yes MC Keys h Yes MC Misc c Yes MC Misc h Yes 75x DAC c Yes 75x DAC h Yes 75x svpwm ics prm h Yes 75x svpwm 3shunt prm h Yes MC PID Regulators c Yes MC PID Regulators h Yes MC PID Param h Yes 75x tacho c Yes 75x tacho h Yes MC tacho prm h Yes MC IFOC Drive c Yes MC IFOC Drive h Yes 95 105 MISRA compliance UM0324 5 2 2 96 105 MISRA rule deviations The only rule not respected in the AC IM IFOC software library is Rule number 45 Type casting from any type to or from pointers shall not be used This deviation occurs in the 75x_svpwm_3shunt c module and it is due to the definition of the DMA_InitTypeDef type in the 75x_dma h header file typedef struct u32 DMA SRCBaseAddr u32 DMA DSTBaseAddr ul6 DMA BufferSize ul6 DMA SRC ul6 DMA DST ul6 DMA SRCSize ul6 DMA SRCBurst ul6 DMA DSTSize ul6 DMA Mode ul6 DMA M2M ul6 DMA DIR DMA InitTypeDef Basically the DMA_SRCBaseAddr and DMA DSTBaseAddr fields which must contain memory addresses should have been declared as pointers instead of unsigned 32bit q UM0324 Additional information Appendix A Additional information A 1 Adjusting CPU
28. to zero current values for compensating the offset introduced by both ICS and amplification network None None The function must be called before PWM outputs are enabled so that current flowing through inverter legs is zero When using the STR750 MC Kit ICS sensors must be supplied before the control board MB469B This way the current sensing conditioning network can reach steady state before performing calibration Standard Library ADC GetFlagStatus ADC_ConversionCma ADC GetConversionValue 53 105 Library functions UM0324 SVPWM_IcsGetPhaseCurrentValues Synopsis Curr Components SVPWM_IcsGetPhaseCurrentValues void Description This function computes current values of Phase A and Phase B in q1 15 format from the values acquired from the A D converter Input None Returns Curr Components type variable Note In order to have a q1 15 format for the current values the digital value corresponding to the offset must be subtracted when reading phase current A D converted values Thus the function must be called after SVPWM lIcsCurrentReadingCalibration Functions called None SVPWM IcsCalcDutyCycles 4 3 3 54 105 Synopsis void SVPWM_IcsCalcDutyCycles Volt Components Stat Volt Input Description After execution of the IFOC algorithm new stator voltages component Va and Vg are computed The purpose of this function is to calculate exactly the three duty cycles to be applied to motor phases from the v
29. values of current igs expressed in q1 15 format according to increasing stator frequencies see Section 4 4 4 on page 63 The first element of the table should have the same value as the hNominal Flux parameter hTorque Reference this look up table 256 signed 16 bit values provides saturation values of current ig expressed in q1 15 format according to increasing stator frequencies see Section 4 4 4 on page 63 How to define and add a c module This section describes with an example how to define and include a new module in a project based on the library The example is based on the addition of two files my i1e candthe corresponding header file my_file h 1 Create a new file You can either copy and paste an existing file and rename it or in the File menu choose New then click the File icon and save it in the right format c h extension as shown in Figure 9 2 Declare the new file containing your code in the toolchain workspace To do this simply right click in the workspace folder then choose the Add Files sub menu The new file is automatically added to the workspace and taken into account for the compilation of the whole project UM0324 Getting started with the library 4 The procedure of adding the module to the project is very easy with the IAR Embedded Workbench as the makefile and linking command files are automatically generated When rebuilding the library the configurati
30. wo dox x Row Ce wo 4 BO TAC StartTachoFiltering 80 TAC ValidSpeedInfo 80 TIMx IC12 IROHandletr n s 4 e e zo s e Xy d a xw a 8l TIMXx UP IROHandlef 4 s o so ox s OS ox woe c9 e cw 9 ow Bd 5 105 Contents UMO324 4 7 2 Integration tips o oooococoo RR 81 4 7 3 Operating principle 6 e 81 4 7 4 Converting Hertz into pseudo frequency 0000eeeee 83 4 8 Flux torque and speed regulators MC_PID_regulators module 83 4 8 1 OVERVIEW ideni edd Sr di de VERG Sh Panda Th ee es dara 83 4 8 2 List of available functions and interrupt service routines 83 PID D x oz ec 8 a BO a Boe ox VELO Ox 4 BB PID Flux Regulator e mo ecos os eb oo A 2 cow c9 oo v 84 PID Torque Reg ulatOf e s 4 4 c x Ba ms X o ov dec v 904 PID Speed Regulator r 5 e p e 2 oo 4 9 wow ako o 85 PID Reset Integral terms 85 PID Speed Coefficients update 85 PID Integral Speed update 85 4 8 3 PID regulator theoretical background 00 eee eee 86 4 8 4 Regulator sampling time setting llle 86 4 8 5 Adjusting speed regulation loop Ki Kp and Kd vs motor frequency 87 Disabling the linear curve computation routine 75x it c module 88 4 9 Main interrupt service routines 75x it module 89
31. 2TS TH TDMA and ADutyA B lt DT TN4 TS ooo 46 DT TN TS lt Low side Phase A duty cycle lt DT TN 2TS TH TDMA and ADutyA B lt DT TN TS doo 47 DT TN TS lt Low side Phase A duty cycle lt DT TN 2TS TH TDMA and ADutyA B DT4TN TS occ 47 DT TN TS lt Low side Phase A duty cycle lt DT TN 2TS TH TDMA and ADUtyA gSDI INFIS pa ceca eee ke aci nea OP cde dae ee eee 48 Low side duty cycle Phase A lt DT TN TS and ADutyA B gt DT TN 2TS TH TDMA ooo 48 Low side duty cycle Phase A DT TN TS and ADutyA B gt DT TN 2TS TH TDMA 49 Low side duty cycle Phase A lt DT TN TS and DT TRise TS lt ADutyA B lt DT TN 2TS TH TDMA ooo 49 Low side duty cycle Phase A lt DT TN TS and DT TRise TS lt ADutyA B lt DT TN 2TS TH TDMA 0 2 00 50 Low side duty cycle Phase A DT TN TS and ADutyA B lt DT TRise TS 51 Stator currents sampling and GP conversions in ICS configuration REP_RATE 1 55 Rotor flux angle calculation quadrature encoder 0000 cece eee eee 58 Rotor flux angle calculation tachogenerator 0 00 cee eee 59 Torque and flux optimization block 0 000 cee eee 60 Torque vs speed characteristic curve 0 000 cee ee 64 Clarke Park and reverse Park transformations 0 0000 e eee eee eee 66 9 105 List of figures UM0324 Figure 41 Figure 42 Figure 43 Figure 44 Figure 45 Figure 46 Figure 47 Figure 48 Figure 49 Figure 50 Figure 51
32. 3ShuntCalcDutyCycles 36 Rotor flux angle calculation quadrature encoder 8 Calculation uncompensated flux response controller 0 1 Osy UMO324 Library functions Figure 37 Rotor flux angle calculation tachogenerator 8 Calculation uncompensated flux response controller Z Aap las L m w electrical degrees IFOC_CalcFluxTorqueRef Synopsis void IFOC_CalcFluxTorqueRef void Description This function provides current components iqs and ids to be used as reference values by the IFOC Model function in closed loop speed mode see Torque amp Flux opt block in Figure 38 Speed setpoint and actual rotor speed are compared in a PID control loop whose output is iqs This component together with the previous flux reference and the rotor speed y is used to work out the stator frequency that has to be generated With this information two lookup tables described in MC ACmotor prm Section 2 2 5 defined by taking into account the field weakening strategy explained in Section 4 4 4 are run through in order to get the optimal flux reference ids and the saturation value of the torque current component iqs max that allow to reach the desired speed under the obvious limitations of rated torque and rated power Input None Returns None Functions called PID Speed Regulator mul q15 q15 q31 div q31 q15 q15 TA 59 105 Library f
33. 5 q31 Volt Components Rev Park Volt Components Volt Input This function transforms stator voltage vg and vg belonging to a rotor flux synchronous rotating frame to a stationary reference frame so as to obtain v and vg See Section 4 5 3 for details Stator voltages vas and Vas in q1 15 format as members of the variable Volt Input which is a structure of type Volt Components Stator voltages v and vg in q1 15 format as members of a structure of type Volt Components mul q15 q15 q31 67 105 Library functions UM0324 Rev_Park Circle Limitation 4 5 3 68 105 Synopsis void RevPark_Circle_Limitation void Description After the two new values Vq and V of the stator voltage producing flux and torque components of the stator current have been independently computed by flux and torque PIDs it is necessary to saturate the magnitude of the resulting vector equal to QVE V passing before them to the SVPWM block The purpose of this routine is to perform the saturation Refer to Section 4 5 4 Circle limitation on page 70 for more detailed information Input None Returns None Note The limitation of the stator voltage vector must be done in accordance with the PWM frequency as shown in Table 2 PWM frequency vs maximum duty cycle relationship on page 51 Functions called None Detailed explanation about reference frame transformations Induction machines show very complex voltage equations becau
34. 50 MCKIT the encoder delivers 400 pulses per revolution This routine returns O for O degrees 4 400 2 800 for 180 degrees None Unsigned 32 bits None STR750 datasheet synchronizable standard timer ENC Get Electrical Angle Synopsis Description Input Output Functions called s16 ENC Get Electrical Angle void This function returns the electrical angle in signed 16 bit format This routine returns 0 for O degrees 32768 816 MIN for 180 degrees 32767 816 MAX for 180 degrees None Signed 16 bits None ENC Get Mechanical Angle Synopsis Description Input Output Functions called Note s16 ENC Get Electrical Angle void This function returns the mechanical angle in signed 16 bit format This routine returns O for O degrees 32768 S16 MIN for 180 degrees 32767 816 MAX for 180 degrees None Signed 16 bits None Link between Electrical Mechanical frequency RPM Electrical frequency number of pair poles x mechanical frequency RPM speed 60 x Mechanical frequency RPM revolutions per minute Example electrical frequency 100 Hz motor with 8 pair poles 100Hz electrical lt gt 100 8 212 5Hz mechanical lt gt 12 5 x 602750 RPM 73 105 Library functions UMO324 ENC_ResetEncoder Synopsis Description Functions called See also ENC_Clear Speed Buffer Synopsis Description Functions called ENC_Get_Speed Synopsis Description Input Output Fu
35. 6 Encoder feedback processing 75x_encoder c module 4 6 1 List of available functions and interrupt service routines The following is a list of available functions as listed in the 75x_ encoder h header file ENC_Init Synopsis Description Functions called See also 72 105 ENC Init on page 72 ENC_GetPosition on page 73 ENC Get Electrical Angle on page 73 ENC Get Mechanical Angle on page 73 ENC_ResetEncoder on page 74 ENC Clear Speed Buffer on page 74 ENC Get Speed on page 74 ENC Get Average Speed on page 75 TIMx UP IRQHandler interrupt routine on page 75 void ENC_Init void The purpose of this function is to initialize the encoder timer The peripheral clock input pins and update interrupt are enabled The peripheral is configured in 4X mode which means that the counter is incremented decremented on the rising falling edges of both timer input 1 and 2 TIMx TIO and TIMx_TI1 pins MRCOC PeripheralClockConfig GPIO Init EIC IROlnit TIM Structlnit TIM Init TIM ClearFlag TIM ITConfig TIM ResetCounter Tim Cmd STR750 datasheet synchronizable standard timer UM0324 Library functions ENC_GetPosition Synopsis Description Input Output Functions called See also u32 ENC_GetPosition void This function returns the encoder timer value giving a direct reading of the rotor position from 0 to 4 number of encoder pulses per revolution For the SHINANO motor included with the STR7
36. C induction motors With this approach it can be stated that the two currents is and lus derived from stator currents have in AC Induction Motor IM the same role that armature and field currents have in DC motors the first is proportional to mechanical torque the second to the rotor flux In more detail in the context of FOC rotor flux position is indirectly calculated starting from transformed equations of the machine by means of known motor parameters and stator current measurements this is why the controller is an indirect controller and hence the phrase IFOC drive In other words it can be stated that IFOC drive is halfway between dynamic controllers speed position and machine core So the system may well be depicted as in Figure 6 if introduced in a loop for speed control Figure 6 FOC drive placed in a speed loop controller 3 phase inverter Flux controller actual rotor speed Basic information on field oriented structure and library functions is represented in Figure 7 e The 64 calculation block estimates rotor flux angle which is essential to transformation blocks Park Reverse Park for performing field orientation so that the currents supplied to the machine can be oriented in phase and in quadrature to the rotor flux vector More in depth information about reference frame theory and FOC structure is available in 1 2 and Section 4 4 3 on page 61 e The space vector PWM block
37. Figure 35 Stator currents sampling and GP conversions in ICS configuration REP_RATE 1 PWM Counter L I Compare A eS Low side A I wT ee T 31359 Phase cufrent I Average current ass ro GP Conversion Chain GP Conversion Chain PWM Registers Update Induction motor IFOC vector control MC IFOC Drive c module Overview The MC_IFOC_Drive c module designed for AC induction machines provides at the core decoupled torque and flux regulation relying on indirect field oriented control algorithm In addition it makes available other important features e speedregulation by PID feedback control e flux weakening for extended speed range It works requiring no adjustment with all of the selectable current or speed sensing configurations in accordance with the settings in the 75x MCcon f h file e isolated current sensing ICS e three shunt resistors current sensing e encoder position and speed sensing e tachometer speed sensing It handles several functions of other modules and has no direct access on the microcontroller peripheral registers 55 105 Library functions UMO324 4 4 2 List of available C functions IFOC Init 56 105 Synopsis Description Input Returns Note Functions called IFOC Init on page 56 IFOC Model on page 57 IFOC CalcFluxTorqueHef on page 59 Calclm on page 60 CalcRotFlxSlipFre
38. Flux and torque PIDs sampling rate REP _RATE 1 Note REP_RATE must be an odd number if currents are measured by shunt resistors see also Section A 2 on page 98 its value is 8 bit long 4 8 5 Adjusting speed regulation loop Ki Kp and Kd vs motor frequency Depending on the motor frequency it might be necessary to use different values of Kp Ki and Kd These values have to be input in the code to feed the regulation loop algorithm A function performing linear interpolation between four set points PID Speed Coefficient update is provided as an example in the software library see MC_PID_regulators c and can be used in most cases as long as the coefficient values can be linearized If that is not possible a function with a larger number of set points or a look up table may be necessary To enter the four set points once the data are collected edit the MC Control param h file and fill in the field dedicated to the Ki Kp and Kd coefficient calculation as shown below Ti 87 105 Library functions UM0324 88 105 Settings for min frequency define Freq Min 10 1 Hz mechanical define Ki_Fmin 1000 Frequency min coefficient settings define Kp_Fmin 2000 define Kd_Fmin 3000 Settings for intermediate frequency 1 define F_1 50 5 Hz mechanical define Ki_F_1 2000 Intermediate frequency 1 coefficient settings define Kp_F_1 1000 define Kd_F_1 2500 Settings for intermedi
39. IROHandler void s if State RUN 1 if wGlobal Flags amp CLOSED LOOP CLOSED LOOP s PID Speed Coefficients update hRot Freq Hz to be commented out Lie 4 9 Main interrupt service routines 75x_it module 4 9 1 Overview The 75x_it module can be used to describe all the exception subroutines that might occur within your application When an interrupt happens the software will automatically branch to the corresponding routine accordingly with the interrupt vector table With the exception of the ADC and PWM emergency stop interrupt requests all the routines are empty so that you can write your own code for exceptios handlers and peripheral interrupt requests 4 9 2 List of non empty interrupt service routines As mentioned above only two interrupts are managed by motor control tasks e PWM_EM_IRQHandler on page 89 e ADC IRQHandler on page 90 PWM EM IRQHandler Synopsis void PWM EM IRQHandler void Description The purpose of this function is to manage an Emergency Stop signal on the dedicated emergency pin In particular PWM outputs are disabled the main state machine is put into FAULT state Input None Returns None Functions called PWM ClearFlag PWM ITConfig See also Synchronizable PWM Timer section in STR750 Reference manual Ti 89 105 Library functions UMO324 ADC_IRQHandler 4 10 4 10 1 4 10 2 90 105 Synopsis Description Input Returns Functions call
40. IZE 0x0 D UND STACK SIZE 0x0 D HEAP SIZE 0x400 E E D E 3 Memory size modifications might also be necessary according to the MCU specifications Default settings are done for a 256KB embedded flash memory If you use a different device you must edit the Inkarm_flash xcl file as explained in Section 1 4 2 Figure 4 Extended linker file Inkarm_flash xc1 flash memory length definition Embedded Flash eie frei big far The user has to change the flash memory length depending STR75xF Code memory in flash DROMSTART 0x20000000 DROMEND 0x2003FFFF Ox2001FFFF Ox200FFFF Data memory DRAMSTART 0x40000000 DRAMEND 0x40003FFF Extended linker file setting As mentioned in the previous section in the provided IAR workspace the internal flash extended linker file is set by default Inkarm flash xc1l To modify the linker file to be used for example Inkarm_ram xcl or Inkarm_smi xcl 1 Open the IAR workspace by double clicking on the Y FOC AC SR v1 0 IAR A IFOC eww file 2 Goto the Project menu select Options then Linker and select the Config sub menu The dialog box shown in Figure 5 is displayed 3 Inthe Override default field type the name of the linker file you want to use and then click OK Selecting the Inkarm ram xc1 file makes the IAR XLINK linker place the memory segments on RAM memory whereas selecting the Inkarm_smi xc1 file makes the linker place the memo
41. O ae 12 Device SUMMA oo ee alee eR ae X De D doe ee ee la ee x eec 13 Extended linker file Inkarm_flash xc1 flash memory length definition 14 Extended linker file setting 0 2 0 0 0 cece teens 15 FOC drive placed ina speed loop 0 0 eee 16 geeignet c MT 17 Torque vs speed characteristic curve lille 24 Adding a new module 0 ce tenet eee 25 Key function assignments 0 0 llle teas 26 Mam ce State Machine e cots eile a eee ea Ue Reda ie ea eee 27 LCD menus in open loop 2 0 6 cette eee 27 Open loop start up strategy 1 2 0 eee 28 LCD menus in closed loop 00 cece teens 29 Closed loop start up strategy llis eee 30 ICS hardware connections 2l 31 Encoder output signals counter operation llle 32 DBGC bit in PWM control register extract from STR750 reference manual 34 Valta and Vheta stator voltage components 0 6 eee 39 SVPWM phase voltages waveforms llis res 39 PWM and TIMO synchronization REP RATE 1 0 eee eh 42 Three shunt topology current sampling and GP A D conversions integration REP RATER CM r 43 Inverter leg and shunt resistor position llle 43 Low side switches gate signals low modulation indexes 20055 45 Low side Phase A duty cycle gt DT TN 2TS TH TDMA 000005 45 DT TN TS lt Low side Phase A duty cycle lt DT TN
42. SE B CHANNEL parameter in MC pwm ics prm h About the positive current direction convention a positive half wave on PHASE X CHANNEL is expected corresponding to a positive half wave on the current coming out of the related inverter leg see direction of in Figure 16 Figure 16 ICS hardware connections Phase A Phase B e A To PHASE A CHANNEL To PHASE B CHANNEL Selecting PHASE A CHANNEL and PHASE B CHANNEL Default settings for PHASE A CHANNEL and PHASE B CHANNEL are respectively ADC CHANNEL11 and ADC_CHANNEL10 You can change the default settings if the hardware requires it by editing the MC pwm ics prm h file However there are a few rules to follow when selecting the new ADC channels e You must initialize the proper GPIOs as analog inputs an example for channel 8 is given below ADC Channel 8 pin configuration GPIO InitStructure GPIO Mode GPIO Mode AIN GPIO InitStructure GPIO Pin GPIO Pin 29 GPIO_Tnit GPIOO amp GPIO InitStructure 31 105 Running the demo program UM0324 3 4 32 105 e You must select two contiguous channels for example ADC CHANNEL8 and ADC_CHANNEL9 and the one with the highest number must be associated with PHASE A CHANNEL for example PHASE A CHANNEL gt ADC CHANNELS PHASE B CHANNEL ADC CHANNELS How to build the system when using an incremental encoder Quadrature incremental encoders
43. UH 52 4 3 2 List of available functions and interrupt service routines 52 SVPWM Tos TIME cfle a a a x e ga Eus 53 SVPWM IcsCurrentReadingCalibration l l 53 SVPWM_IcsGetPhaseCurrentValues leere 54 SVPWM IcsCalcDutyCycles leen 54 4 3 3 Current sampling in isolated current sensor topology and integrating general purpose A D conversions ooocococooc 54 4 4 Induction motor IFOC vector control MC IFOC Drive c module 55 4 4 1 OVerVieW scis uua auk tek ees wines Seeded wae UR SUR UR RR OUR 55 4 4 2 List of available C functions 0 0 0 0 ccc eee 56 IFOCCIDEE La ded o wocstaw Se BOR ee eg Er a e ER h DG TPOC Model ia due ehh 8 24 dud et dtu utet A BR 57 PROC CalcBRl xTOFqueRef ikke s ux Reb edet t a EUR 59 4 105 ky UM0324 Contents q 4 5 4 6 4 7 CALADO M CUT 60 CaldROCELXSITpErGq o pRAPQepR aaa e Eque is 61 4 4 3 Detailed explanation about indirect field oriented control IFOC 61 4 4 4 Detailed explanation about field weakening operation 63 Reference frame transformations MC_Clarke_Park h module 65 4 5 1 SU MIA 65 4 5 2 List of available C functions oooooooooocooo 66 Clarken I Der 66 Parked i heed de ewe iwhawtes PRA rS lene esque DEP RE 67 REV Park PPM 67 Rev Park Circle Limitation cse 68 4 5 3 Detailed explanation about reference frame transformations 68 4 5 4 Ci
44. X Input Capture 2 define MAX SPEED FDBK This parameter defines the frequency above which speed feedback is not realistic in the application this allows to discriminate glitches for example The unit is 0 1Hz By default it is set to 6400 640 0Hz which corresponds to approximately 20000 RPM for a two pole pair motor e define MAX SPEED This parameter is the value returned by the function TAC_GetRotorFreqInHz if measured speed is greater than MAX SPEED FDBK The default value is 640Hz but it can be 0 or FFFF depending on how this value is managed by the upper layer software define MAX PSEUDO SPEED This parameter is the value returned by the function TAC_GetRotorFreq if measured speed is greater than MAX SPEED FDBK The unit is rad pwm period 2n rad OxFFFF See Section 4 7 4 Converting Hertz into pseudo frequency on page 83 for more details define MIN SPEED FDBK This parameter is the frequency below which speed feedback is not realistic in the application this allows to discriminate too low frequency This value is set to 1 Hz by default and depends on sensor and signal conditioning stage characteristics Typically the tacho signal is too weak at very low speed to trigger input capture on the MCU Note The MC tacho prm h file includes two formulas that allow to compute the minimum sensed speed when speed is increasing during
45. a sign discrepancy between the real rolling direction and the direction that is read To avoid this kind of reading error you can apply the following procedure UMO324 Running the demo program 1 Setthe DC source at low voltage 50V 2 Runthe system in closed loop operation and on the LCD observe the target and measured speeds The error occurs if the sign of the measured speed is opposite to the sign of the target speed For help with the LCD menus see Section 3 2 on page 29 3 Ifthe error occurs you can correct it by simply swapping and rewiring the encoder output signals If this isn t practical you can modify a software setting instead in the 75x encoder c file replace the code line TIM InitStructure TIM ICiPolarity TIM IC 1Polarity Rising with TIM InitStructure TIM ICiPolarity TIM IC1Polarity Falling 3 5 Fault messages This section provides a list of possible fault message that can be displayed on the LCD when using the software library together with the STR750MC KIT e Over Current An Emergency Stop was detected on the PWM peripheral dedicated pin If using STR750 MCKIT it could mean that either the hardware over temperature protection or the hardware over current protection were triggered Refer to the STR750 MCKIT User Manual for details e Over Heating An over temperature was detected on the dedicated analog channel the digit
46. al threshold NTC THRESHOLD and the relative hysteresis NTC_HYSTERESTS are specified in the MC_Misc c source file Refer to the STR750 MCKIT User Manual for details e Tacho timed out The speed feedback timed out Verify speed sensor connections e Start up failed The motor ramp up failed Refer to Section 3 1 and Section 3 2 for in depth information e Bus Over Voltage An over voltage was detected on the dedicated analog channel The digital threshold OVERVOLTAGE_THRESHOLD is specified in the MC_Misc c source file Refer to the STR750 MCKIT User Manual for details e Bus Under Voltage The bus voltage is below 20V DC This threshold is specified in the UNDERVOLTAGE THRESHOLD parameter in the MC Misc c source file Note The corresponding FAULT flag is not cleared by firmware therefore the STR750 must be reset after the bus voltage has been switched on 33 105 Running the demo program UM0324 3 6 Caution 34 105 Note on debugging tools The third party JTAG interface should always be isolated from the application using the MB535 JTAG opto isolation board it provides protection for both the JTAG interface and the PC connected to it During a breakpoint when using the JTAG interface for the firmware development the motor control cell clock circuitry should always be enabled if disabled a permanent DC current may flow in the motor because the PWM outputs are enabled which could cause permanent damage to th
47. al relation 14 lo 1g 0 For this reason to reconstruct the currents flowing through a generic three phase load it is sufficient to sample only two out of the three currents while the third one can be computed by using the above relation The flexibility of the STR750 A D converter trigger makes it possible to synchronize the two A D conversions needed for reconstructing the current flowing through the three phase AC induction motor at any given time along the PWM period To do this the control algorithm must have a full control of the A D converter peripheral 41 105 Library functions UM0324 42 105 Furthermore you have the possibility to add any A D conversions required for your application hereafter referred to as general purpose conversions This section describes how this is achieved First of all the SVPWM_3Shunt Init function performs the synchronization between PWM and TIMO peripherals Figure 27 shows the two peripheral counters when REP_RATE 1 then the A D converter peripheral is configured so that it is triggered by the TIMO OC2 signal Figure 21 PWM and TIMO synchronization REP_RATE 1 Synchronized start y This way when the value of the TIMO counter matches the value contained in the OCR2 register the first A D conversion for current sampling is started Meanwhile a DMA transaction reloads the TIMO OCR2 register with the value corresponding to the delay required f
48. alues of these voltage components Refer to Section 4 2 3 for details about the theoretical approach of SVPWM and its implementation Input Va and Vg Returns None Note None Functions called None Current sampling in isolated current sensor topology and integrating general purpose A D conversions The three currents l4 l2 and I5 flowing through a three phase system follow the mathematical relationship 14 lo 1g 0 Therefore to reconstruct the currents flowing through a generic three phase load it is sufficient to sample only two out of the three currents while the third one can be computed by using the above relationship The flexibility of the STR750 A D converter trigger makes it possible to synchronize the two A D conversions necessary for reconstructing the stator currents flowing through the three phase AC induction motor with the PWM reload register updates Tithe update rate can be adjusted using the repetition counter This is important because as shown in Figure 35 it is precisely during counter overflow and underflow that the average level of current is equal to ky UM0324 Library functions 4 4 4 4 1 the sampled current Refer to the STR750 Reference Manual to learn more about A D conversion triggering and the repetition counter Finally at the end of the injected chain conversion for current reading the general purpose A D conversions are performed while the CPU executes the IFOC algorithm
49. ate frequency 2 define F_2 200 20 Hz mechanical define Ki_F_2 1000 Intermediate frequency 2 coefficient settings define Kp_F_2 750 define Kd_F_2 1200 Settings for max frequency define Freq Max 500 50 Hz mechanical define Ki_Fmax 500 Frequency max coefficient settings define Kp_Fmax 500 define Kd_Fmax 500 Once the motor is running integer proportional and derivative coefficients are computed following a linear curve between F min and F 1 F 1 and F 2 F 2 and F max see Figure 47 Note that F min F 1 F 2 F max are mechanical frequencies with 0 1 Hz resolution for example F 1 1234 means F_1 123 4Hz Figure 47 Linear curve for coefficient computation Ki Kp Kd KEE 2 KD E 2 KdcES L0 G uMxe m Ki Fmax Kp Fmax Kd Fmax Ki F1 Kp F1 KdaF1i Ki_Fmin Kp_Fmin Kd_Fmin j Rotor mechanical F min F 1 F2 F max frequency Disabling the linear curve computation routine 75x it c module If you want to disable the linear curve computation you must comment out the PID Speed Coefficients update routine In this case the default values for Ki Kp Kd for torque flux and speed regulation are used See PTD TORQUE Kx DEFAULT PID FLUX Kx DEFAULT PID SPEED Kx DEFAULT inthe MC control Param h file ky UMO324 Library functions To disable the linear curve computation routine in 75x_TBtimer void TB_
50. available functions as listed in the 75x svpwm ICS h header file e SVPWM lcslnit on page 53 e 3SVPWM lcsCurrentReadingCalibration on page 53 e SVPWM lcsGetPhaseCurrentValues on page 54 e 3SVPWM lcsCalcDutyCycles on page 54 UM0324 Library functions SVPWM IcsInit Synopsis Description Input Returns Note Functions called void SVPWM JIcslnit void The purpose of this function is to set up microcontroller peripherals for performing ICS reading and center aligned PWM generation The function initializes EIC ADC GPIO and PWM peripherals In particular ADC and PWM peripherals are configured to perform one injected chain of two A D conversions every time PWM registers are updated event called U event Refer to Section 4 3 3 for further information on A D conversion triggering in ICS configuration None None It must be called at main level Standard library MRCC_PeripheralClockConfig GPIO Init EIC IRQlnit EIC IRQOmd PWM Delnit PWM Structlnit PWM Init PWM TRGOSelection PWM ClearFlag PWM ITConfig PWM ResetCounter ADC Structlnit ADC Init ADC Cmd ADC StartCalibration ADC_ConversionCmd PWM Cmd Motor control library SVPWM lIcsCurrentReadingCalibration SVPWM IcsCurrentReadingCalibration Synopsis Description Input Returns Note Functions called void SVPWM IcsCurrentReadingCalibration void The purpose of this function is to store the two analog voltages corresponding
51. bed in this header file does not match the hardware that is actually in use or in case of wrong wiring More specifically define ICS SENSORS To be uncommented when current sampling is done using isolated current sensors define THREE SHUNT To be uncommented when current sampling is performed via three shunt resistors default define ENCODER To be uncommented when an incremental encoder is connected to the starter kit for position sensing in parallel fill out MC encoder param h as explained in Section 2 2 3 e define TACHO To be uncommented when a tachogenerator is in use to detect rotor speed default in parallel fill out MC tacho prm h as explained in Section 2 2 4 define Id Iq DIFFERENTIAL TERM ENABLED To be uncommented when differential terms for torque and flux control loop regulation PID are enabled e define SPEED DIFFERENTIAL TERM ENABLED To be uncommented when differential term for speed control loop regulation PID is enabled Once these settings have been done only the required blocks will be linked in the project this means that you do not need to exclude c files from the build When using shunt resistors for current measurement ensure that the REP RATE parameter in MC Control Param h is set properly see Section 2 2 2 and Section A 2 Selecting PWM frequency for 3 shunt resistor c
52. chasers are solely responsible for the choice selection and use of the ST products and services described herein and ST assumes no liability whatsoever relating to the choice selection or use of the ST products and services described herein No license express or implied by estoppel or otherwise to any intellectual property rights is granted under this document If any part of this document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products or services or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such third party products or services or any intellectual property contained therein UNLESS OTHERWISE SET FORTH IN ST S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY WITH RESPECT TO THE USE AND OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED WARRANTIES OF MERCHANTABILITY FITNESS FOR A PARTICULAR PURPOSE AND THEIR EQUIVALENTS UNDER THE LAWS OF ANY JURISDICTION OR INFRINGEMENT OF ANY PATENT COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT UNLESS EXPRESSLY APPROVED IN WRITING BY AN AUTHORIZED ST REPRESENTATIVE ST PRODUCTS ARE NOT RECOMMENDED AUTHORIZED OR WARRANTED FOR USE IN MILITARY AIR CRAFT SPACE LIFE SAVING OR LIFE SUSTAINING APPLICATIONS NOR IN PRODUCTS OR SYSTEMS WHERE FAILURE OR MALFUNCTION MAY RESULT IN PERSONAL INJURY DEATH OR SEVERE PROPERTY
53. cording to increasing stator frequency column P should be copied as hFlux_Reference in MC ACMotor Prm h e saturation values of current component iss in q1 15 format according to increasing stator frequency column Q should be copied as hTorque Reference in MC ACMotor Prm h 4 5 Reference frame transformations MC Clarke Park h module 4 5 1 Overview This module intended for AC machines induction synchronous and PMSM is designed to perform transformations of electric quantities between frames of reference that rotate at different speeds Based on the arbitrary reference frame theory the module provides three functions named after two pioneers of electric machine analysis E Clarke and R H Park These functions implement three variable changes that are required to carry out field oriented control FOC e Clarke transforms stator currents to a stationary orthogonal reference frame named qd frame see Figure 40 e then from that arrangement Park transforms currents to a frame that rotates at an arbitrary speed which in IFOC drive is synchronous with the rotor flux e Reverse Park transformation brings back stator voltages from a rotating qd frame to a stationary one 65 105 Library functions UM0324 4 5 2 Clarke 66 105 Figure 40 Clarke Park and reverse Park transformations Clarke Park Vg d List of available C functions e Clarke on page 66 e Parkon page 67 e Hev Pa
54. displayed on the LCD during FAULT state UM0324 Running the demo program 3 1 Figure 11 Main c state machine 1sec delay elapsed Open loop Figure 12 shows a summary of the LCD menus and settings blinking items are shown underlined Figure 12 LCD menus in open loop Open Ret Hz Motor stopped Open closed loop selection Speed 0000 0 Hz Motor running no access Iq 02000 PID torque regulator target selection Id 00000 Measured torque top right and flux bottom right Iq 02000 PID flux regulator target selection Id 00000 Switching from open to closed loop operation and vice versa is done by moving the joystick up or down while the first menu shown in Figure 12is displayed and the motor is stopped 27 105 Running the demo program UM0324 Caution 28 105 Moving the joystick left or right in these circumstances allows changing the context into the second menu where it is possible to modify both the torque and flux reference Finally press either the KEY button or the joystick to start the motor main state machine will move from IDLE to START state The ramp up strategy is illustrated in Figure 13 Basically the applied torque reference reaches the final Iq value set with the joystick in the time that you configure in the STARTUP RAMP DURATION parameter defined in MC Control Param h following a linear ramp After STARTUP RAMP DURATION if valid i
55. e power stage and or motor A dedicated bit in the PwM CR the DBGC bit must be set to 1 see Figure 18 Figure 18 DBGC bit in PWM control register extract from STR750 reference manual Control Register PWM CR Address Offset 00h Reset value 0000h 15 14 13 12 11 10 9 8 7 6 5 3 2 1 0 CNT CNT DBASE DBGC MMS res CMS U D OPM EN RST UFS TW TW TW rw rw TW TW nw TW TW rw rw TW mw rw DBGC Debug Control SeeSection 9 5 3 Debug mode on page 186 for a detailed description Bit 10 z h O The timer is stopped in debug mode 1 The timer continues working in debug mode UMO324 Library functions 4 Library functions 4 1 Function description conventions Functions are described in the format given below Synopsis Lists the prototype declarations Description Describes the functions specifically with a brief explanation of how they are executed Input Gives the format and units Returns Gives the value returned by the function including when an input value is out of range or an error code is returned Note Indicates the limits of the function or specific requirements that must be taken into account before implementation Caution Indicates important points that must be taken into account to prevent hardware failures Functions called Lists called functions Useful to prevent conflicts due to the simultaneous use of resources Code example Indicates the proper way to use the function and if t
56. e saturation boundary could be a value slightly lower than 16 MAX depending on PWM switching frequency when using three shunt resistor configuration Table 2 on page 51 repeated below for convenience shows the maximum applicable modulation index as a function of PWM switching frequency when using the STR750 MCKIT PWM frequency Max duty cycle Max modulation index MMI Up to 11 4kHz 10096 10096 12 2kHz 99 5 99 12 9kHz 99 98 13 7kHz 98 5 97 14 4kHz 98 96 15 2kHz 97 5 95 16kHz 97 94 16 7kHz 96 596 93 17 5kHz 96 92 The figures above were measured using the MB459 board This evaluation platform is designed to support several motor driving topologies PMSM and AC induction and current reading strategies single and three shunt resistors Therefore the figures provided in should be understood as a starting point and not as a best case The RevPark_Circle_Limitation function performs the discussed stator voltage components saturation as illustrated in Figure 42 UM0324 Library functions 4 Figure 42 Circle limitation working principle V V2 V MMI S16_MAX Va and V represent the saturated stator voltage component to be passed to the SVPWM block From geometrical considerations it is possible to draw the following relationship _ V MMI S16 MAX V E d V _ Vj MMI S16 MAX q NA In order to speed up the computation of the abo
57. e wired to TIMER2 input pins default required if using STR750 MCKIT 2 2 4 Tachogenerator parameters MC tacho prm h The MC tacho prm h header file is to be filled out if speed sensing is performed using an AC tachogenerator Extra details and more explanations on tacho based speed measurement can be found in Section 4 7 on page 76 and Section A 4 on page 100 define TACHO PULSE PER REV Define here the number of pulses per revolution given by the tachogenerator in order to verify the correct operation of the tacho module this parameter can be set to 1 so that the frequency measurement can be directly compared with the one of a signal generator 21 105 Getting started with the library UM0324 define TIMERO_HANDLES_TACHO To be uncommented if tachogenerator based speed measurement is performed by TIMERO define TIMER1_HANDLES_TACHO To be uncommented if tachogenerator based speed measurement is performed by TIMER1 define TIMER2 HANDLES TACHO To be uncommented if tachogenerator based speed measurement is performed by TIMER2 Default required if using STR750 MCKIT in conjunction with Input Capture 1 choice see below define TACHO INPUT TI1 To be uncommented if sensor output signal is wired to TimerX Input Capture 1 Default in conjunction with TIMER2 choice required if using STR750 MCKIT define TACHO INPUT TI2 To be uncommented if sensor output signal is wired to Timer
58. ed See also void ADC IRQHandler void The purpose of this function is to handle the ADC interrupt request The end of the stator current conversions interrupt routine JECH in case of ICS EOC in case of three shunt resistors is used to trigger execution of the IFOC algorithm Moreover the general purpose conversions are also started in this ISR None None IFOC Model In THREE SHUNT configuration SVPWM_3ShuntGPADCConfig In ICS configuration IFOC Model Section 4 2 4 and Section 4 3 3 on page 54 for more details General purpose time base 75x TBtimer module Overview The purpose of the 75x TBtimer module is to generate a time base that can be used by the other modules of the applications List of available functions and interrupt service routines The following is a list of available functions as listed in the 75x TBtimer c source file e TB StartUplnit on page 91 e TB Timebase Timer Init on page 91 e TB Waiton page 92 e TB StartUp Timeout IsElapsed TB Delay IsElapsed TB DisplayDelay IsElapsed on page 92 page 92 TB Set Delay 500us TB Set DisplayDelay 500us TB Set StartUp Timeout on e TB IRQHandler on page 93 UM0324 Library functions TB StartUpInit Synopsis Description Input Returns Note Caution Functions called TB Timebase Timer Init Synopsis Description Input Returns Functions called void TB StartUplnit void This function performs all the ope
59. following flow diagrams Figure 53 and Figure 54 show the decision tree for the computation of the torque flux and speed regulation routines Figure 53 Torque flux control loop block diagram Measured Torque Flux cp Target Torque Flux Torque Flux error signed 16 bit Proportional Kp x Torque Flux Error Is PI output saturated Integral Integral Ki x Torque Flux Error Integral term frozen If enabled See Differential Kd x Error Torque Flux Bsp Output value to important Previous Error Torque Flux signed int domain note in section 2 2 1 Output Proportional 2 13 Integral 2 16 Differential terms 2 13 Is Output lt PI D lower lim or gt PI D upper limit Clamp Output value to unsigned PI D lower limit PI D upper limit Set Saturated Output Flag Reset Saturated Output Flag return Output value signed 16 bit 4 UM0324 Additional information A 6 A 7 Figure 54 Speed control loop block diagram Is PI output saturated Integral Integral Ki x Slip Error Clamp Output value to signed int domain ntegral term frozen If enabled See lt important note in section 2 2 1 _ Differential Kd x Error Speed Previous Error Speed Output Proportional 2 8 Integral 2 14 Differential terms 2 8 Is Output lt PI D lower lir or PI D upper limit
60. g flux torque and in case of closed loop motor speed List of available functions and interrupt service routines The following is a list of available functions in the MC PID regulators module e PID Init on page 83 e PID Flux Regulator on page 84 e PID Torque Hegulator on page 84 e PID Speed Hegulator on page 85 e PID Heset Integral terms on page 85 e PID Speed Coefficients update on page 85 e PID Integral Speed update on page 85 Synopsis void PID Init void Description The purpose of this function is to initialize the PIDs for torque flux and speed regulation For each one a set of default values are loaded target speed torque or flux proportional integral and derivative gains lower and upper limiting values for the output Functions called None Note Default values for PID regulators are declared and can be modified in the MC Control Param h file see Section 2 2 2 on page 19 83 105 Library functions UMO324 PID Flux Regulator Synopsis Description Input Output Functions called Note See also PID Torque Regulator Synopsis Description Input Output Functions called Note See also s16 PID Flux regulator PID FluxTYPEDEF PID Flux s16 gld input The purpose of this function is to compute the proportional integral and derivative terms if enabled see Id Iq DIFFERENTIAL TERM ENABLED in Section 2 2 1 on page 18 for the flux regulation PID Fl
61. g that information is lost or that speed is decreasing sharply None None This function must be called to re arm the time out detection mechanism and re start rotor frequency measurements the returned frequency is 0 as long as the time out flag is set u16 TAC_GetCaptCounter void This routine gives the number of tacho capture interrupts since the last call to the TAC_ClrCaptCounter function None Unsigned 16 bit integer This variable cannot roll over this is prevented in the tacho capture routine itself it will be limited to max u16 value This function is typically used to monitor the interrupts activity while the motor is running tacho related interrupts must not be stopped or too frequent TAC_ClrCaptCounter 79 105 Library functions UMO324 TAC ClrCaptCounter Synopsis Description Input Output TAC StartTachoFiltering Synopsis Description Input Output Note TAC ValidSpeedInfo Synopsis Description Input Output Caution 80 105 void TAC ClrCaptCounter void This routine clears the number of capture events variable None None void TAC StartTachoFiltering void This routine initiates the tacho value smoothing mechanism The result of the next capture will be copied in all storage array locations to have the first average equal to the last value None None The initialization of the FIFO used to do the averaging will be done when the next tacho capture i
62. gned 16 bit value adjustable from 0 to 32767 Torque and flux controller setpoints and PID constants define PID TORQUE REFERENCE The torque reference value in open loop at start up signed 16 bit value define PID TORQUE KP DEFAULT The proportional constant of the torque loop regulation signed 16 bit value adjustable from 0 to 32767 define PID TORQUE KI DEFAULT The integral constant of the torque loop regulation signed 16 bit value adjustable from 0 to 32767 define PID TORQUE KD DEFAULT The derivative constant of the torque loop regulation signed 16 bit value adjustable from 0 to 32767 define PID FLUX REFERENCE The flux reference its default value is NOMINAL FLUX which is adjustable by modifying the parameter hNominal Flux see Section 2 2 5 define PID FLUX KP DEFAULT The proportional constant of the flux loop regulation signed 16 bit value adjustable from 0 to 32767 define PID FLUX KI DEFAULT The integral constant of the flux loop regulation signed 16 bit value adjustable from 0 to 32767 define PID FLUX KD DEFAULT The derivative constant of the flux loop regulation signed 16 bit value adjustable from 0 to 32767
63. he duty cycles applied to the low side switches are the highest In particular by looking at Figure 20 you can deduct that in sectors 1 and 6 the voltage on the Phase A shunt resistor can be discarded likewise in sectors 2 and 3 for Phase B and finally in sectors 4 and 5 for Phase C Moreover in order to properly synchronize the two stator current reading A D conversions it is necessary to distinguish between the different situations that can occur depending on PWM frequency and applied duty cycles The explanations below refer to space vector sector 1 They can be applied in the same manner to the other sectors Case 1 Duty cycle applied to Phase A low side switch is larger than DT Ty 2Ts Ty TpMA Where e DT is dead time e Ty is the duration of the noise induced on the shunt resistor voltage of a phase by the commutation of a switch belonging to another phase Tgisthe sampling time of the STR750 A D converter Refer to the STR750 reference manual for more detailed information e Ty is the holding time of the STR750 A D converter Refer to the STR750 reference manual for more detailed information Tpma is the time required for the DMA to load the value related to the next conversion delay in TIMO OCR2 refer to Section 4 2 4 Current sampling in three shunt topology and general purpose A D conversions on page 41 for further details This case typically occurs when SVPWM with low 6096 modulation index is gene
64. here are certain prerequisites interrupt enabled etc Some of these sections may not be included if not applicable for example no parameters or obvious use 4 2 Current reading in three shunt resistor topology and space vector PWM generation 75x svpwm 3shunt module 4 2 1 Overview Two important tasks are performed in the 75x svpwm 3shunt module e Space vector pulse width modulation SVPWM e Current reading in three shunt resistor topology In order to reconstruct the currents flowing through a three phase load with the required accuracy using three shunt resistors it is necessary to properly synchronize A D conversions with the generated PWM signals This is why the two tasks are included in a single software module 35 105 Library functions UMO324 4 2 2 List of available functions The following is a list of available functions as listed in the 75x svpwm 3shunt h header file e 3SVPWM SShuntlnit on page 36 SVPWM 3ShuntInit 36 105 Synopsis Description Input Returns Note Functions called SVPWM SShuntCurrentReadingCalibration on page 37 SVPWM SShuntGetPhaseCurrentValues on page 37 SVPWM SShuntCalcDutyCycles on page 38 SVPWM SShuntGPADCConfig on page 38 void SVPWM 3Shuntlnit void The purpose of this function is to set up microcontroller peripherals for performing 3 shunt resistor topology current reading and center aligned PWM generation The function initializes DMA EIC ADC GPIO
65. hich for a first order ODE written as y f ty may be summarized in this way Y 1 Yn t At f t Yn where t is the sampling time Putting the equation above in the explicit form we have 62 105 77 UM0324 Library functions 4 4 4 dr dr l L T L m n l m n r m A A 7 A 4 At E A y E Nas h yp n On the other hand under the same conditions the q axis rotor flux equation becomes Ar Ar e Ar A CL FL qr Ir qr e Ary i 0 So the equation for igr is Combining the last with the q axis rotor voltage equation leads to Ar T Lar T L v Ar r m Oa O o E Ar L A Ar Las dr r dr This equation implemented in the CalcRotFIxSlipFreq function see CalcRotFIxSlipFreg on page 61 is at the foundation of indirect field oriented control it tells us that the rotor flux slip frequency y may be simply calculated from stator current components relying on knowledge of the rotor time constant of the machine If rotor angle or rotor speed is known see Figure 36 and Figure 37 respectively then we have managed to determine the rotor flux position 05 This information is essential to achieve optimum control Detailed explanation about field weakening operation Many applications need to operate induction machines above their rated speed this is achieved by means of field weakening The conventional method for the field weakening operation is to vary the
66. in UM0324 Getting started with tools 1 3 3 1 4 1 4 1 Starting the IAR toolchain When you have installed the toolchain you can open the workspace directly from the dedicated folder by double clicking on the 1FOC eww file The file location is FOC_AC_SR_v1 0 Y IAR Y IFOC eww Customizing the workspace for your STR750X derivative The AC IM IFOC software library was written for the STR750FVT2 However it works equally successfully with all the products in the STR75x family Using a different STR750 sales type may require some modifications to the library according to the available features some of the I O ports are not present on low pin count packages Refer to the datasheet for further details Also depending on the memory size the workspace may have to be configured to fit your STR75x MCU derivative Figure 3 Device summary Features STR755FRx STR751FRx STR752FRx STR755FVx STR750FVx Flash Bank O 64K 128K 256K bytes Flash Bank 1 bytes 16K RWW RAM bytes 16K Operating Temp 40 to 85 C 40 to 105 C see Table 41 3 UARTS 2 SSPs 1 1 C Common Peripherals 2 UARTs 2 SSPs 1 12C 3 timers 1 PWM timer 3 timers 1 PWM timer 72 F Gg 38 I Os 13 Wake up lines 11 A D Channels I Os 15 Wake up lines 16 A D Channels USBCAN None USB CAN None USB CAN peripherals Operating Voltage 3 3V or 5V 3 3V 3 3V or 5V m i T T LQFP100 14x14 Package
67. ivate functions Result is zero if speed is too low glitches at start for instance Excessive speed or glitches will result in a pre defined value returned see Section 2 2 4 on page 21 Maximum expectable accuracy depends on CKTIM 60MHz will give the best results This routine returns the mechanical frequency of the rotor To find the electrical speed use the following conversion electrical frequency mechanical frequency number of pole pairs 77 105 Library functions UMO324 TAC_GetRotorFreq Synopsis Description Input Output Functions called Note Caution GetLastTachoPeriod Synopsis Description Input Output Functions called Note GetAvrgTachoPeriod 78 105 Synopsis Description Input Output Functions called Note u16 TAC GetRotorFreq void This routine returns rotor frequency with a unit that can be directly integrated accumulated to get the rotor angular position in the main control loop None Rotor mechanical frequency with rad PWM period unit 21 rad OXFFFF assuming the control loop is executed in each and every PWM interrupt service routine GetAvrgTachoPeriod GetLastTachoPeriod both private functions Result is zero if speed is too low glitches at start for instance Excessive speed or glitches will result in a pre defined value returned see Section 2 2 4 on page 21 Maximum expectable accuracy depends on CKTIM 60MHz will give the best resul
68. ken when this routine is called at main interrupt level a call from an interrupt routine with a higher priority than the timebase interrupt will freeze code execution TB Set Delay 500us TB Set DisplayDelay 500us TB Set StartUp Timeout Synopsis Description Input Returns Functions called void TB Set Delay 500us u16 void TB Set DisplayDelay 500us u16 void TB Set StartUp Timeout u16 These functions are used to respectively update the values of the hTimebase 500us hTimebase display 500us and hStart Up TimeBase 500us variables They are used to maintain the main state machine in FAULT state to set the refresh rate of the LCD and the Start up timeout Unsigned 16 bits None None TB StartUp Timeout IsElapsed TB Delay IsElapsed TB DisplayDelay IsElapsed 92 105 Synopsis Description Input Returns Functions called bool TB StartUp Timeout IsElapsed void bool TB Delay IsElapsed void bool TB DisplayDelay IsElapsed void These functions return TRUE if the related delay is elapsed FALSE otherwise None Boolean None UM0324 Library functions TB IRQHandler Synopsis void TB IRQHandler void Description This is the Timebase timer interrupt routine It is executed every 500us as determined by TB Timebase Timer Init and is used to refresh various variables used mainly as counters for example PID sampling time Moreover this routine implements the startup torque ramp described in Sec
69. le array UM0324 Additional information Figure 51 Processing captured value when timer did not overflow Store capture value Prescaler decreased Store current prescaler value 1 in prev int Reset flag indicating decrement No Capture lt 0x5500 Yes Store current prescaler value J Is the prescaler already 0 Store current prescaler value Store current prescaler value Decrease prescaler register Set flag indicating decrement for next capture interrupt Figure 52 Processing captured value when timer did overflow Store capture value in CaptBuf Store prescaler value in PrscBuf Is overflow Cnt 0 Does Capture exceeds 16 bit format Compute total number of clock cycle 0x10000 per overflow Make it fit 16 bit by increasing PrscBuf Prescaler will overflow Set max value to CaptBuf and PrscBuf Store CaptBuf and PrscBuf in array Did previous capture cause overflow Reset flag indicating increment Is prescaler at Increase Timer clock presale max value already Set flag indicating increment for next capture interrupt q 101 105 Additional information UM0324 A 5 102 105 PID block diagrams The
70. load related to IFOC algorithm execution The Synchronizable PWM Timer peripheral has the built in capability of updating PWM registers only after a given number of PWM semi periods This feature is handled by a programmable repetition counter It is particularly useful to adjust the CPU load related to IFOC algorithm execution for a given PWM frequency refer to STR750 Reference Manual for more information on programmable repetition counter When using ICS the injected chain of conversions for current reading is directly triggered by a PWM register update event Moreover since the IFOC algorithm is executed at the end of the injected chain of conversions in the related ISR changing repetition counter has a direct impact on IFOC refresh rate and thus on CPU load However in the case of three shunt topology current reading to ensure that the IFOC algorithm is executed once for each PWM register update it is necessary to keep the synchronization between current conversions triggering and PWM signal In the proposed software library this is automatically performed so that you can reduce the frequency of execution of the IFOC algorithm by simply changing the default value of the repetition counter the REP_RATE parameter in the MC_Control_Param h header file Figure 48 shows current sampling triggering and IFOC algorithm execution with respect to PWM period when REP_RATE is Set to 3 Figure 48 AD conversions for three shunt topolog
71. luation platform it is designed to support different motor driving topologies PMSM and AC induction and current reading strategies single and three shunt resistors Therefore the figures given in Table 2 on page 51 should be understood as a starting point and not as a best case Moreover to keep the synchronization between TIMO and PWM peripherals it is always necessary to finish executing the IFOC algorithm before the next PWM period begins as shown in Figure 49 Figure 49 AD conversions for three shunt topology stator currents reading and IFOC algorithm execution when REP_RATE 1 PWM counter M P riod IFOC algorithm IFOC algorithm execution executioni 8B E 8B Ee 1bt 2hd 1st qm TIMO counter ADC ADC ADE ApC Given that the raw execution time of the IFOC algorithm is around 27 5us and that other delays such as the time necessary to enter ADC ISR have to be considered this limits to about 12 5 kHz the maximum IFOC algorithm execution rate when using REP RATE 1 However no limitations occur in the typical range of PWM frequencies when using REP RATE 3 The following table summarizes the performance of the system for different PWM frequencies UM0324 Additional information A 3 Table 4 System performance when using STR750 MCKIT PWM frequency Max applicable duty cycle Max IFOC algo
72. n debugging tools lt ooooooooornrnnnnoo 34 4 Library functions cuiua p 08 6 arn ge CR a e O M a e 35 4 1 Function description conventions 2 0 eee eee 35 4 2 Current reading in three shunt resistor topology and space vector PWM generation 75x svpwm 3shunt module 2 000 35 4 2 1 OVEIVIEW 2 1 diede qe d CER doa ation a Sh cte ee uh reds 35 4 2 2 List of available functions 00 0c eee eee eee 36 SVPWM 39H nt Ente uec nat OE eat eee eS ede dE duit ete d deis 36 SVPWM 3ShuntCurrentReadingCalibration llle 37 SVPWM 3ShuntGetPhaseCurrentValues s l 37 SVPWM 3ShuntCalcDutyCycles eens 38 SVPWM 3ShuntGPADCConfig cese 38 4 2 3 Space vector PWM implementation 0 00 cece eee eae 39 4 2 4 Current sampling in three shunt topology and general purpose A D conversions 41 4 2 5 Tuning delay parameters and sampling stator currents in three shunt resistor topology lsssseseseeeeeele Ies 43 Case 1 Duty cycle applied to Phase A low side switch is larger than DT TN 2TS TH TDMA oooococco eens 44 Case 2 DT TN TS lt Phase A duty cycle lt DT TN 2TS TH TDMA 46 Case 3 Phase A pulse width lt DT TN TS 0 000 c eee eee eee 48 4 3 Isolated current sensor reading and space vector PWM generation 75x svpwm ICS module eee 52 4 3 1 OVerVIOW ia iria Rada OS Ye a See Res E ee POR NUR CRGO
73. nctions called Note 74 105 void ENC_resetEncoder void This function resets the encoder timer hardware register value to zero TIM ResetCounter STR750 datasheet synchronizable standard timer void ENC Clear Speed Buffer void This function resets the buffer used for speed averaging None s16 ENC Get Speed void This function returns the rotor speed in Hz The value returned is given with 0 1Hz resolution which means that 1234 is equal to 123 4 Hz None Signed 16 bits None This routine returns the mechanical frequency of the rotor To find the electrical speed use the following conversion electrical frequency number of pole pairs mechanical frequency UM0324 Library functions ENC Get Average Speed Synopsis Description Input Output Functions called Note s16 ENC Get Average Speed void This function returns the average rotor speed in Hz The value returned is given with 0 1Hz resolution which means that 1234 is equal to 123 4 Hz None Signed 16 bits ENC Get Speed The averaging is done with the values stored in Speed Buffer The size of this buffer is set through the SPEED BUFFER SIZE statement which must be equal to a power of 2 to allow the use of the shift operation for divisions This routine returns the mechanical frequency of the rotor To find the electrical speed use the following conversion electrical frequency mechanical frequency number of pole pairs
74. nformation from the speed sensor tachometer or encoder is detected the torque reference becomes adjustable on the fly from the joystick On the contrary if no valid information from the speed sensor is detected for example because a problem occurred with speed sensor connections or because the load torque is higher then the value that you set then the final torque reference is kept constant until STARTUP TIMEOUT Finally when no valid speed information comes from the motor and STARTUP_TIMEOUT is elapsed the main state machine goes into FAULT state for two seconds and the error message Start up failed is displayed on the LCD In this case it is strongly advised to check speed sensor feedback connections first and then if necessary to increase the final ramp torque reference in case the load torque is too high In open loop operation a constant torque reference is produced Depending on the load torque applied this could lead to constant acceleration of the motor making the speed rise up to the motor s physical limits Figure 13 Open loop start up strategy Torque reference set L by Joystick STARTUP RAMP DURATION STARTUP_TIMEOUT t UM0324 Running the demo program 3 2 Closed loop Figure 14 shows a summary of the LCD menus and settings blinking items are shown underlined Figure 14 LCD menus in closed loop Closed Ref 0015Hz Motor stopped Open closed loop
75. nterrupt occurs Consequently the TAC_GetRotorFreq will continue to return a raw period value until the next interrupt event bool TAC ValidSpeedlnfo u16 hMinRotorFreq This routine indicates if the information provided by the tachogenerator is reliable this is particularly important at start up when the signal of the tacho is very weak and cannot be properly conditioned by the external circuitry glitches It is also used in start up functions to find out if the rotor shaft is turning at the right speed Rotor frequency 0 1Hz resolution above which speed information is not considered reliable rolling averages cannot be computed Boolean TRUE if the tacho provides clean signals Because there is no way to differentiate rotation direction with a tachogenerator you must be aware that this routine may return TRUE in certain conditions re start with very short or no stop time and high inertia load You should therefore manage a minimal amount of time before re starting This function is not effective if the start up duration time for the voltage to settle is much shorter than the time needed to obtain at least two consecutive speed data UMO324 Library functions TIMx IC12 IRQHandler Synopsis void TIMx IC12 IRQHandler void Description This function handles the capture event interrupt in charge of tacho signal period measurement It updates an array where the 4 latest period measurements are stored resets the
76. oach of SVPWM Input V and Vg Returns None Note None Functions called None SVPWM 3ShuntGPADCConfig 38 105 Synopsis void SVPWM 3ShuntGPADCConfig void Description The purpose of this function is to configure the A D converter for general purpose conversions after conversions for current reading have been performed In particular this function starts a chain of regular conversions whose first channel is GP CONVERSIONS FIRST CHANNEL defined in MC pwm 3shunt prm h In addition the number of channels to be converted is set equal to GP CONVERSIONS NUMBER defined in MC_pwm_3shunt_prm h Input None Returns None Note As mentioned in Section 4 2 3 the overall duration of the regular chain conversion must be lower than the duration of the IFOC_Model routine This limits to 6 at 7 5MHz ADC peripheral clock the number of channels that can be converted in one PWM period Functions called None UM0324 Library functions 4 2 3 Space vector PWM implementation Figure 19 shows the Stator Voltage components V and Vg while Figure 20 illustrates the corresponding PWM for each of the six space vector sectors Figure 19 Vand Vz stator voltage components Vbeta Valfa Figure 20 SVPWM phase voltages waveforms 100 90 80 70 60 0 0 60 120 180 240 300 360 Phase A Phase B Phase C Sector 1 Sector 2 Sector 3 Sector 4 Sector 5
77. of the Phase A low side switch a blanking window equal to Ty is applied before starting conversion of phase C then at the end of the first conversion it is necessary to wait a Tpma period before starting the phase B conversion 45 105 Library functions UM0324 46 105 Case 2 DT TN TS lt Phase A duty cycle lt DT TN 2TS TH TDMA In this case only one of the two conversions can be performed between the two Phase A low side commutations The other conversion is then synchronized depending on the difference of duty cycles between Phase B and A ADutya p In particular if ADutya g lt DT Ty Ts as shown in the red circle in Figure 26 the sampling of Phase C cannot be performed between Phase B low side switching on and Phase A high side switching off see Figure 27 Therefore Phase C current sampling is performed before Phase B high side commutation Figure 26 DT Ty Tg lt Low side Phase A duty cycle lt DT Ty 2Ts Ty Tpma and ADuty p lt DT Ty Ts 100 90 80 70 60 50 40 30 20 10 0 0 30 60 Phase A Phase B Phase C UMO324 Library functions Figure 27 DT Typ Tg lt Low side Phase A duty cycle lt DT Ty 2Ts Ty Tpma and ADuty p lt DT TytTs ADuty 1 1 9 Low side Phase A YN LD Current feedback of y A _ Phase B Current feedback of 7 c rversion start Phase C aha T e Sampling end On the contrary if ADu
78. on files are updated accordingly Figure 9 Adding anew module JAR Embedded Workbench IDE File Edit View Project Simulator Tools Window Help ge g a ob m e 0 H Ys E 4e 4 p noe AZ Workspace 75x MClib h MC Control Param h MC encoder param h MC_acmotor_prm h MC_tacho_prm h MC_IFOC_Drive c_ my file c Dbo A Q ss545554444444445445 C COPYRIGHT 2006 SIMicroelectronics 544455444444444544 i Files E B x Nase x thor a 2 IFOC 1 i 4 Options 4 Date First Issued dd mm yyyy Ha A inclut 5 Description Para Make e Ha C3 starty A J 1 Poo AAA AAA AAA Std Rebuild all 8 History E 75x Clean 95 dd ux yyyy a 5x gt 10 ERRE AA AAA AAA AAA AAA AAA AAA flf bf lc Pl P Pf Pl AAA E 75x Ha M75 Add Fies ha El 5x Add my f fie e ha E 5x t Remove Add Group E 75x source Code Control Ha El main Ha a MC File Properties E El E MC I E MC Globals c MC IFOC Drive F MC Keys c E MC Misc c E MC PID regula 23 Output 25 105 Running the demo program UM0324 3 26 105 Running the demo program This section assumes that you are using the STR750 MCKIT motor control kit The demo program is intended to provide examples on how to use the software library functions it includes both open speed loop and closed speed loop operations hereafter simply referred to as Open Loop and Clo
79. onfiguration on page 98 for details UMO324 Getting started with the library 2 2 2 Drive control parameters MC_Control_Param h The MC Control Param h header file gathers parameters related to e Power device control parameters on page 19 e Flux and torque PID regulators sampling rate on page 19 e Speed regulation loop frequency on page 19 e Speedcontroller setpoint and PID constants initial values on page 20 e Torque and flux controller setpoints and PID constants on page 20 e Start up torque ramp parameters on page 21 e Linear variation of PID constants according to mechanical speed on page 21 Power device control parameters define PWM FREQ Define here in Hz the switching frequency in parallel uncomment the maximum allowed modulation index definition MAX MODULATION XX PER CENT corresponding to the PWM frequency selection define DEADTIME NS Define here in ns the dead time in order to avoid shoot through conditions Flux and torque PID regulators sampling rate define REP RATE Stator currents sampling frequency and consequently flux and torque PID regulators sampling rate are defined according to the following equation Flux and torque PIDs sampling rate ROM FREQ REP RATE 1 In fact because there is no reason for either executing the IFOC algorithm without updating the stator currents values or for performing stator current conversions without running the
80. or the second current sampling conversion Moreover the end of this first A D conversion triggers another DMA transaction which sets the next channel to be converted in the ADC register CLR2 At the end of the second conversion the three phase load current has been updated and the IFOC algorithm can then be executed in the A D End of Conversion Interrupt Service Routine EOC ISR In this routine the A D converter is also reconfigured so that it can perform the general purpose chain of conversions while the CPU executes the IFOC algorithm The entire process is illustrated in Figure 22 After execution of the IFOC algorithm the A D converter is configured to perform the next PWM period three phase current sensing delays and channels This allows to reduce the CPU load lower number of ADC ISR and limits to 6 7 5 MHz ADC peripheral clock the number of general purpose A D conversions that can be performed in each PWM period To specify the general purpose conversions to be performed you can select the first channel and the number of channels to be converted by editing the GP CONVERSIONS FIRST CHANNEL and GP CONVERSIONS NUMBER parameters respectively in the MC pwm 3shunt prm h header file UM0324 Library functions 4 2 5 Figure 22 Three shunt topology current sampling and GP A D conversions integration REP RATE 1 TIMO OC2 signal TIMO counter EOC Interrupt DMA
81. ors are useful to maintain a level of torque flux or speed according to a desired target Figure 45 PID general equation torque f rotor position ll torque and flux regulation for maximum flux f rotor position E system efficiency 1 torque regulation for speed regulation torque f rotor speed E of the system Where Error sys Error of the system observed at time t T ErrOfsys _ Error of the system observed at time t T Tsampling T f X7 Kp x Error sys Kix yError KyX Errorgy ErrOfsys 1 0 A a Derivative term can be disabled Equation 1 corresponds to a classical PID implementation where e K is the proportional coefficient e Kiis the integral coefficient e Kgis the differential coefficient As mentioned in Figure 45 the derivative term of the PID can be disabled independently through a compiler option see 75x_MCconf h file for the torque flux or the speed regulation a PI can then be quickly implemented whenever the system doesn t require a PID control algorithm Regulator sampling time setting The sampling time needs to be modified to adjust the regulation bandwidth As an accumulative term the integral term is used in the algorithm increasing the loop time decreases its effects accumulation is slower and the integral action on the output is delayed Inversely decreasing the loop time increases its effects accumulation is faster and the integral action on the ou
82. osition the unit is 2x rad that is OXFFFF per sampling period 4 7 3 Operating principle Although the principle of measuring a period with a timer is quite simple you must pay attention to keeping the best resolution in particular for signals such as the one provided by a tachogenerator which can vary with a ratio of up to 1 100 TA 81 105 Library functions UM0324 82 105 In order to have always the best resolution the timer clock prescaler is constantly adjusted in the current implementation The basic principle is to speed up the timer if captured values are too low for an example of low periods see Figure 43 and slow it down when the timer overflows between two consecutive captures see example of large periods in Figure 44 The prescaler modification is done in the capture interrupt taking advantage of the buffered registers the new prescaler value is taken into account only on the next capture event by the hardware without disturbing the measurement Further details are provided in the flowcharts in Section A 4 on page 100 Figure 43 Automatic tacho timer prescaler decrease Capture q Capture q Capture Capture q OxFFFF Capture value is too low the prescaler is decreased 0x5500 J7 W MR A EU At nae 0x0000 Prescaler preload Prescaler active Transfer from preload to active on nex
83. otor parameters power devices features speed position sensor parameters current sensors transconductance 2 Edit using an IDE the configuration header file 75x MCconf h as explained in more detail in Section 2 2 1 and the following parameter header files MC Control Param h see Section 2 2 2 MC encoder param h see Section 2 2 3 or MC tacho prm h see Section 2 2 4 MC_ACmotor_prm h see Section 2 2 5 3 Re build the project and download it on the STR750 microcontroller 17 105 Getting started with the library UM0324 2 2 1 Caution 18 105 Library configuration file 75x MCconf h The purpose of this file is to declare the compiler conditional compilation keys that are used throughout the entire library compilation process to e Select which current measurement technique is actually in use the choice is between three shunt or ICS sensors according to availability e Select which speed position sensor is actually performed here the choice is between tachometer and quadrature incremental encoder according to availability e Enable or disable the derivative action in the speed controller or in the current controllers in accordance with expected performance and code size If this header file is not edited appropriately no choice or undefined choice you will receive an error message when building the project Note that you will not receive an error message if the configuration descri
84. overflow counter and updates the clock prescaler to optimize the accuracy of the measurement If the average is enabled the last captured measurement is copied into the whole array Period captures are managed as follows e If too low capture value below 0x5500 the clock prescaler is decreased for the next measurement e If too high for example the timer overflowed the result is re computed as if there was no overflow and the prescaler is increased to avoid overflows during the next capture Input None Output None Note This is an interrupt routine TIMx UP IRQHandler Synopsis void TIMx UP IRQHandler void Description This function handles the overflow of the timer in charge of the tacho signal period measurement It updates a Counter of overflows which is reset when next capture occurs Input None Output None Note This is an interrupt routine 4 7 2 Integration tips In the MC tacho prm h file of your project select the Timer you have chosen and the input channel on which the tacho signal arrives using the right define see Section 2 2 4 on page 21 In the main c module or the c module just above 75x tacho include the 75x tacho h file call TAC_TachoTimerInit after MCU reset and TAC_InitTachoMeasure before motor start up TAC GetRotorFreqInHz returns a frequency directly with 0 1Hz while TAC_GetRotorFreq returns a value that can be directly accumulated in the FOC algorithm to get the rotor angular p
85. q on page 61 void IFOC_Init void This function is normally called at every motor start up It performs the initialization of some of the variables used for IFOC implementation by the MC IFOC Drive c module None None None None UM0324 Library functions IFOC_Model Synopsis Description Input Returns void IFOC_Model void The purpose of this function is to perform AC IM torque and flux regulation implementing the IFOC vector algorithm AY x Msg Current commands iqs and igs which under field oriented conditions can control machine torque and flux respectively are defined outside this function in closed loop they are provided by means of speed and flux regulators by the IFOC_CalcFluxTorqueRef function while in open loop mode they are settled by the user Therefore as a current source is required the function has to run the power converter as a CR PWM For this purpose it implements an high performance synchronous d q frame current regulator whose operating frequency is defined as explained in Section 2 2 2 by the parameter REP RATE in conjunction with PWM FREQ Triggered by ADC ECH JECH ISR the function loads stator currents read by ICS or shunt resistors and carries out Clark and Park transformations converting them to Md and ig see Figure 7 Then these currents are fed to PID regulators together with reference values igs and ig The regulator output voltages Nae
86. rameters 17 2 2 1 Library configuration file 75x_MCconf R sasaaa eee eee 18 2 2 2 Drive control parameters MC Control Param h 19 Power device control parameters tees 19 Flux and torque PID regulators sampling rate 0oooocoooooomoo 19 Speed regulation loop frequency 000 cee eee eee 19 Speed controller setpoint and PID constants initial values 20 Torque and flux controller setpoints and PID constants 20 Start up torque ramp parameterS 2 0000 cee eee eee eee 21 Linear variation of PID constants according to mechanical speed 21 2 2 3 Incremental encoder parameters MC_encoder_param h 21 2 2 4 Tachogenerator parameters MC tacho prm h sss 21 2 2 5 AC induction motor parameters MC ACmotor param h 23 2 3 How to define and add a c module cece eee eee nee 24 3 Running the demo program 00 cee eee eee eee 26 3 1 Open IDOD ise ck RR RE REREOG beets Mare wees E RR x Rs 27 3 2 XJoSedJ5BOD usura a Pa E ERE 29 3 3 Setting up the system when using ICS sensors 2055 30 3 3 1 Connecting the two ICS sensors to the motor and to STR750 31 3 3 2 Selecting PHASE A CHANNEL and PHASE B CHANNEL 31 Ti 3 105 Contents UMO324 3 4 How to build the system when using an incremental encoder 32 3 5 Fault messages exec dt e die wed 33 3 6 Note o
87. rated see Figure 24 The modulation index is the applied phase voltage magnitude expressed as a percentage of the maximum applicable phase voltage the duty cycle ranges from 096 to 100 Figure 25 offers a reconstruction of the PWM signals applied to low side switches of Phase A and B in these conditions plus a view of the analog voltages measured on the STR750 A D converter pins for both Phase B and C the time base is lower than the PWM period UM0324 Library functions Figure 24 Low side switches gate signals low modulation indexes 100 90 80 70 60 50 40 30 20 10 0 0 30 60 Phase A Phase B Phase C Note that these current feedbacks are constant in the view in Figure 25 because it is assumed that commutations on Phase B and C have occurred out of the visualized time window Moreover it can be observed that in this case the two stator current sampling conversions can be performed between the two commutations of the Phase A low side switch as shown in Figure 25 Figure 25 Low side Phase A duty cycle gt DT Ty 2Ts Ty Toma Low side Phase A U High side Phase A i A Low side Phase B Phase B i convession High side Phase B Pd T pog Tona Ts T i e rei Current feedback of W gt WW_ Phase B S Phase C i Ty or 1 e Sampling 1 e 1 i Current feedback of Zw al Tai i end Phase C nJ After the commutation
88. rations necessary for initializing both hardware and software every time the motor is restarted In particular speed feedback buffer and PID references are initialized and a 5096 duty cycle is generated for about 2msec for loading the boot capacitance of high side drivers None None This routine exits after the 2msec required for loading boot capacitance of high side drivers None PID Reset Integral terms IFOC Init TB Set StartUp Timeout PWM_CtrIPWMOutputs TB StartUp Timeout IsElapsed TB Set StartUp Timeout If working with encoder ENC Clear Speed Buffer If working with tachogenerator TAC InitTachoMeasure void TB Timebase Timer Init void The purpose of this function is to initialize the Timebase Timer The peripheral clock interrupt autoreload value and counter mode are setup The peripheral is configured to generate an interrupt every 500 us thus providing a general purpose timebase None None EIC IRQlnit TB Structlnit TB Init TB ITConfig TB Cmd TB ResetCounter TB ResetCounter 91 105 Library functions UMO324 TB_Wait Synopsis Description Input Returns Functions called Caution void TB_Wait u16 time This function produces a programmable delay equal to variable time multiplied by 500ys Unsigned 16 bit None None This routine exits only after the programmed delay has elapsed Meanwhile the code execution remains frozen in a waiting loop Care should be ta
89. rcle limitation sss 70 Encoder feedback processing 75x encoder c module 72 4 6 1 List of available functions and interrupt service routines 72 ENG STINE 4 e oh ecg ce IS e Se d o Aoc a AA ENC G6tPOSition lt e p w 09 Go k oe we wee x 4o ox 49 ENC Get Electrical Angle 73 ENC Get Mechanical Angle 73 ENC ResetEncoder 74 ENC Clear Speed Buffer 74 ENC Get Speed i 4 Boe Go 4 o sas oe ew 44 ENC Get Average Speed 75 TIMx UP IRQHandler interrupt routine 2000 eee eee 75 Tachogenerator feedback processing 75x_tacho c module 76 4 7 1 List of available functions and interrupt service routines 76 TAC TachoTimerIndt g r 2 9 8 wow oov 9 9 cw 09 6 o0 y ww YO TAC InitTachoMeasure 2 2 s 77 TAC GetRotorFE eqInHz e osis a ode ok So ood E o8 OR Ws oe de c uw P TAC GetROLOIEEXGQ GS ae as o cox e oye Oe ow de oU d e RS 8 GetLastTachoPeriod s s 78 GetAvrgTachoPeriod 78 TAC TST3m dOUt sce ed m A woo Cm Ge e Gu dC um Eo ues cg PD TAC ClrTImeO t e moie xg x GEnGE ex aa XR IE WE GE a TO TAC GetCaptCOou nter 6 2 x o wo ow o ek ee Soe o wx d ov TO TAG ClrCaptCOuntef 4 ow G5 ow 2s
90. rithm execution rate Up to 11 4kHz 100 12 2kHz 99 5 Equal to PWM frequency 12 9kHz 99 13 7kHz 98 5 14 4kHz 98 15 2kHz 97 5 Equal to PWM frequency 2 16kHz 97 REP_RATE 3 16 7kHz 96 596 17 5kHz 96 Fixed point numerical representation The AC IM IFOC software library uses fixed point representation of fractional signed values Thus a number nis expressed as n m f where mis the integer part magnitude and fthe fractional part and both m and fhave fixed numbers of digits In terms of two s complement binary representation if a variable n requires Ql bits to express as powers of two its magnitude of which 1 bit is needed for the sign QF bits as inverse powers of two for its fractional part then we have to allocate QI QF bits for that variable Therefore given a choice of QI and QF the variable representation has the following features e Range 2 Ql 1 lt n lt 2 Ql 1 _ 2CGF e Resolution 1 20 The equation below converts a fractional quantity q to fixed point representation n n floor q 20r A common way to express the choice that has been made is the q QI QF notation So if a variable is stored in q3 5 format it means that 3 bits are reserved for the magnitude 5 bits for the resolution the expressible range is from 4 to 3 96875 the resolution is 0 03125 the bit weighting is bit n 7 6 5 4 3 2 1 0 value 4 2 1 we m we ine 1182
91. rk on page 67 e Hev Park Circle Limitation on page 68 Synopsis Curr Components Clarke Curr Components Curr Input Description This function transforms stator currents ig and ips which are directed along axes each displaced by 120 degrees into currents ig and ig in a stationary qd reference frame q d axes are directed along paths orthogonal to each other See Section 4 5 3 for the details Input Stator currents ias and ips in q1 15 format as members of the variable Curr Input which is a structure of type Curr Components Returns Stator currents i and ig in q1 15 format as members of a structure of type Curr Components Functions called mul q15 q15 q31 UM0324 Library functions Park Rev_Park Synopsis Description Input Returns Functions called Synopsis Description Input Returns Functions called Curr Components Park Curr Components Curr Input s16 Theta The purpose of this function is to transform stator currents i and ig which belong to a stationary qd reference frame to a rotor flux synchronous reference frame properly oriented so as to obtain igg and igg See Section 4 5 3 for details Stator currents i and ig in q1 15 format as members of the variable Curr_Input which is a structure of type Curr_Components rotor flux angle 05 65536 pulses per revolution Stator currents ig and igs in q1 15 format as members of a structure of type Curr Components mul q15 q1
92. roduction programmers can be obtained from third parties 11 105 Getting started with tools UM0324 1 3 1 3 1 Note 1 3 2 12 105 Library source code Download The complete source files are available for free download on the ST website www stmcu com in the Technical Literature and Support Files section as a zip file It is highly recommended to check for the latest releases of the library before starting any new development and thento verify from time to time all release notes to be aware of any new features that might be of interest for your project Registration mechanisms are available on ST web sites to automatically obtain updates File structure The AC IM IFOC software library contains the workspace for the IAR toolchain Once the files are unzipped the following library structure appears as shown in Figure 2 Figure 2 File structure STR750 FOC Firmware Libraries v1 0 StdLib FOC_PMSM_SR_v1 0 oe FOC_AC_SR_v1 0 IAR debug release config settings Include Source The STR750 FOC Firmware Libraries v1 0 folder contains the firmware libraries for running both PMSM and AC induction three phase sensored motors The StdLib folder contains the standard library for the STR750 The Include and Source folder contain respectively the header and source files of the motor control library Finally IAR folder contains the configuration files for the EWARM toolcha
93. rotor flux reference in proportion to the inverse of the rotor speed q In this approach if maximum inverter modulation index is required when attaining rated speed and rated power then the voltage margin enough to regulate current beyond that point is not available this is caused by increased voltage drop across the stator leakage inductance That s why when 1 method is implemented the inverter voltage is generally limited at 9596 of its means The AC IM IFOC software library however makes use of a maximum torque capability scheme 2 which aims to exploit the system resources completely In both cases DC bus voltage limitation Vpcmay inverter current rating and motor thermal rating usually in order to provide better dynamic response the inverter current rating is higher than that of the machine must be considered and a precise knowledge of motor parameters such as magnetizing inductance Lm rotor leakage inductance Lir rotor resistance r is required 63 105 Library functions UM0324 64 105 There are two different field weakening operation regions see Figure 39 e the constant power region where rotor flux is decreased inversely with the speed considering the influence of the voltage drop across Lis while slip frequency increases until breakdown value e the constant power speed region where rotor flux is decreased but keeping the slip frequency fixed at breakdown value Figure 39 Torque vs
94. ry segments on an external memory UM0324 Getting started with tools 4 Figure 5 Extended linker file setting Options for node IFOC Category General Options C C Compiler Assembler Custom Build Build Actions Debugger Simulator Angel IAR ROM monitor J LinkAJ Trace Macraigor RDI Third Party Driver Factory Settings Output Extra Output define Diagnostics Lit Config Proce gt m Linker command file IV Overide default sPROJ_DIRS config inkam fiash xc E Command file configuration tool Override default program entry Entry label C Defined by application Search paths one per line poem Raw binary image l E Symbol Segment Align ee ee TF 15 105 Getting started with the library UM0324 2 2 1 16 105 Getting started with the library Introduction to AC induction motor FOC drive The AC IM IFOC software library is designed to achieve the high dynamic performance in AC motor control offered by the field oriented control FOC strategy Through complex machine electrical quantity transformations this well established drive system optimizes the control of the motor to the extent that it is able to offer decoupled torque Ta and magnetic flux A regulation That is it offers the same optimum and favorable conditions as DC motors but in this case carried out with rugged and powerful A
95. s x T LOFP64 10x10 H LFBGA64 H LFBGA100 Inkarm xxx xcl file internal external flash or RAM based project The IAR config folder contains 3 files e Inkarm flash xcl e Inkarm smi xcl e Inkarm ram xcl These files are used as an extended command linker file and contain linker options Memory areas start address size and other parameters are declared here It also contains the value assigned to the stack size for each ARM operating mode for example USER or FIQ Refer to the ARM7TDMI S Technical Reference Manual for more information 13 105 Getting started with tools UM0324 1 4 2 14 105 The default extended linker file used in the standard library to configure the device for internal flash based resident firmware is Inkarm flash xcl an extract of this file showing the definitions of heap and stack size is provided below Depending on the project requirements it may be necessary to manually edit the segment sizes f kk e ke ke kc se e Se ke e ke e RARE RR RRA e ck che ke he e kk e ke RE RAR RAR hc KEE EERE ERE k k k k RR kk kk k kk k k Stack and heap segments f Rhe kkk kkk kkk he he k he he kkk kk k k k k k ke he k he e KEKE k k k k k k k k k k k k k k k RARE RARE RAR ko kk k k k k k Add size gt 0 for ABT Stack UND Stack if you need them size must be 8 byte aligned D CSTACK SIZE 0x200 D SVC STACK SIZE 0x20 D IRQ STACK SIZE 0x100 D FIQ STACK SIZE 0x40 D ABT STACK S
96. s must be defined in all cases define ROTOR TIME CONSTANT Define here in us the rotor open circuit time constant of the motor t L Lp L UM r where L is the magnetizing inductance Lis the rotor leakage inductance L is the rotor inductance r is the rotor resistance define POLEPAIR_NUMBER Define here the stator winding pole pair number define RATED_FREQ Define here in 0 1Hz the right hand boundary of the constant torque region see Figure 8 in that region we have rated current rated flux rated torque rated power hNominal_Flux Define here the required magnetizing current im positive peak value expressed in q1 15 format see Section A 3 on page 99 23 105 Getting started with the library UM0324 Note 2 3 24 105 Figure 8 Torque vs speed characteristic curve 1 2 Constant Torque regioni Constant Power region Constant Power Speed j region 0 4 Torque Per Unit eo o 0 2 0 q AAA gt gt gt gt z gt 7y zz Tyg gt j gt TyzTyT77y7T TT7T7TT HTA N N gt SS SAP AP AP gh ESE Speed Per Unit The following parameters are required only to enter the field weakening operation constant power region begins beyond the RATED_FREQ boundary mentioned above e hFlux_Reference this look up table 256 signed 16 bit values provides reference
97. se of the time varying mutual inductances between stator and rotor circuits By making a change of variables that refers stator and rotor quantities to a frame of reference rotating at any angular velocity it is possible to reduce the complexity of these equations This strategy is often referred to as the Reference Frame theory 1 Supposing fax fbx fox are three phase instantaneous quantities directed along axis each displaced by 120 degrees where x can be replaced with s or r to treat stator or rotor quantities see Figure 41 supposing fax fax fox are their transformations directed along paths orthogonal to each other the equations of transformation to a reference frame rotating at an arbitrary angular velocity can be expressed as cos cos 9 2 cos 0477 jf f i gt r fax fa Z Sin sin poe sin di 3 3 Sox 1 1 1 rm 2 2 5 where 0 is the angular displacement of the q d reference frame at the time of observation and 0g that displacement at t 0 see Figure 41 UM0324 Library functions Figure 41 Transformation from an abc stationary frame to a qd rotating frame With Clark s transformation stator currents ias and ips which are directed along axes each displaced by 120 degrees are resolved into currents ia and ib on a stationary qd reference frame Appropriate substitution into the general equations given above yields po b FL pe V3 In Park s change of variables sta
98. sed Loop with the possibility of varying different parameters on the fly The default configuration allows the use of three shunt resistor for stator current reading and tacho generator for speed feedback Refer to Section 3 3 on page 30 for setting up the system when using ICS and to Section 3 4 on page 32 if using quadrature incremental encoder After the MCU initialization phase a welcome message appears and shortly after the main window is displayed Use the joystick and the button labelled KEY to navigate between the menus Key assignments are shown in Figure 10 Figure 10 Key function assignments DATA a FUNCTION 4 e FUNCTION e b d Ob 2 x ENTER KEY connected to PB3 DATA A simple state machine handles the motor control tasks in the main loop as well as basic monitoring of the power stage This state machine does not differentiate open from closed loop control It is described in Figure 11 The power stage is monitored using the ADC peripheral and the PWM peripheral Emergency Stop ES input to watch the following conditions e Heatsink over temperature ADC channel AIN6 and ES input e DC bus over voltage on ADC channel AIN7 e Over current protection ES input Any of these three conditions will cause the PWM to be stopped and the state machine to go into FAULT state for 2 seconds before coming back to IDLE state Depending on the source of the fault an error message is also
99. selection Speed 0000 0 Hz Motor running no access Ref 0015Hz 0000 0 Hz PID motor speed target selection Current speed in Hz S 0000 0 G 0000 9 PID motor speed integral gain Ki 400 Kd 07400 selection S 0000 0 Ki 02000 Kp 05400 Kd 07400 Mri pn PID motor speed proportional gain Kp S 0000 0 Ki 02000 PID motor speed derivative gain Kd Kp 05400 Kd 07400 ctn Iq 02000 00000 PID flux torque regulator target and Id 00000 00000 measured flux torque visualization Switching from open to closed loop operation and vice versa is done by moving the joystick up or down while the first menu shown in the above figure is displayed and motor is stopped In closed loop operation you can vary the target speed by moving the joystick up or down while the PID motor speed target selection menu is displayed The demo program also allows real time tuning of the speed PID regulator coefficients Finally although you cannot act directly on torque and flux references you can also observe both the target and measured flux and torque stator current component In fact in closed loop both flux and torque references are the outputs of speed PID regulator and field weakening blocks As in open loop pressing the joystick or the KEY button will start the motor The closed loop ramp up strategy is shown in Figure 15 Basically a linear torque ramp is applied to the motor until it reaches speed TACHO SPEED VAL if a tacho speed sensor is
100. speed characteristic curve Torque characteristic Constant Torque regioni Constant Power region o 00 Constant Power Speed region T T T T T T T T THT T T T T T T T T T T T T T T T T T T T T T TT T T 111 Td N N N Speed Per Unit Torque Per Unit o o o e in 0 In order to help you select the most suitable values of flux reference and torque saturation as needed by the CalcRotFIxSlipFreq function a spreadsheet is available to be filled out with the following system parameters e Mains AC voltage rms Volt cell B1 Volt e motor rated current peak amplitude cell B2 Ampere as said before this data is to be matched with inverter current rating motor rated magnetizing current peak amplitude cell B3 Ampere magnetizing inductance Lm cell B4 Henry leakage inductance Lj Lir cell B5 Henry stator resistance rs cell B6 Ohm rotor resistance r cell B7 Ohm maximum measurable current Imax peak amplitude cell BB Ampere UMO324 Library functions As a result of data processing the following information can be obtained e highest frequency of constant torque region i e the maximum allowable frequency before entering field weakening content of cell B13 should be inserted as parameter RATED FREQ in MC_ACMotor_Prm h see Section 2 2 5 e reference values of igs in q1 15 format ac
101. start up or decreasing during motor stop e define MAX RATIO Maximum possible TIMER clock prescaler ratio This defines the lowest speed that can be measured when counter OxFFFF It also prevents the clock prescaler from decreasing excessively when the motor is stopped This prescaler is automatically adjusted during each and every capture interrupt to optimize the timing resolution O define MAX OVERFLOWS This is the maximum number of consecutive timer overflows taken into account It is set by default to 10 if the timer overflows more than 10 times meaning that the tacho 22 105 ky UM0324 Getting started with the library 2 2 5 period has been increased by a factor of 10 at least the number of overflows is not counted anymore This usually indicates that information is lost tacho time out or that the speed is decreasing very sharply The corresponding duration depends on the tacho timer prescaler which is variable the higher the prescaler at low speed the longer the time out period define SPEED FIFO SIZE This is the length of the sofware FIFO in which the latest speed measurements are stored This stack is necessary to compute rolling averages on several consecutive data AC induction motor parameters MC_ACmotor_param h The MC ACmotor param h header file holds motor parameters which are essential to properly operate the IFOC vector drive The following parameter
102. t capture update event Figure 44 Automatic tacho timer prescaler increase Capture Capture Capture E Capture 4 OxFFFF ovf UN ovf Timer overflowed the i i prescaler is increased 0x5500 are A ear T 2 AAA S A 0x0000 Prescaler preload 30 31 i 31 Prescaler active lt 30 Transfer from preload to active on next capture update event Figure 44 shows that the prescaler is not decreased although the captured value is below 0x5500 due to an overflow interrupt ky UM0324 Library functions 4 7 4 4 8 4 8 1 4 8 2 PID_Init Converting Hertz into pseudo frequency From the definition of frequency 1Hz is equal to 2x rad s it is easy to define a pseudo frequency format so that the rotor angular position can be easily determined by accumulating the rotor speed information every time the control loop is executed for example during PWM update interrupt service routine Providing that 2x OxFFFF so that angle roll overs do not need to be managed the frequency with 0 1Hz unit can easily be converted into pseudo frequency using the following fomula OxFFFF F F x pseudo 0 1Hz 10x Fawn Flux torque and speed regulators MC PID regulators module Overview The MC PID regulators module contains all the functions required for implementing the necessary PID regulators for controllin
103. than DT Ty Tg and that ADutya p lt DT TrigetTs In this case it is not possible to perform the current reading on Phase B see Figure 34 so the PWM patterns are slightly modified to relapse in the case shown in Figure 33 Because this PWM pattern modification produces a distortion on the phase currents it is better to limit the scope of the modification by limiting the modulation index depending on the selected PWM frequency Specifically this can be done with the following default values DT 0 7us Ty 2 55ys Ts 1 6us Ty 2 67us TDMA 0 7us TRise 2 6us 50 105 ky UMO324 Library functions Figure 34 Low side duty cycle Phase A lt DT Ty Tg and ADutya g lt DT TrisetTs i ADuty s I T Low side Phase A 1M ee ee X Po High side Phase A i Low side Phase B A l i i High side Phase B i Ieo Eu ttn oe Current feedback 1 i of Phase B Los i Phase C conversion i Current feedback kn 3 urrent feedbac Ta Th i ee of Phase C BW I rr iw PHASE B NOT ACCESSIBLE The maximum applicable duty cycles are listed in Table 2 as a function of the PWM frequency Table 2 PWM frequency vs maximum duty cycle relationship PWM frequency Max duty cycle Max modulation index MMI Up to 11 4kHz 100 100 12 2kHz 99 5 99 12 9kHz 99 98 13 7kHz 98 596 97 14 4kHz 98 96 15 2kHz 97 5 95 16kHz 97 94 16 7kHz 96 596 93 17 5kHz 96 92 Note
104. tion 3 Running the demo program on page 26 Input None Returns None Functions called IFOC_CalcFluxTorqueRef TB ClearFlag If Encoder is used ENC Get Average Speed If Tacho is used TAC_GetRotorFreqinHz Note This is an interrupt routine 4 11 Application layer The application layer is split into several modules mainly for the control of the keys LCD display temperature and bus voltage monitoring and main loop The following is a brief description of these modules main c module Contains the initialization and the main control loop of the overall firmware MC_Keys c module Centralizes all information regarding the keyboard reading Any action on the keyboard is processed in the Keys_process routine MC_Display c module Centralize all information regarding the LCD display management 75x_LCD c module Contains some dedicated routines for the control of the LCD embedded with the starter kit MC_misc c module Contains some dedicated routines for monitoring the temperature of the power stage and the bus voltage 93 105 MISRA compliance UM0324 5 5 1 5 2 5 2 1 94 105 MISRA compliance Based on the The Motor Industry Software Reliability Association s Guidelines for the Use of the C Language in Vehicle Based Software the purpose of this section is to provide a report of any MISRA deviation in the version 1 0 of the library modules Analysis method The software library was checked for
105. tor currents i and ig which belong to a stationary qd reference frame are resolved to a rotor flux synchronous reference frame properly oriented so as to obtain ig and igs Consequently with this choice of reference r thus i 71 sinQ ti cos ij i COSO t i sin On the other hand reverse Park transformation takes back stator voltage v and vq belonging to a rotor flux synchronous rotating frame to a stationary reference frame so as to obtain v and vg Va V SINO v COSA Vg v COS O v sin 69 105 Library functions UM0324 4 5 4 Note 70 105 Circle limitation As discussed above FOC allows to separately control the torque and the flux of a 3 phase permanent magnet motor After the two new values V and V of the stator voltage producing flux and torque components of the stator current have been independently computed by flux and torque PIDs it is necessary to saturate the magnitude of the resulting vector yV before passing them to the SVPWM block The saturation boundary is normally given by the value 816 MAX 32767 which produces the maximum output voltage magnitude corresponding to a duty cycle going from 096 to 100 Nevertheless when using three shunt resistor configuration and depending on PWM frequency it might be necessary to limit the maximum PWM duty cycle to guarantee the proper functioning of the stator currents reading block For this reason th
106. tput is increased This is why this parameter has to be adjusted prior to setting up any coefficient of the PID regulator In order to keep the CPU load as low as possible and as shown in equation 1 in Figure 45 the sampling time is directly part of the integral coefficient thus avoiding an extra multiplication Figure 46 describes the link between the time domain and the discrete system UMO324 Library functions Figure 46 Time domain to discrete PID equations Time domain f t Ko x Errorgys t K x J o Errors s dt Kyx S Errors 0 Discrete f X Kyx Errors Kx DYErrorsys Kgx Error Error domain 0 sampling done at Fs 1 Ts frequency pe kx To K In theory the higher the sampling rate the better the regulation In practice you must keep in mind that e The related CPU load will grow accordingly e For speed regulation there is absolutely no need to have a sampling time lower than the refresh rate of the speed information fed back by the external sensors this becomes especially true when a tacho generator sensor is used while driving the motor at low to medium speed As discussed in Section 2 2 2 on page 19 the speed regulation loop sampling time can be customized by editing the PTD SPEED SAMPLING TIME parameter in the MC Control Param h header file The flux and torque PID regulator sampling rates are given by the relationship 2 PWM FREQ
107. ts This routine returns the mechanical frequency of the rotor To find the electrical speed use the following conversion electrical frequency mechanical frequency number of pole pairs u32 GetLastTachoPeriod void This routine returns the rotor period based on the last tacho capture None Tacho signal period unit is 1 CKTIM period unsigned 32 bit format None This function is private to the 75x tacho c module u32 GetAvrgTachoPeriod void This routine returns returns the rotor period based on the average of the four last tacho captures None Tacho signal period unit is 1 CKTIM period unsigned 32 bit format None This function is private to the 75x tacho c module UM0324 Library functions TAC IsTimedOut Synopsis Description Input Output Functions called Note TAC ClrTimeOut Synopsis Description Input Output Note TAC GetCaptCounter Synopsis Description Input Output Note See also bool TAC_IsTimedOut void This routine indicates to the upper layer software that tacho information has disappeared or that the period of the signal has drastically increased None Boolean TRUE in case of time out None The time out duration depends on tacho timer pre scaler which is variable the time out is higher at low speed The boolean will remain set to TRUE until the TAC_ClrTimeOut is called void TAC ClrTimeOut void This routine clears the flag indicatin
108. ty a g gt DT Ty Ts as shown in the red circle in Figure 28 Phase C conversion is performed between Phase B low side switch on and Phase A high side switch off see Figure 29 Figure 28 DT Ty Ts lt Low side Phase A duty cycle lt DT Ty 2TstTy Tpma and ADuty p gt DT Ty Ts 100 90 80 70 60 50 40 30 20 10 0 60 0 30 PhaseA Phase B Phase C Ti 47 105 Library functions UM0324 48 105 Figure 29 DT Ty Ts lt Low side Phase A duty cycle lt DT Ty 2Tst Ty Tpya and ADuty p gt DT TytTs ADU as 1 E Low side Phase A High side Phase A 1L m Low side Phase B D Current feedback of y Phase B i Current feedback of pr Phase C i Sampling end Case 3 Phase A pulse width lt DT TN TS In this case the duty cycle applied to Phase A is so short that no current sampling can be performed in between the two low side commutations Then if the difference of duty cycles between Phase B and A is long enough to allow two A D conversions to be performed between Phase B low side switch on and Phase A high side switch off the strategy shown in Figure 31 is used Figure 30 Low side duty cycle Phase A lt DT Ty Ts and ADutya B gt DT Ty 2Ts Tu Toma 100 0 30 60 Phase A Phase B Phase C UM0324 Library functions Otherwise if the difference of duty cycles between Phase B and A is long eno
109. ugh to allow only one A D conversion to be performed between Phase B low side switch on and Phase A high side switch off the strategy shown in Figure 33 is used In Figure 33 Trigg represents the time required by the analog voltage on the shunt resistor of a phase signal Current feedback of Phase B to settle after a commutation of the low side switch belonging to the same phase Figure 31 Low side duty cycle Phase A lt DT Ty Tg and ADuty _p gt DT Tyt2Tst Tyt Tpma ADuty amp Low side Phase A High side Phase A di Low side Phase B pu i oo E l Phase B hh High side PhaseB eed E pl a Current feedback 1 of Phase B J PhaselC conversion DM nl Current feedback UR Ts Ta Toha of Phase C NAR y PO Ahn e Sampling end Figure 32 Low side duty cycle Phase A lt DT Ty Tg and DT TRise Ts lt ADutyA p lt DT Tyt2Tst Tyt Tpma 100 90 80 70 60 50 40 30 20 10 0 0 30 60 Phase A PhaseB Phase C 49 105 Library functions UM0324 Figure 33 Low side duty cycle Phase A lt DT Ty Tg and DT TRise Ts lt ADutyA p lt DT Tyt2Ts THt T pa es Ta T Current feedback po of Phase B a i y Phase C Current feedback 77 of Phase C RR Ne NIS Y A Finally when a high modulation index gt 9296 and high frequency gt 11kHz PWM signal is generated it could happen that both Phase A pulse width is lower
110. unctions UM0324 Figure 38 Torque and flux optimization block IFOC Drive Speed Reference wm profile generator IFOC Model Flux A optimization SPEED READING L actual rotor speed wr CalcIm Synopsis s16 Calclm s16 hld input Description The purpose of this routine is to supply to the calling function the estimated value of the rotor flux as a response to variations of the input current value ms see uncompensated flux response controller block in Figure 36 and Figure 37 See Section 4 4 3 for in depth information about the computations implemented Input Stator current ig in q1 15 format Returns Magnetizing current im defined as rotor flux A divided by magnetizing inductance L in q1 15 format Functions called mul qi5 g15 q31 MC qmath h 60 105 ky UM0324 Library functions CalcRotFlxSlipFreq Synopsis s32 CalcRotFIxSlipFreq s16 hlq input s16 hlm input Description This function estimates the rotor flux slip frequency e central POI in Figure 36 and Figure 37 as result of currents i and im Agr IL m See Section 4 4 3 for an in depth comprehension of the implemented computations Input Stator current d and magnetizing current im both in q1 15 format Returns Rotor flux slip frequency expressed in pulses per PWM period 65536 65536 pulses 2n radiants Functions called mul q15 q15 q31 div q31 q15 q15 MC qmath h
111. uxTYPDEF see MC type h for structure declaration signed 16 bits Signed 16 bits None Default values for the PID flux regulation are declared and can be modified in the MC Control Param h file see Section 2 2 2 on page 19 Figure 53 on page 102 shows the PID block diagram s16 PID Torque regulator PID TorqueTYPEDEF PID Torque s16 glq input The purpose of this function is to compute the proportional integral and derivative terms if enabled see ld Iq DIFFERENTIAL TERM ENABLED in Section 2 2 1 on page 18 for the torque regulation PID TorqueTYPDEF see MC type h for structure declaration signed 16 bits signed 16 bits None Default values for the PID torque regulation are declared and can be modified in the MC Control Param h file see Section 2 2 2 on page 19 Figure 53 on page 102 shows the PID block diagram UMO324 Library functions PID Speed Regulator Synopsis s16 PID Speed regulator PID SpeedTYPEDEF PID Speed s16 speed Description The purpose of this function is to compute the proportional integral and derivative terms if enabled see SPEED DIFFERENTIAL TERM ENABLED in Section 2 2 1 on page 18 for the speed regulation Input PID SpeedTYPDEF see MC type h for structure declaration signed 16 bits Output signed 16 bits Functions called None Caution Default values for the PID speed regulation are declared and can be modified in the MC Control Param h file see Section 2 2 2 on page 19
112. validated using the main hardware boards included in STR750 MCKIT starter kit a complete inverter and control board The STR750 MCKIT starter kit provides an ideal toolset for starting a project and using the library Therefore for rapid implementation and evaluation of the software described in this user manual it is recommended to acquire this starter kit It is also recommended to install the IAR EWARM C toolchain which was used to compile the AC IM IFOC software library With this toolchain you do not need to configure your workspace You can set up your workspace manually for any other toolchain A free kickstart edition of the IAR EWARM C toolchain with a 32Kb limitation can be downloaded from www iar com it is sufficient to compile and evaluate the software library presented here Software tools A complete software package consists of eA third party integrated development environment IDE eA third party C compiler This library was compiled using the third pary IAR C toolchain e JTAG interface for debugging and programming Using the JTAG interface of the MCU you can enter in circuit debugging session with most of toolchains Each toolchain can be provided with an interface connected between the PC and the target application Figure 1 JTAG interface for debugging and programming JTAG JTAG IDE STR750 Application board The JTAG interface can also be used for in circuit programming of the MCU Other p
113. ve equations while keeping an adequate resolution the value MMI S16_MAX IV is computed and stored in a look up table for different values of V Furthermore considering that MMI depends on the selected PWM frequency a look up table is stored in MC Clarke Park h with MMI ranging from 92 to 100 Once you have selected the required PWM switching frequency you should uncomment the Max Modulation Index definition corresponding to the selected PWM frequency in the MC Control Param h definitions list shown below define MAX MODULATION 100 PER CENT 100 max modulation index define MAX MODULATION 99 PER CENT 99 max modulation index define MAX MODULATION 98 PER CENT 98 max modulation index define MAX MODULATION 97 PER CENT 97 max modulation index define MAX MODULATION 96 PER CENT 96 max modulation index define MAX MODULATION 95 PER CENT 95 max modulation index define MAX MODULATION 94 PER CENT 94 max modulation index define MAX MODULATION 93 PER CENT 93 max modulation index define MAX MODULATION 92 PER CENT 92 max modulation index 71 105 Library functions UMO324 For information on selecting the PWM switching frequency you will find advice in Section A 2 on page 98 To determine the max modulation index corresponding to the PWM switching frequency refer to Table 2 on page 51 4
114. y stator currents reading and IFOC algorithm execution when REP_RATE 3 PWM counter PWM Period IFOC algorithm IFOC algorithm execution execution TIMO countera E seta t gt Note Because three shunt resistor topology requires low side switches to be on when performing current reading A D conversions the REP_RATE parameter must be an odd number in this case Considering that the raw IFOC algorithm execution time is about 27 5us when in three shunt resistor stator current reading configuration the related contribution to CPU load can be computed as follows CPULoad Frm __ 975 10 100 Few 27 5 10 100 Refresh_Rate REP RATE 1 2 ky 97 105 Additional information UM0324 A 2 Note 98 105 Selecting PWM frequency for 3 shunt resistor configuration Beyond the well known trade off between acoustical noise and power dissipation consideration should be given to selecting the PWM switching frequency using the AC IM IFOC software library As discussed in Section 4 2 5 on page 43 depending on the PWM switching frequency a limitation on the maximum applicable duty cycle could occur if using three shunt resistor configuration for current reading Table 2 PWM frequency vs maximum duty cycle relationship on page 51 summarizes the performance of the system when the software library is used in conjunction with STR750 MCKIT hardware The MB459 board is an eva

Download Pdf Manuals

image

Related Search

Related Contents

Courrierde l`Éducation nationale A04  User`s Guide  GT05 Protective Cover for Oil User`s Manual  DNA結合キット  - Il Portale del Sole    Manual de Servicio Polipasto - R&M Materials Handling equipment  Tiva C Series TM4C123G LaunchPad Evaluation Kit User`s Manual  Manual de instalação  

Copyright © All rights reserved.
Failed to retrieve file