AN204469 FM3 Family 3-Phase PMSM FOC Control Associated Part Family: FM0+ / FM3 / FM4 Series This application note describes the FOC control of a 3-phase PMSM which includes, the structure of a 3-phase PMSM and motor driving principle, FOC control system, Core modules and Mathematical model of a 3-phase PMSM. Contents 1 2 3 Introduction .................................................................. 1 1.1 Purpose .............................................................. 1 1.2 Definitions, Acronyms and Abbreviations ............ 1 1.3 Document Overview ............................................ 1 Structure of a 3-Phase PMSM and Motor Driving Principle.......................................... 2 2.1 Motor Category ................................................... 2 2.2 Structure of a 3-Phase PMSM ............................ 2 2.3 Driving principle of 3-Phase PMSM .................... 3 FOC Control ................................................................ 5 1 Introduction 1.1 Purpose 4 Core Modules .............................................................. 7 4.1 Coordinate Transformation ................................. 7 4.2 PI Regulator ........................................................ 9 4.3 SVPWM ............................................................ 10 4.4 Sensor-less Position Observer ......................... 16 5 Mathematical Model of a 3-Phase PMSM ................. 17 6 Additional Information ................................................ 17 Document History............................................................ 18 This document describes the FOC control of a 3-phase PMSM. The following contents are included: 1.2 1.3 The structure of a 3-phase PMSM and motor driving principle FOC control system Core modules Mathematical model of a 3-phase PMSM Definitions, Acronyms and Abbreviations PMSM Permanent Magnetic Synchronous Motor SVPWM Space Vector Pulse Width Modulation FOC Field Oriented Control Document Overview The rest of document is organized as the following: Section 1 explains Introduction. Section 2 explains Structure of a 3-Phase PMSM and Motor Driving Principle. Section 3 explains FOC Control. Section 4 explains Core Modules. Section 5 explains Mathematical Model of a 3-Phase PMSM. Section 6 explains Additional Information. www.cypress.com Document No. 002-04469 Rev. *A 1 FM3 Family 3-Phase PMSM FOC Control 2 Structure of a 3-Phase PMSM and Motor Driving Principle 2.1 Motor Category Synchronous motors can be divided into several different types. The figure below shows a simple classification tree of electric motors. In this document, the FOC control of 3-phase PMSM is to be introduced, which is highlighted with the green color in below figure. Figure 1. Motor Category 2.2 Structure of a 3-Phase PMSM A 3-phase PMSM is mainly composed of two parts: the stator and the rotor. At stator side, the 3-phase windings are coiled on the stator core. The windings of 3 phases are separately placed by the rule of 120 degrees angle to generate a round rotating magnetic field (Fs) when a 3-phase AC current goes through the 3-phase windings. The separated 3-phase winding placed by the rule of 120 degrees angle is named as 3-phase symmetric winding. At rotor side, one or more pairs of permanent magnetic poles are mounted to offer a constant rotor magnetic field (Fr). Figure 2. Structure of a 3-phase PMSM www.cypress.com Document No. 002-04469 Rev.*A 2 FM3 Family 3-Phase PMSM FOC Control Because Fs is a rotating magnetic field, the Fr will be dragged and follow the Fs. If the Fr cannot catch up with Fs, the rotor will rotate continuously. If the 3-phase current in 3-phase windings disappears, the Fs will disappear at the same time, and the rotor will stop. 2.3 Driving principle of 3-Phase PMSM To keep rotor rotating, a continuous rotating stator magnetic field is necessary. Assume the 3-phase AC current can be expressed as: ° ° The 3-phase AC current goes through stator 3-phase winding, so three magnetic fields are created. By the formula of F , the three magnetic fields can be expressed as: Figure 3. Stator Magnetic Field of A 3-phase PMSM FC FB FA ° ° By observing the synthesis magnetic F in different timing modes, which is combined by understand the rotating principle of stator magnetic field. 1. , it is easy to ° Figure 4. Stator Magnetic Field of a 3-Phase PMSM When ° FC F FB www.cypress.com Document No. 002-04469 Rev.*A 3 FM3 Family 3-Phase PMSM FOC Control 2. ° Figure 5. Stator Magnetic Field of a 3-Phase PMSM When ° FB F 3. FA ° Figure 6. Stator Magnetic Field of a 3-Phase PMSM When FB ° FC FA F www.cypress.com Document No. 002-04469 Rev.*A 4 FM3 Family 3-Phase PMSM FOC Control From the synthetic magnetic field F in different timing modes, it is obviously known that F is a rotating vector and furthermore the magnitude of F is a constant . Now we can get a conclusion that a round rotating magnetic field is created if a 3-phase AC current goes through a 3-phase symmetric winding. 3 FOC Control 3.1.1 FOC Principle Brush DC motor is the conventional DC motor with a long history. A big advantage of the brush DC motor is that its torque control and magnetizing control are decoupled, which makes brush DC motor easy to control. The brush DC motor decoupled control is shown in below figure. Figure 7. Brush DC Motor Decoupled Control The magnetizing is controlled by magnetizing current ( ), and the torque is controlled by torque current ( ). The direction of the magnetizing magnetic field is parallel with d-axis (vertical direction), and the direction of the torque magnetic field is parallel with q-axis (horizontal direction). So these two magnetic fields do not influence each other. That is to say, it is decoupled between the 2 magnetic fields and motor’s magnetizing and torque can be adjusted individually. For example, the torque control formula is , which means torque is only controlled by torque current . The condition of PMSM motor control is much more complex than a brush DC motor. The magnetic field of a 3phase symmetry winding is a coupled magnetic field. We can discover the complex coupled relationship from the torque control formula. www.cypress.com Document No. 002-04469 Rev.*A 5 FM3 Family 3-Phase PMSM FOC Control Figure 8. The Coupled Magnetic Flux of A PMSM , From the expression of Te, it is easy to understand that the torque is determined by all 3-phase inductances (including self-inductance and mutual-inductance) and currents. Obviously, the torque control seems much more complex than a brush DC motor. Coordinate transformation is just the way to simplify the PMSM torque control. By coordinate transformation, a PMSM control model is converted from A-B-C coordinate to d-q coordinate. The torque control formula is also converted into d-q coordinate, the formula is: The simple formula in d-q coordinate makes the PMSM torque control as easy as a brush DC motor. 3.1.2 FOC Control Structure From the description above, the FOC core thinking is to make the torque control of PMSM as easy as a DC brush motor by a motor rotor magnetic field orientation technology. In the technology, the coordinate transformation method turns the motor module from the u-v-w coordinate to the rotational d-q coordinate, and the d-q coordinate rotational speed is the same as the stator magnetic field rotational speed. Then the control of a PMSM is simplified and the control performance is almost same as a DC brush motor. Some PID regulators are added to adjust the motor output following the given input. By setting different PID parameters, system gets different dynamic and static performance. SVPWM technology is applied to accept the driving voltage in α-β coordinate and output a set of switching instruction to control the 6 switches in full bridge inverter. Position and speed estimator is designed to observe the real time motor speed through the motor driving voltage and current. The estimated motor speed is compared with the expected speed, and the comparison result serves as the input of the speed PI regulator. The estimated rotor position angle is used by the coordinate transformation unit. www.cypress.com Document No. 002-04469 Rev.*A 6 FM3 Family 3-Phase PMSM FOC Control Figure 9. FOC Control Diagram ωre + - f Iqref + PI Park-1 Vq - Vα d,q PI ThreePhase Bridge SVPWM Idref + PI Vd Vβ α,β - A C Iq Isα d,q Id Isβ α,β Park θestim ωm Position and speed Estimator Isβ Isα Vβ Vα α,β a,b,c B Ib Ic Clark e R Software 4 Core Modules 4.1 Coordinate Transformation Hardware The coordinate transformation includes Clark transformation and Park transformation. On the contrary, the inverse coordinate transformation includes inverse Clark transformation and inverse Park transformation. 1. Clark transformation It changes a quantity in A-B-C coordinate to α-β coordinate. 2. Park transformation It changes a quantity in α-β coordinate to d-q coordinate. www.cypress.com Document No. 002-04469 Rev.*A 7 FM3 Family 3-Phase PMSM FOC Control 3. Inverse Clark transformation It changes a quantity in α-β coordinate to A-B-C coordinate. 4. Inverse Park transformation It changes a quantity in d-q coordinate to α-β coordinate. The following figures show the progress of coordinate transformation. Figure 10. Coordinate Transformation Clark Inverse Clark 1. FABC , F , Fdq -- Synthesis magnetic field 2. s1 , , dqs -- Magnetic field rotating speed 3. s1 Park www.cypress.com dqs Inverse Park Document No. 002-04469 Rev.*A 8 FM3 Family 3-Phase PMSM FOC Control 4.2 PI Regulator 4.2.1 Introduction The PI regulator is composed of a proportional regulator and an international regulator, which mainly has two functions: 1. To assure a fast response when the input is changed; 2. To assure the output follows the given input. The PI regulator keeps the output follow the expected output by a comparing error between the expected output and the real output. The P-value is to make a fast output response to the comparing error, and the I-value is to decrease the stable output error. Its transfer function can be expressed as follows. Figure 11. PI-regulator Transfer Function expected output PI regulator causes a fluctuating output, fluctuating amplitude is decreasing. After some regulating periods, the output follows the expected output with a very small fluctuation around the expected output value. Figure 12. Output of PI Regulator expected output www.cypress.com Document No. 002-04469 Rev.*A 9 FM3 Family 3-Phase PMSM FOC Control 4.2.2 Formula The mathematic formula of PI regulator is: Usually the formula can be changed to the discrete field and expressed by the incremental algorithm. Generally, an output limitation is defined to limit the output into a legal range. Figure 13. PI Regulator with Output Limitation expected output 4.3 SVPWM 4.3.1 Synthesis of a Space Vector SVPWM is a method to generate a round rotational voltage vector by controlling the status of 6 switches ( ) in the 3-phase full bridge inverter. Figure 14. 3-phase Full Bridge Inverter www.cypress.com Document No. 002-04469 Rev.*A 10 FM3 Family 3-Phase PMSM FOC Control Below figure lists 8 switching statuses (1 – switch is closed, 0 – switch is opened) and the relative voltages. Table 1. Eight Switching Statuses and Voltages Through the Clark transformation, those voltages are equally converted to α-β coordinate. Table 2. Voltages in α-β Coordinate www.cypress.com Document No. 002-04469 Rev.*A 11 FM3 Family 3-Phase PMSM FOC Control Then 6 basic voltage vectors and 2 zero vectors are got. Figure 15. Basic Voltage Vectors V120 (010) 0(111) V180 (011) V240 (001) V60 (110) 0(000) V0 (100) V300 (101) Because motor is driven by a magnetic field created by the 3-phase stator winding, let’s see the relationship between the voltage and the magnetic field. A winding follows below voltage-flux formula. For the motor winding, if the motor rotational speed is not very low, the formula above can be simplified as: So we can get: From the table of ‘voltages in α-β coordinate’, it is easy to know all the basic voltages vectors are constants. So the formula above can become: It means that the stator magnetic field is created by the voltage added in motor stator winding. Furthermore, a longer time of voltage applying on winding causes a bigger magnetic field. In Figure 15, 6 basic voltage vectors divide the space into 6 numbers. It is numbered as follows (Voltage vectors are expressed as magnetic vectors). www.cypress.com Document No. 002-04469 Rev.*A 12 FM3 Family 3-Phase PMSM FOC Control Figure 16. Sector Numbers ψs 120 (010) ψs 60 (110) I V III 0 (111) ψs 180 (011) ψs 0 (100) 0 (000) II IV VI ψ s240 (001) ψs 300 (101) In a control period T, if we divide the T into 3 parts: , a magnetic field can be expressed as: , . Below figure shows the synthesis magnetic vector. Figure 17. Vector Synthesis v60 (110) s 60 v60 t60 O s s 0 v0 t0 v0 (100) In above figure, it shows the synthesis vector in sector III. By the same way, the synthesis magnetic direction in every sector can be composed of the adjacent 2 basic vectors and the zero vectors. www.cypress.com Document No. 002-04469 Rev.*A of any 13 FM3 Family 3-Phase PMSM FOC Control 4.3.2 Basic Vector Conduction Time Assuming the synthesis vector locates in the sector III, the conduction time can be calculated by the following method. Figure 18. Conduction Time of Basic Vectors v60 (110) s 60 v60 t60 s vs T (T t0 t60 tnull ) u s O v0 (100) s 0 v0 t0 us From the table of Eight Switching Statuses and Voltages, It is easy to know the basic vector amplitude is a constant ( v0 v60 2 VDC ). 3 The synthesis vector is composed of and . vs T cos v0 t0 cos 0 v60 t60 cos 60 vs T sin v0 t0 sin 0 v60 t60 sin 60 2 v0 v60 VDC 3 us vs T cos us vs T cos It can be simplified as 3 3 us us t 2 0 2 VDC T t 3us 60 T VDC It means that the conduction time of basic vectors can be calculated from If . , the rest time is filled by the zero vectors. For other sectors, the conduction time of basic vectors can be got similarly. www.cypress.com Document No. 002-04469 Rev.*A 14 FM3 Family 3-Phase PMSM FOC Control The condition time control of basic vectors can be done by the timer in MCU. Generally MCU offers an up-down counter. According to the counting value, we control the full bridge switches to assign the conduction time for each basic vector. Figure 19. Assign the Conduction Time of Basic Vectors by an Up-down Counter FRT is an up-down counter in FMx series MCU. Npwm is FRT’s counting top value. 4.3.3 controls and . OCCP1 is the toggle time. controls and . OCCP3 is the toggle time. controls and . OCCP5 is the toggle time. Sector Number Calculation According to the sector division, the sector number can be judged by the following table. Table 3. Sector Number Calculation Sector Condition I II III IV www.cypress.com Document No. 002-04469 Rev.*A 15 FM3 Family 3-Phase PMSM FOC Control Sector Condition V VI 4.4 Sensor-less Position Observer The estimator has PLL structure. Its operating principle is based on the fact that the d-component of the Back Electromotive Force (BEMF) must be equal to zero at a steady state functioning mode. The block diagram of the estimator is presented in below figure. Figure 20. PLL Estimator’s Block Schematic Park Eα Eβ Ed α,β Eq LPF LPF d, q Edf Sign Eqf + - Integrator θestim ωmR Starting from the closed loop shown in Figure 4-2, the estimated speed (ωmR) of the rotor is integrated in order to obtain the estimated angle, as shown in Equation 4.4-1: Equation 1: The estimated speed, ωmR, is obtained by dividing the q-component of the BEMF value with the voltage constant, ΚΦ, as shown in Equation 4.4-2. Equation 2: Considering the initial estimation premise (the d-axis value of BEMF is zero at steady state) shown in Equation 2, the BEMF q-axis value, Eqf, is corrected using the d-axis BEMF value, Edf, depending on its sign. The BEMF d-q component’s values are filtered with a first order filter, after their calculation with the Park transform, as indicated in Equation 4.4-3. Equation 3: With the fixed stator frame, Equation 4.4-4 represents the stators circuit equations. Equation 4: In Equation 4, the terms containing α – β were obtained from the three-phase system’s corresponding measurements through Clarke transform. Ls and Rs represent the stator inductance and resistance per phase respectively, considering Y (star) connected stator phases. If the motor is Δ (delta) connected, the equivalent Y connection phase resistance and inductance should be calculated and used in the equations above. www.cypress.com Document No. 002-04469 Rev.*A 16 FM3 Family 3-Phase PMSM FOC Control 5 Mathematical Model of a 3-Phase PMSM FOC is a control theory based on coordinate transformation. In the d-q coordinate, the PMSM mathematical model can be described as below. Where, – voltage of d axis – voltage of q axis – current of d axis – current of q axis – inductance of d axis – inductance of q axis – magnetic linkage of d axis – magnetic linkage of q axis – motor stator phase resistor – rotor rotational speed – permanent magnetic linkage of rotor – pole pairs In FOC method, it always keeps status. to zero so that the motor mathematical model can be simplified in the steady From the equation above, the following results can be deduced: 1. The magnetic exciting is independently determined by the permanent magnetic linkage ( 2. Torque is independently determined by the current on q axis ( ); ); So we can adjust only the current on q axis ( ) to control the torque which determines the motor rotational speed. 6 Additional Information For more Information on Cypress semiconductor products, visit the following website: www.cypress.com/cypress-microcontrollers www.cypress.com Document No. 002-04469 Rev.*A 17 FM3 Family 3-Phase PMSM FOC Control Document History Document Title: AN204469 - FM3 Family 3-Phase PMSM FOC Control Document Number: 002-04469 Revision ECN Orig. of Change Submission Date ** — SHEY 02/26/2015 Initial release *A 5232902 SHEY 04/21/2016 Migrated Spansion Application Note from FM3_ AN709-00015-1v0-E to Cypress format www.cypress.com Description of Change Document No. 002-04469 Rev.*A 18 FM3 Family 3-Phase PMSM FOC Control Worldwide Sales and Design Support Cypress maintains a worldwide network of offices, solution centers, manufacturer’s representatives, and distributors. To find the office closest to you, visit us at Cypress Locations. PSoC® Solutions Products ARM® Cortex® Microcontrollers cypress.com/arm PSoC 1 | PSoC 3 | PSoC 4 | PSoC 5LP Automotive cypress.com/automotive Cypress Developer Community Clocks & Buffers cypress.com/clocks Interface cypress.com/interface Lighting & Power Control cypress.com/powerpsoc Memory cypress.com/memory PSoC cypress.com/psoc Touch Sensing cypress.com/touch USB Controllers cypress.com/usb Wireless/RF cypress.com/wireless Forums | Projects | Videos | Blogs | Training | Components Technical Support cypress.com/support PSoC is a registered trademark and PSoC Creator is a trademark of Cypress Semiconductor Corporation. All other trademarks or registered trademarks referenced herein are the property of their respective owners. Cypress Semiconductor 198 Champion Court San Jose, CA 95134-1709 Phone Fax Website : 408-943-2600 : 408-943-4730 : www.cypress.com © Cypress Semiconductor Corporation, 2014-2016. This document is the property of Cypress Semiconductor Corporation and its subsidiaries, including Spansion LLC (“Cypress”). This document, including any software or firmware included or referenced in this document (“Software”), is owned by Cypress under the intellectual property laws and treaties of the United States and other countries worldwide. Cypress reserves all rights under such laws and treaties and does not, except as specifically stated in this paragraph, grant any license under its patents, copyrights, trademarks, or other intellectual property rights. If the Software is not accompanied by a license agreement and you do not otherwise have a written agreement with Cypress governing the use of the Software, then Cypress hereby grants you a personal, non-exclusive, nontransferable license (without the right to sublicense) (1) under its copyright rights in the Software (a) for Software provided in source code form, to modify and reproduce the Software solely for use with Cypress hardware products, only internally within your organization, and (b) to distribute the Software in binary code form externally to end users (either directly or indirectly through resellers and distributors), solely for use on Cypress hardware product units, and (2) under those claims of Cypress’s patents that are infringed by the Software (as provided by Cypress, unmodified) to make, use, distribute, and import the Software solely for use with Cypress hardware products. Any other use, reproduction, modification, translation, or compilation of the Software is prohibited. TO THE EXTENT PERMITTED BY APPLICABLE LAW, CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS DOCUMENT OR ANY SOFTWARE OR ACCOMPANYING HARDWARE, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. To the extent permitted by applicable law, Cypress reserves the right to make changes to this document without further notice. Cypress does not assume any liability arising out of the application or use of any product or circuit described in this document. Any information provided in this document, including any sample design information or programming code, is provided only for reference purposes. It is the responsibility of the user of this document to properly design, program, and test the functionality and safety of any application made of this information and any resulting product. Cypress products are not designed, intended, or authorized for use as critical components in systems designed or intended for the operation of weapons, weapons systems, nuclear installations, life-support devices or systems, other medical devices or systems (including resuscitation equipment and surgical implants), pollution control or hazardous substances management, or other uses where the failure of the device or system could cause personal injury, death, or property damage (“Unintended Uses”). A critical component is any component of a device or system whose failure to perform can be reasonably expected to cause the failure of the device or system, or to affect its safety or effectiveness. Cypress is not liable, in whole or in part, and you shall and hereby do release Cypress from any claim, damage, or other liability arising from or related to all Unintended Uses of Cypress products. You shall indemnify and hold Cypress harmless from and against all claims, costs, damages, and other liabilities, including claims for personal injury or death, arising from or related to any Unintended Uses of Cypress products. Cypress, the Cypress logo, Spansion, the Spansion logo, and combinations thereof, PSoC, CapSense, EZ-USB, F-RAM, and Traveo are trademarks or registered trademarks of Cypress in the United States and other countries. For a more complete list of Cypress trademarks, visit cypress.com. Other names and brands may be claimed as property of their respective owners. www.cypress.com Document No. 002-04469 Rev.*A 19