MATH AND MOTOR CONTROL LIBRARY 32-BIT MICROCONTROLLER FM3 Family USER MANUAL Publication Number FM3_AN706-00091-1v0-E Revision 1.0 Issue Date September 19, 2014 U S E R 2 M A N U A L FM3_AN706-00091-1v0-E, September 19, 2014 U S E R M A N U A L Target products This user manual describes all the FM3 series MCUs. September 19, 2014, FM3_AN706-00091-1v0-E 3 U S E R M A N U A L Table of Contents 1. Introduction .............................................................................................................................................. 6 1.1 About Document ............................................................................................................................. 6 1.2 Definitions, Acronyms and Abbreviations ....................................................................................... 6 1.3 Document Overview ....................................................................................................................... 6 2. System Scope .......................................................................................................................................... 7 2.1 Firmware Architecture .................................................................................................................... 7 2.2 Software Environment .................................................................................................................... 8 2.3 Hardware Environment ................................................................................................................... 8 3. Library Module Description .................................................................................................................... 9 3.1 UMOLIB .......................................................................................................................................... 9 3.1.1 UMO_Add32Sat .................................................................................................................. 9 3.1.2 UMO_Sub32Sat ................................................................................................................ 10 3.1.3 UMO_Mul32Sat ................................................................................................................. 10 3.1.4 UMO_Div32Sat ................................................................................................................. 11 3.1.5 UMO_Abs32Sat ................................................................................................................ 12 3.1.6 UMO_Neg32Sat ................................................................................................................ 13 3.1.7 UMO_Rnd32 ..................................................................................................................... 13 3.1.8 UMO_LLS32 ..................................................................................................................... 14 3.1.9 UMO_LRS32 ..................................................................................................................... 14 3.1.10 UMO_ROL32 .................................................................................................................... 15 3.1.11 UMO_ROR32 .................................................................................................................... 16 3.1.12 UMO_Qnm ........................................................................................................................ 16 3.1.13 UMO_Rep32 ..................................................................................................................... 17 3.2 UMFLIB ........................................................................................................................................ 17 3.2.1 UMF_Sin 18 3.2.2 UMF_Cos 18 3.2.3 UMF_Tan 19 3.2.4 UMF_Arcsin ...................................................................................................................... 20 3.2.5 UMF_Arccos ..................................................................................................................... 20 3.2.6 UMF_Arctan ...................................................................................................................... 21 3.2.7 UMF_Sqrt 22 3.2.8 UMF_Lut1D ....................................................................................................................... 22 3.2.9 UMF_Sign ......................................................................................................................... 24 3.3 BFLIB ........................................................................................................................................... 25 3.3.1 BF_Lmt 25 3.3.2 BF_Hyst 26 3.3.3 BF_Ramp 27 3.3.4 BF_Intg 28 3.4 UDFLIB ......................................................................................................................................... 29 3.4.1 UDF_FilterAvg ................................................................................................................... 29 3.4.2 UDF_AvgFilter_Slide ......................................................................................................... 29 3.4.3 UDF_Filter1stOrd .............................................................................................................. 31 3.5 BMCLIB ........................................................................................................................................ 33 3.5.1 BMC_ClarkeTrans ............................................................................................................. 33 3.5.2 BMC_ParkTrans ................................................................................................................ 33 3.5.3 BMC_ClarkeInvTrans ........................................................................................................ 34 3.5.4 BMC_ParkInvTrans ........................................................................................................... 35 3.5.5 BMC_Pid 36 3.5.6 BMC_SvmCalc .................................................................................................................. 37 3.5.7 BMC_Ovm ......................................................................................................................... 38 3.6 AMCLIB ........................................................................................................................................ 41 4 FM3_AN706-00091-1v0-E, September 19, 2014 U S E R M A N U A L 3.6.1 AMC_PllEstimate .............................................................................................................. 41 3.6.2 AMC_AvgSpdCalc............................................................................................................. 42 3.6.3 AMC_GetDeltaAngleByEncoder_A ................................................................................... 43 3.6.4 AMC_Hall 45 4. Reference Documents ........................................................................................................................... 48 5. Additional Information .......................................................................................................................... 49 6. Appendix ................................................................................................................................................ 50 6.1 Data Type Description .................................................................................................................. 50 6.2 Data Format Description ............................................................................................................... 50 Figures Figure 2-1: Relationship between Each Sub-library ................................................................................... 7 Figure 2-2: Block Diagram for Motor Control Using MMCL ........................................................................ 8 Figure 3-1: Addition with Saturation Diagram ............................................................................................. 9 Figure 3-2: Difference with Saturation Diagram........................................................................................ 10 Figure 3-3: Product with Saturation Diagram ............................................................................................ 11 Figure 3-4: Product with Saturation Diagram ............................................................................................ 11 Figure 3-5: UMO_LLS32 Diagram ............................................................................................................ 14 Figure 3-6: UMO_LRS32 Diagram ........................................................................................................... 15 Figure 3-7: UMO_ROL32 Diagram ........................................................................................................... 15 Figure 3-8: UMO_ROR32 Diagram .......................................................................................................... 16 Figure 3-9: Hysteresis Function Diagram ................................................................................................. 26 Figure 3-10: Signal Ramp Diagram .......................................................................................................... 27 Figure 3-11: Average Sliding Filter Diagram ............................................................................................. 30 Figure 3-12: Overview of under-modulation module................................................................................. 38 Figure 3-13: Overview of New Over-PWM Module................................................................................... 39 Figure 3-14: Overview of AMC_PllEstimate ............................................................................................. 42 Figure 3-15: Overview of AMC_AvgSpdCalc ............................................................................................ 43 Figure 3-16: QPRC Configuration Example ............................................................................................. 45 Figure 3-17: Hall Module Diagram............................................................................................................ 46 Figure 3-18: Correct Angle and Rotor Speed Generated by Hall Edge Interrupt ...................................... 47 Tables Table 2-1: Software Environment ............................................................................................................... 8 Table 2-2: Hardware Environment .............................................................................................................. 8 Table 3-1: Key Variable Lists for SVPWM Calculation Function ............................................................... 37 Table 3-2: Variable Lists for Over-PWM function ...................................................................................... 39 Table 3-3: Variable Lists for Rotor Observer Function .............................................................................. 41 September 19, 2014, FM3_AN706-00091-1v0-E 5 U S E R M A N U A L 1. Introduction 1.1 About Document This user manual describes how to use and implement the library functions provided by the Math and Motor Control Library. The purpose of the Math and Motor control library is to make basic elements of motor control application, such as basic arithmetical operation, general digital filter, basic algorithm etc. Customers all over the world could use these elements to build their motor control system rapidly to shorten their development cycle. The MMCL is based on the SPANSION Cortex-M3 microcontrollers. All modules in the MMCL are described in detail in the following chapters. 1.2 1.3 Definitions, Acronyms and Abbreviations API Application Programming Interface MMCL Math and motor control library UMOLIB Universal Math Operation Library UMFLIB Universal Math Function Library BFLIB Basic Function Library UDFLIB Universal Digital Filter Library BMCLIB Basic Motor Control Library AMCLIB Advanced Motor Control Library Document Overview The rest of document is organized as the following: Chapter 2 explains System Development Environment. Chapter 3 explains Firmware Architecture. Chapter 4 explains Firmware State Machine Chapter 5 explains Firmware Module Description. 6 FM3_AN706-00091-1v0-E, September 19, 2014 U S E R M A N U A L 2. System Scope In the motor control field, the basic element of motor control is also important in addition to different motor control solutions .The math function and motor control library including the basic elements should be built so that global customers could use them to build their motor control system rapidly. 2.1 Firmware Architecture The relationship between each sub library of Math and Motor library is shown in Figure 2-1.The function of each sub library is shown below: UMOLIB - Universal Math Operation Library UMFLIB - Universal Math Function Library BFLIB - Basic Function Library UDFLIB - Universal Digital Filter Library BMCLIB - Basic Motor Control Library AMCLIB - Advanced Motor Control Library BMCLIB UMFLIB AMCLIB BFLIB UDFLIB UMOLIB Figure 2-1: Relationship between Each Sub-library The block diagram of the motor control with the MMCL is shown in Figure 2-2.The basic inverter motor control can be accomplished by this library. September 19, 2014, FM3_AN706-00091-1v0-E 7 U S E R M A N U A L Firmware Motor Basic Startup Protect BMC_Pid ωref PI BMC_ParkInvTrans BMC_Pid Iqref Vq PI Idref d,q Park BMC_Pid 0 Vα Vd PI -1 α,β Vβ Hardware BMC_SvmCalc Ovm_Calc Over -PWM SVPWM 3-Phase Bridge Field weaken Iq Isα d,q α,β BMC_ClarkeTrans θestim Sensor-less Observer ωmR A C B Clarke Park Id Ia α,β Ib Isβ a,b,c BMC_ParkTrans Isβ Isα Vαr M Vβr Hall Capture Hall or QPRC signal QPRC Rotor Position and Speed MMCL Block Other Block Figure 2-2: Block Diagram for Motor Control Using MMCL 2.2 Software Environment Table 2-1: Software Environment Item 2.3 Details Operating System Windows 7 /XP Compiler IAR 6.60 or above Development language C and Assembly Hardware Environment Table 2-2: Hardware Environment Item Spansion inverter demo board Emulator 8 Details General motor control evaluation board: LVPS (Low voltage power supply inverter board) ADPT (FM3) J-link (SWD) FM3_AN706-00091-1v0-E, September 19, 2014 U S E R M A N U A L 3. Library Module Description Each of the modules in the MMCL will be described in detail in this chapter. 3.1 UMOLIB All functions in the Universal Math Operation Library (UMOLIB) are shown below. 3.1.1 Name Description UMO_Add32Sat 32-bit add with saturation UMO_Sub32Sat 32-bit subtraction with saturation UMO_Mul32Sat 32-bit product with saturation (32-bit input / 32-bit output) UMO_Div32Sat 32-bit division with saturation (32-bit input / 32-bit output) UMO_Abs32Sat 32-bit absolute value with saturation UMO_Neg32Sat 32-bit negative value with saturation UMO_Rnd32 32-bit round value UMO_LLS32 32-bit logic shift left UMO_LRS32 32-bit logic shift right UMO_ROL32 32-bit rotational shift left UMO_ROR32 32-bit rotational shift right UMO_Qnm 32-bit Qn format transformation UMO_Rep32 32-bit reciprocal value UMO_Add32Sat This function outputs the sum of 2 numbers. If the sum exceeds the limitation of signed 32-bit value, the output will be limited to the 32-bit boundary value. Output 0x7fffffff Sum of 2 numbers 0x8000000 0 Figure 3-1: Addition with Saturation Diagram Prototype int32_t UMO_Add32Sat(int32_t x, int32_t y); IO Parameters Structure Name I/O Data Type Range Description \ x In signed int 0x80000000~0x7fffffff Number 1 \ y In signed int 0x80000000~0x7fffffff Number 2 Description This function calculates the sum of ‘number 1’ and ‘number 2’. If the sum is within the range of [-2147483648, 2147483647], the function outputs the result directly. Otherwise the limitation value is outputted. −2147483648 𝑥 + 𝑦 < −2147483648 𝑜𝑢𝑡𝑝𝑢𝑡 = { 2147483647 , 𝑥 + 𝑦 > 2147483647 𝑥−𝑦 𝑒𝑙𝑠𝑒 Special Result September 19, 2014, FM3_AN706-00091-1v0-E 9 U S E R M A N U A L NA Use Case int32_t gr; void main(void) { gr = UMO_Add32Sat (0x7ffffff0, 0xff); } 3.1.2 UMO_Sub32Sat This function outputs the difference of 2 numbers. If the difference exceeds the limitation of signed 32-bit value, the output will be limited to the 32-bit boundary value. Output 0x7fffffff Difference of 2 numbers 0x8000000 0 Figure 3-2: Difference with Saturation Diagram Prototype int32_t UMO_Sub32Sat(int32_t x, int32_t y); IO Parameters Structure Name I/O Data Type Range Description \ x In signed int 0x80000000~0x7fffffff Number 1 \ y In signed int 0x80000000~0x7fffffff Number 2 Description This function calculates the difference of ‘number 1’ and ‘number 2’. If the difference is within the range of [-2147483648, 2147483647], the function outputs the result directly. Otherwise the limitation value is outputted. −2147483648 𝑥 − 𝑦 < −2147483648 𝑜𝑢𝑡𝑝𝑢𝑡 = { 2147483647 , 𝑥 − 𝑦 > 2147483647 𝑥−𝑦 𝑒𝑙𝑠𝑒 Special Result NA Use Case int32_t gr; void main(void) { gr = UMO_Sub32Sat (0x7ffffff0, 0xff); } 3.1.3 UMO_Mul32Sat This function outputs the product of 2 numbers. If the product exceeds the limitation of signed 32-bit value, the output will be limited to the 32-bit boundary value. 10 FM3_AN706-00091-1v0-E, September 19, 2014 U S E R M A N U A L Output 0x7fffffff Multiply of 2 numbers 0x8000000 0 Figure 3-3: Product with Saturation Diagram Prototype int32_t UMO_Mul32Sat(int32_t x, int32_t y); IO Parameters Structure Name I/O Data Type Range Description \ x In signed int 0x80000000~0x7fffffff Number 1 \ y In signed int 0x80000000~0x7fffffff Number 2 Description This function calculates the product of ‘number 1’ and ‘number 2’. If the product is within the range of [-2147483648, 2147483647], the function outputs the result directly. Otherwise the limitation value is outputted. −2147483648 𝑥 × 𝑦 < −2147483648 𝑜𝑢𝑡𝑝𝑢𝑡 = { 2147483647 , 𝑥 × 𝑦 > 2147483647 𝑥×𝑦 𝑒𝑙𝑠𝑒 Special Result NA Use Case int32_t gr; void main(void) { gr = UMO_Mul32Sat (0x7ffffff0, 0xff); } 3.1.4 UMO_Div32Sat This function output the division of 2 numbers. If the division exceeds the limitation of signed 32-bit value, the output will be limited to the 32-bit boundary value. Output 0x7fffffff Division of 2 numbers 0x8000000 0 Figure 3-4: Product with Saturation Diagram Prototype int32_t UMO_Div32Sat(int32_t x, int32_t y); September 19, 2014, FM3_AN706-00091-1v0-E 11 U S E R M A N U A L IO Parameters Structure Name I/O Data Type Range Description \ x In signed int 0x80000000~0x7fffffff Number 1 \ y In signed int 0x80000000~0x7fffffff Number 2 Description This function calculates the division of ‘number 1’ and ‘number 2’. If the division is within the range of [-2147483648, 2147483647], the function outputs the result directly. Otherwise the limitation value is outputted. −2147483648 𝑥/𝑦 < −2147483647 𝑜𝑢𝑡𝑝𝑢𝑡 = { 2147483647 , 𝑥/𝑦 > 2147483647 𝑥/𝑦 𝑒𝑙𝑠𝑒 Special Result NA Use Case int32_t gr; void main(void) { gr = UMO_Div32Sat (0x7ffffff0, 0xff); } 3.1.5 UMO_Abs32Sat This function outputs the absolute value. If the result exceeds the limitation of signed 32-bit value, the output will be limited to the 32-bit boundary value ( [-2147483648, 2147483647] ). Prototype int32_t UMO_Abs32Sat(int32_t x); IO Parameters Structure \ Name I/O Data Type Range Description x In input value signed int 0x80000000~0x7fffffff Description This function calculates the absolute of input value. If the result is within the range of [-2147483648, 2147483647], the function outputs the result directly. Otherwise the limitation value is outputted. 2147483647 𝑥 < −2147483647 𝑜𝑢𝑡𝑝𝑢𝑡 = {2147483647 , 𝑥 > 2147483647 |𝑥| 𝑒𝑙𝑠𝑒 Special Result NA Use Case int32_t gr; void main(void) { gr = UMO_Abs32Sat (-2147483648); } 12 FM3_AN706-00091-1v0-E, September 19, 2014 U S E R 3.1.6 M A N U A L UMO_Neg32Sat This function outputs the negative value. If the result exceeds the limitation of signed 32-bit value, the output will be limited to the 32-bit boundary value ( [-2147483648, 2147483647] ). Prototype int32_t UMO_Neg32Sat(int32_t x); IO Parameters Structure \ Name I/O Data Type Range Description x In input value signed int 0x80000000~0x7fffffff Description This function calculates the negative value of input value. If the result is within the range of [-2147483648, 2147483647], the function outputs the result directly. Otherwise the limitation value is outputted. 2147483647 𝑥 < −2147483647 𝑜𝑢𝑡𝑝𝑢𝑡 = {−2147483648 , 𝑥 > 2147483647 −𝑥 𝑒𝑙𝑠𝑒 Special Result NA Use Case int32_t gr; void main(void) { gr = UMO_Neg32Sat (-2147483648); } 3.1.7 UMO_Rnd32 This function outputs the round value. Prototype int32_t UMO_Rnd32(int32_t x, int32_t Qn); IO Parameters Structure Name I/O Data Type Range Description \ x In signed int 0x80000000~0x7fffffff input value \ Qn In signed int 0 ~ 31 Qn format of x Description This function calculates the round value of input value. ⌊𝑥⌋ + 1 𝑖𝑓 𝑥 𝑖𝑠 𝑎 𝑝𝑜𝑠𝑖𝑡𝑖𝑣𝑒 𝑑𝑒𝑐𝑖𝑚𝑎𝑙𝑠 𝑎𝑛𝑑 𝑡ℎ𝑒 𝑑𝑒𝑐𝑖𝑚𝑎𝑙 𝑝𝑎𝑟𝑡 𝑖𝑠 𝑔𝑟𝑒𝑎𝑡𝑒𝑟 𝑡ℎ𝑎𝑛 0.5 𝑖𝑓 𝑥 𝑖𝑠 𝑎 𝑝𝑜𝑠𝑖𝑡𝑖𝑣𝑒 𝑑𝑒𝑐𝑖𝑚𝑎𝑙𝑠 𝑎𝑛𝑑 𝑡ℎ𝑒 𝑑𝑒𝑐𝑖𝑚𝑎𝑙 𝑝𝑎𝑟𝑡 𝑖𝑠 𝑙𝑒𝑠𝑠 𝑡ℎ𝑎𝑛 0.5 ⌊𝑥⌋ 𝑜𝑢𝑡𝑝𝑢𝑡 = ⌈𝑥⌉ − 1 , 𝑖𝑓 𝑥 𝑖𝑠 𝑎 𝑛𝑒𝑔𝑎𝑡𝑖𝑣𝑒 𝑑𝑒𝑐𝑖𝑚𝑎𝑙𝑠 𝑎𝑛𝑑 𝑡ℎ𝑒 𝑑𝑒𝑐𝑖𝑚𝑎𝑙 𝑝𝑎𝑟𝑡 𝑖𝑠 𝑔𝑟𝑒𝑎𝑡𝑒𝑟 𝑡ℎ𝑎𝑛 0.5 𝑖𝑓 𝑥 𝑖𝑠 𝑎 𝑛𝑒𝑔𝑎𝑡𝑖𝑣𝑒 𝑑𝑒𝑐𝑖𝑚𝑎𝑙𝑠 𝑎𝑛𝑑 𝑡ℎ𝑒 𝑑𝑒𝑐𝑖𝑚𝑎𝑙 𝑝𝑎𝑟𝑡 𝑖𝑠 𝑙𝑒𝑠𝑠 𝑡ℎ𝑎𝑛 0.5 ⌈𝑥⌉ { 𝑥 𝑖𝑓 𝑥 𝑖𝑠 𝑎 𝑖𝑛𝑡𝑒𝑟𝑔𝑒𝑟 Special Result NA Use Case September 19, 2014, FM3_AN706-00091-1v0-E 13 U S E R int32_t M A N U A L gr; void main(void) { gr = UMO_Rnd32 (6, 2); } 3.1.8 UMO_LLS32 This function logic shifts a value to the left direction. Prototype int32_t UMO_LLS32(int32_t x, int32_t ShiftLength); IO Parameters Structure Name I/O Data Type Range Description \ x In signed int 0 ~ 0xffffffff input value \ ShiftLength In signed int 0 ~ 32 How many bits are to be shifted Description This function shifts x to the left, the shift length is given by ‘ShiftLength’. If ShiftLength equals 2, the following figure shows the operation details. Original value x: Bit 31 … Bit 2 Bit 1 Bit 0 … Bit 0 0 0 Result (ShiftLength = 2): Bit 29 Figure 3-5: UMO_LLS32 Diagram Special Result NA Use Case int32_t gr; void main(void) { gr = UMO_LLS32 (6, 2); } 3.1.9 UMO_LRS32 This function logic shifts a value to the right direction. Prototype int32_t UMO_LRS32(int32_t x, int32_t ShiftLength); IO Parameters Structure 14 Name I/O Data Type Range Description \ x In signed int 0 ~ 0xffffffff input value \ ShiftLength In signed int 0 ~ 32 How many bits are to be shifted FM3_AN706-00091-1v0-E, September 19, 2014 U S E R M A N U A L Description This function shifts x to the right, the shift length is given by ‘ShiftLength’. If the ‘ShiftLength’ equals 2, the following figure shows the operation details. Original value x: Bit 31 … Bit 2 Bit 1 Bit 0 0 Bit31 … Bit2 Result (ShiftLength = 2): 0 Figure 3-6: UMO_LRS32 Diagram Special Result NA Use Case int32_t gr; void main(void) { gr = UMO_LRS32 (6, 2); } 3.1.10 UMO_ROL32 This function rotating shifts a value to the left direction. Prototype int32_t UMO_ROL32(int32_t x, int32_t ShiftLength); IO Parameters Structure Name I/O Data Type Range Description \ x In signed int 0 ~ 0xffffffff input value \ ShiftLength In signed int 0 ~ 32 How many bits are to be shifted Description This function rotating shifts x to left, the shift length is given by ‘ShiftLength’. If ShiftLength equals 2, the following figure shows the operation details. Original value x: Bit 31 … Bit 2 Bit 1 Bit 0 … Bit 0 Bit31 Bit30 Result (ShiftLength = 2): Bit 29 Figure 3-7: UMO_ROL32 Diagram Special Result NA September 19, 2014, FM3_AN706-00091-1v0-E 15 U S E R M A N U A L Use Case int32_t gr; void main(void) { gr = UMO_ROL32 (6, 2); } 3.1.11 UMO_ROR32 This function rotating shifts a value to the right direction. Prototype int32_t UMO_ROR32(int32_t x, int32_t ShiftLength); IO Parameters Structure Name I/O Data Type Range Description \ x In signed int 0 ~ 0xffffffff input value \ ShiftLength In signed int 0 ~ 32 How many bits are to be shifted Description This function shifts x to right, the shift length is given by ‘ShiftLength’. If ShiftLength equals 2, the following figure shows the operation details. Original value x: Bit 31 … Bit 2 Bit 1 Bit 0 Bit0 Bit31 … Bit2 Result (ShiftLength = 2): Bit1 Figure 3-8: UMO_ROR32 Diagram Special Result NA Use Case int32_t gr; void main(void) { gr = UMO_ROR32 (6, 2); } 3.1.12 UMO_Qnm This function transfers a Qn format value to a Qm format value. Prototype int32_t UMO_Qnm(int32_t x, int32_t Qn, int32_t Qm); 16 FM3_AN706-00091-1v0-E, September 19, 2014 U S E R M A N U A L IO Parameters Structure Name I/O Data Type Range Description \ x In signed int 0 ~ 0xffffffff input value \ Qn In signed int 0 ~ 31 Original Qn format of x \ Qm In signed int 0 ~ 31 Target Qm format of x Description This function transfers a Qn format value to a Qm format value. For example, 1 (Q0) can be transferred to 0x100 (Q8) by calling this function: UMO_Qnm(1, 0, 8). Special Result NA Use Case int32_t gr; void main(void) { gr = UMO_Qnm (0x100, 8, 0); } 3.1.13 UMO_Rep32 This function calculates the reciprocal. Prototype int32_t UMO_Rep32(int32_t x); IO Parameters Structure \ Name I/O Data Type Range Description x In input value with Q15 format signed int 0x80000000~0x7fffffff Description This function calculates the reciprocal. The input value is Q15 format, and the output value is also Q15 format. For example, to calculate the reciprocal of 0.5, we can set x=16384 (Q15), then the output result is 1 ( ) = 65536(Q15) . 0.5 Special Result If x = 0, the output should be 0x7fffffff. Use Case int32_t gr; void main(void) { gr = UMO_Rep32 (32768); } 3.2 UMFLIB All functions in the Universal Math Operation Library (UMFLIB) are shown below: September 19, 2014, FM3_AN706-00091-1v0-E 17 U S E R 3.2.1 M A N U A L Name Description UMF_Sin Sine function UMF_Cos Cosine function UMF_Tan Tangent function UMF_Arcsin Arc-sin function UMF_Arccos Arc-cos function UMF_Arctan Arc-tan function UMF_Sqrt square-root function UMF_Lut1D linear interpolation function UMF_Sign Sign function UMF_Sin This function calculates the sine value. Prototype int32_t UMF_Sin(int32_t x); IO Parameters Structure \ Name I/O Data Type Range Description x In input positive value signed int 0 ~ 0x7fffffff Description This function calculates the sine value. The input value x should be positive. This function outputs a Q12 value. The relation between x value and the real angle (degree) is as follows. x Angle(degree) 0 0 * 360 / 1024 1 1 * 360 / 1024 2 2 * 360 / 1024 … … n n * 360 / 1024 Special Result NA Use Case int32_t gr; void main(void) { gr = UMF_Sin (256); } 3.2.2 UMF_Cos This function calculates the cosine value. Prototype int32_t UMF_Cos(int32_t x); 18 FM3_AN706-00091-1v0-E, September 19, 2014 U S E R M A N U A L IO Parameters Structure \ Name I/O Data Type Range Description x In input positive value signed int 0 ~ 0x7fffffff Description This function calculates the cosine value. The input value x should be positive. This function outputs a Q12 value. The relation between x value and the real angle (degree) is as follows. x Angle(degree) 0 0 * 360 / 1024 1 1 * 360 / 1024 2 2 * 360 / 1024 … … n n * 360 / 1024 Special Result NA Use Case int32_t gr; void main(void) { gr = UMF_Cos (256); } 3.2.3 UMF_Tan This function calculates the tangent value. Prototype int32_t UMF_Tan(int32_t x); IO Parameters Structure \ Name I/O Data Type Range x In signed int Description 0x80000000 ~ 0x7fffffff input value Description This function calculates the tangent value and outputs a Q12 value The relation between x value and the real angle (degree) is as follows. September 19, 2014, FM3_AN706-00091-1v0-E x Angle(degree) -n -n * 360 / 1024 … … -1 -1 * 360 / 1024 0 0 * 360 / 1024 1 1 * 360 / 1024 … … n n * 360 / 1024 19 U S E R M A N U A L Special Result NA Use Case int32_t gr; void main(void) { gr = UMF_Tan (256); } 3.2.4 UMF_Arcsin This function calculates the arc-sine value. Prototype int32_t UMF_Arcsin(int32_t x); IO Parameters Structure \ Name I/O Data Type Range Description x In input value with Q12 format signed int -4096 ~ 4096 Description This function calculates the arc-sine value. The input value is Q12 format which is in the range of [-4096, 4096]. This function outputs an angle value which is in the range of [-256, 256]. The relation between output value and the real angle (degree) is as follows. output Angle(degree) -256 -256 * 360 / 1024 … … -1 -1 * 360 / 1024 0 0 * 360 / 1024 1 1 * 360 / 1024 … … 256 256 * 360 / 1024 Special Result NA Use Case int32_t gr; void main(void) { gr = UMF_Arcsin (128); } 3.2.5 UMF_Arccos This function calculates the arc-cosine value. Prototype 20 FM3_AN706-00091-1v0-E, September 19, 2014 U S E R M A N U A L int32_t UMF_Arccos(int32_t x); IO Parameters Structure \ Name I/O Data Type Range Description x In input value with Q12 format signed int -4096 ~ 4096 Description This function calculates the arc-cosine value. The input value is Q12 format which is in the range of [-4096, 4096]. This function outputs an angle value which is in the range of [-256, 256]. The relation between output value and the real angle (degree) is as follows. output Angle(degree) -256 -256 * 360 / 1024 … … -1 -1 * 360 / 1024 0 0 * 360 / 1024 1 1 * 360 / 1024 … … 256 256 * 360 / 1024 Special Result NA Use Case int32_t gr; void main(void) { gr = UMF_Arccos (128); } 3.2.6 UMF_Arctan This function calculates the arc-tangent value. Prototype int32_t UMF_Arctan(int32_t x); IO Parameters Structure \ Name I/O Data Type Range x In signed int Description 0x80000000 ~ 0x7fffffff input value with Q12 format Description This function calculates the arc-tangent value. The input value is Q12 format. This function outputs an angle value which is in the range of [-256, 256]. The relation between output value and the real angle (degree) is as follows. September 19, 2014, FM3_AN706-00091-1v0-E 21 U S E R M A N U A L output Angle(degree) -256 -256 * 360 / 1024 … … -1 -1 * 360 / 1024 0 0 * 360 / 1024 1 1 * 360 / 1024 … … 256 256 * 360 / 1024 Special Result NA Use Case int32_t gr; void main(void) { gr = UMF_Arctan (327680); } 3.2.7 UMF_Sqrt This function calculates the square-root value. Prototype int32_t UMF_Sqrt(int32_t x); IO Parameters Structure \ Name I/O Data Type Range Description x In input value with Qk format, k should be even and in the range of [0, 30] signed int 0 ~ 0x7fffffff Description This function calculates the square-root value. The input value is Qk format, k should be even and in the range of [0, 30]. This function outputs a Qm value, m = k / 2. For example, if x = 65536 (Q12, the real value is 16), the output should be 256 (Q6, the real value is 4). Special Result NA Use Case int32_t gr; void main(void) { gr = UMF_Sqrt (65536); } 3.2.8 UMF_Lut1D The function UMF_ Lut1D returns the linear interpolation value between two of the points. 22 FM3_AN706-00091-1v0-E, September 19, 2014 U S E R M A N U A L Prototype int32_t UMF_Lut1D(int32_t x,int32_t x0,int32_t y0,int32_t x1,int32_t y1); IO Parameters Structure Name I/O Data Type Range Description \ x In signed long 0x80000000 ~ the input value between two points 0x7fffffff \ x0 In signed long 0x80000000 ~ the abscissa value of the first point 0x7fffffff \ y0 In signed long 0x80000000 ~ the ordinate value of the first point 0x7fffffff \ x1 In signed long 0x80000000 ~ the abscissa value of the second point 0x7fffffff \ y1 In signed long 0x80000000 ~ the ordinate value of the second point 0x7fffffff \ y Out signed long 0x80000000 ~ The return value by the linear interpolation 0x7fffffff function Description The UMF_Lut1D function calculates the value between two points by the linear interpolation function as the following equations and diagram show: 𝑦 = 𝑦0 + (𝑥 − 𝑥0) ∗ 𝑦1 − 𝑦0 𝑥1 − 𝑥0 (x1,y1) (x,y) 𝑦 = 𝑦0 + (𝑥 − 𝑥0) ∗ 𝑦1 − 𝑦0 𝑥1 − 𝑥0 (x0,y0) Special Result The abscissa value can’t be the same due to the over-flow will happen at this condition. Use Case September 19, 2014, FM3_AN706-00091-1v0-E 23 U S E R M A N U A L int32_t x,y; int32_t x0,y0; int32_t x1,y1; void main(void) { while(1) { y= UMF_Lut1D(x,x0,y0,x1,y1); } } 3.2.9 UMF_Sign The function UMF_Sign returns the sign of the argument Prototype int32_t UMF_Sign(int32_t x); IO Parameters Structure \ Name I/O Data Type Range Description x In signed long 0x800000000 ~ 0x7fffffff Input value Description The function UMF_Sign calculates the sign of the input value as the following equation shows: 1 𝑤ℎ𝑒𝑛 𝑥 > 0 𝑦 = { 0 𝑤ℎ𝑒𝑛 𝑥 = 0 −1 𝑤ℎ𝑒𝑛 𝑥 < 0 Special Result NA Use Case int32_t x,y; void main(void) { while(1) { y= UMF_ Sign (x); } } 24 FM3_AN706-00091-1v0-E, September 19, 2014 U S E R 3.3 M A N U A L BFLIB All functions in the Basic Function Library (BFLIB) are shown below. 3.3.1 Name Description BF_Lmt Limitation Function BF_Hyst Hysteresis Function BF_Ramp Signal Integration Function BF_Intg Signal Ramp Function BF_Lmt The limitation function BF_Lmt returns the input value by the upper or lower limit. The result stays to the limitation value when the limit is achieved; otherwise it stays the same as input. Prototypes int32_t BF_Lmt(int32_t i32In, stc_Lmt_t *LmtStc); IO Parameters Structure Name I/O Data Type Range Description \ i32In In signed int 0x80000000~0x7fffffff Input value i32UpLmt In signed int 0x80000000~0x7fffffff Max value for the limitation i32LwLmt In signed int 0x80000000~0x7fffffff Min value for the limitation stc_Lmt_t Description The input value will be the same with output if the input value is between the upper and lower limits. On the other hand, the input value will be limited to the upper or lower value as the equation shows i32In when i32LwLmt ≤ i32In ≤ i32UpLmt i32In = { i32UpLmt wheni32In ≥ i32UpLmt i32LwLmt wheni32In ≤ i32LwLmt The upper and lower limits can be found in the limitation structure ’stc_Lmt_t’. Special Result The upper limitation value must be greater than the lower limitation when these values are set by the user. Use Case stc_Lmt_t BF_StcLmt; int32_t v1, gr; void main(void) { BF_ StcLmt. i32UpLmt = -100; BF_ StcLmt. i32UpLmt = 100; while(1) { v1 = 22; v1 = BF_Lmt(v1,&BF_StcLmt);//output should be v1=22 v1 = 111; v1 = BF_Lmt(v1,&BF_StcLmt); //output should be v1=100 v1 = -111; v1 = BF_Lmt(v1,&BF_StcLmt); //output should be v1=-100 } } September 19, 2014, FM3_AN706-00091-1v0-E 25 U S E R 3.3.2 M A N U A L BF_Hyst The hysteresis function returns the function ON or OFF value. It is can be used to the function ON\OFF based on the input value to avoid the frequently entry or exit the function at one of the input conditions. Switch off In Switch on Figure 3-9: Hysteresis Function Diagram Prototype int32_t BF_Hyst(int32_t i32In, stc_Hyst_t *HystStc); IO Parameters Structure Name I/O Data Type Range Description \ i32In In signed int 0x80000000~0x7fffffff Input value i32SwOn In signed int 0x80000000~0x7fffffff Threshold value for state on i32SwOff In signed int 0x80000000~0x7fffffff Threshold cOutState Out char TRUE/FALSE output state by hysteresis TRUE – function ON FALSE – function OFF stc_Hyst_t value for state off Description The hysteresis function ‘BF_Hyst’ can be used to output hysteresis relay signal. The function switches the output between the two Threshold ‘i32SwOn’ and ‘i32SwOff’ that are in the structure ‘stc_Hyst_t’. When the value of the input is higher than the upper threshold i32SwOn, the output value is equal to TRUE. When the input value is lower than the lower threshold i32SwOff, the output value is equal to FALSE. When the input value is between the two threshold values, the output state will not change. 𝑦={ 𝑇𝑅𝑈𝐸 𝑦 𝐹𝐴𝐿𝑆𝐸 𝑤ℎ𝑒𝑛 𝑖32𝐼𝑛 ≥ i32SwOn 𝑤ℎ𝑒𝑛 𝑖32𝐼𝑛 𝑏𝑒𝑡𝑤𝑒𝑒𝑛 i32SwOn 𝑎𝑛𝑑 i32SwOff 𝑤ℎ𝑒𝑛 𝑖32𝐼𝑛 ≤ i32SwOff Special Result NA Use Case stc_Hyst_t BF_StcHyst; int32_t v1, gr; void main(void) { BF_ StcHyst. i32SwOn = -100; BF_ StcHyst. i32SwOff = 100; while(1) { gr = BF_Hyst(v1,&BF_StcHyst);//’gr’ changes to 0 or 1 based on the ‘v1’ } } 26 FM3_AN706-00091-1v0-E, September 19, 2014 U S E R 3.3.3 M A N U A L BF_Ramp The function is used for the ramp output that can be used to make the middle signal approach the destination value by the setting slope. Prototype void BF_Ramp(&BF_StcRamp); IO Parameters Structure stc_Ramp_t Name I/O Data Type Range Description i32RampEndVal In signed int 0x80000000~0x7fffffff Ramp end value i32RampMidVal I/O signed int 0x80000000~0x7fffffff Ramp value i32RampStep In signed int 0x80000000~0x7fffffff Step value for the ramp i32RampCnt inner signed int 0x80000000~0x7fffffff Counter for the ramp execution i32RampCount In signed int 0x80000000~0x7fffffff Time for the ramp execution cRampState out char State for the ramp process, 1--up, 0--keep,2--down 0,1,2 Description The function of signal ramp ‘BF_Ramp’ can be used for the signal changing with the setting slope such as the speed accelerate or decelerate and other similar signals. The ramp out signal ‘i32RampMidVal’ can be changed with the slope as ‘i32RampStep’ and ‘i32RampCount’ setting. i32RampStep Ramp down step Keep Ramp up step i32RampCount Figure 3-10: Signal Ramp Diagram Special Result If the result is greater than 0x7FFF or smaller than 0x8000, the output overflows. The signal changing step ‘i32RampStep’ and execution counter ‘i32RampStep’ must be positive values. Otherwise the ramp output can’t approach the destination value or an unexpected value may appear. Use Case September 19, 2014, FM3_AN706-00091-1v0-E 27 U S E R M A N U A L stc_Ramp_t BF_StcRamp; int32_t v1, gr; void main(void) { BF_StcRamp.i32RampCount = 10; BF_StcRamp.i32RampEndVal = 100; BF_StcRamp.i32RampStep=12; while(1) { /** BF_StcRamp. i32RampMidVal will approach the ‘i32RampEndVal’ */ BF_Ramp(&BF_StcRamp); } } 3.3.4 BF_Intg The function is used for the signal integration. Prototype void BF_Intg(int32_t i32In,stc_Integrat_t *IntgStc); IO Parameters Structure Name I/O Data Type \ Range Description i32In In signed long 0x80000000~0x7fffffff Input value stc_Integrat_t i32IntgOut out signed long 0x80000000~0x7fffffff Integration output stc_Integrat_t i32IntgMax Inner signed long 0x80000000~0x7fffffff Max value of integration stc_Integrat_t i32IntgMin inner signed int value 0x80000000~0x7fffffff Min value of integration Description The function returns the integrated value of the input signal with anti-windup. When the output of the integration ‘IntgStc-> i32IntgOut’ exceeds the maximum or minimum limitation, it will stay to the limitation. For the discrete of the digital input signal, the integration function can be simplified as following: yn = yn−1 + xn Special Result NA Use Case stc_Integrat_t BF_StcIntg; int32_t v1, gr; void main(void) { BF_StcIntg.i32IntgMax = 0x7fff; BF_StcIntg.i32IntgMin = 0x8000; while(1) { BF_Intg(v1,&BF_StcIntg); } } 28 FM3_AN706-00091-1v0-E, September 19, 2014 U S E R 3.4 M A N U A L UDFLIB All functions in the Universal Digital Filter Library (UDFLIB) are shown below. Name Description UDF_FilterAvg Moving Average Filter UDF_AvgFilter_Slide Moving Average Filter with buffer UDF_Filter1stOrd 3.4.1 1st order low pass filter UDF_FilterAvg The function UDF_FilterAvg is used for the moving average filter. Prototype int32_t UDF_FilterAvg(int16_t i16In, stc_FilterAvg_t *pFilter); IO Parameters Structure Name I/O Data Type Range Description \ i16In In signed int Input value i32Sum Inner signed long 0x80000000~0x7fffffff Output for moving average filter stc_Integrat_t i16Depth 0x8000~0x7fff signed long 0x80000000~0x7fffffff Filter depth is 2i16Depth In Description This function returns the filter value of input signal value by the moving average filter. The algorithm used in this filter is shown as following equations. i32Sum += i16In out = i32Sum ≫ i16Depth i32Sum −= out The related variables can be found in the structure ‘stc_FilterAvg_t’. Special Result The filter depth ‘i16Depth’ must be greater than 0. Use Case stc_FilterAvg_t int32_t UDF_StcFilterAvg; v1, gr; void main(void) { UDF_StcFilterAvg.i16Depth = 2; UDF_StcFilterAvg.i32Sum = v1*((1<<UDF_StcFilterAve.i16Depth )-1) while(1) { gr = UDF_FilterAve(v1,&UDF_StcFilterAve); } } 3.4.2 UDF_AvgFilter_Slide The function UDF_ AvgFilter_Slide is used for the moving average filter. Prototype int32_t UDF_AvrFilter_Slide(stc_AvrFilterSliding_t *pstcAvrFilterSliding, int32_t ElementVal); September 19, 2014, FM3_AN706-00091-1v0-E 29 U S E R M A N U A L IO Parameters Structure \ Name I/O Data Type ElementVal In signed int 0x80000000~0x7fffffff Current input pContainer Inner signed int 0x80000000~0x7fffffff A container (named as container array) to hold history inputs HowManyDots Inner signed int Not greater than the How many elements is used for length of container average filter array. stc_AvrFilterSliding_t Sum Range Description Inner signed int 0x80000000~0x7fffffff Sum of all the elements in container array. ElementNo Inner unsigned Not greater than the The element which serial short length of container number is ElementNo in array. container array will be replaced by current input value (ElementVal) FlagFull Inner boolean_t 0 or 1 To denote if the container array is full. Description This function returns a filtered value according to the following procedure. Below figure shows a 5-element average sliding filter. Input element Container array Output result E1 E1 0 0 0 0 E1 E2 E1 E2 0 0 0 (E1+E2)/2 E3 E1 E2 E3 0 0 (E1+E2+E3)/3 E4 E1 E2 E3 E4 0 (E1+E2+E3+E4)/4 E5 E1 E2 E3 E4 E5 (E1+E2+E3+E4+E5)/5 E6 E6 E2 E3 E4 E5 (E6+E2+E3+E4+E5)/5 E7 E6 E7 E3 E4 E5 (E6+E7+E3+E4+E5)/5 E8 E6 E7 E8 E4 E5 (E6+E7+E8+E4+E5)/5 … … … Figure 3-11: Average Sliding Filter Diagram Special Result NA 30 FM3_AN706-00091-1v0-E, September 19, 2014 U S E R M A N U A L Use Case int32_t ContainerArray[5]; stc_AvgFilterSliding_t UDF_StcFilterAvg; int32_t gr, gin = 100; void main(void) { UDF_StcFilterAvg.HowManyDots = sizeof(ContainerArray) / sizeof(int32_t); UDF_StcFilterAvg.pContainer = &(ContainerArray[0]); UDF_StcFilterAvg.ElementNo = 0; Set a breakpoint here. Set a new ‘gin’ value every time program stops at this breakpoint. Then the output can be observed by ‘gr’. UDF_StcFilterAvg.Sum = 0; UDF_StcFilterAvg.FlagFull = FALSE; while(1) { gr = UDF_AvgFilter_Slide(&UDF_StcFilterAvg, gin); } } 3.4.3 UDF_Filter1stOrd st The function returns the value by the 1 order low pass filter. Prototype void UDF_Filter1stOrd(int32_t i32In, int32_t*i32Out, stc_Filter1stOrd_t *LPFPar); IO Parameters Structure Name I/O Data Type \ i32In In signed long 0x80000000~0x7fffffff Input value \ i32Out out signed long 0x80000000~0x7fffffff The output value by the filter Q12_LPFK In signed long 0x80000000~0x7fffffff The coefficient for the filter stc_Filter1stOrd_t Q20_LowBits Range Description Inner signed long 0x80000000~0x7fffffff The accumulation buffer for the filter Description st This function outputs the filter value of input signal value by 1 low pass filter. The algorithm used in this filter is shown as following equations y n = y n−1 + Coe ∗ (xn − xn−1 ) st Where: Coe is the coefficient of the 1 order LPF The related variables can be found in the structure ‘stc_Filter1stOrd_t’. Special Result NA Use Case September 19, 2014, FM3_AN706-00091-1v0-E 31 U S E R M A N U A L stc_Filter1stOrd_t UDF_StcFilter1s; int32_t v1, gr; void main(void) { UDF_StcFilter1stASM.Q12_LPFK = Q12(0.004); UDF_StcFilter1stASM.Q20_LowBits = 0; while(1) { UDF_Filter1stOrd(v1,&v3,&UDF_StcFilter1st); } } 32 FM3_AN706-00091-1v0-E, September 19, 2014 U S E R 3.5 M A N U A L BMCLIB The Basic Motor Control Library (BMCLIB) generates the basic functions of motor control algorithm. All functions in the BMCLIB are shown below. Name Description BMC_ClarkeTrans Clark Transformation BMC_ParkTrans Park Transformation BMC_ClarkeInvTrans Inverse Clark Transformation 3.5.1 BMC_ParkInvTrans Inverse Park Transformation BMC_Pid PID Controller Functions BMC_SvmCalc SVPWM BMC_Ovm Over -PWM BMC_ClarkeTrans The function BMC_ClarkeTrans returns the value by Clarke coordinates transform. Prototype void BMC_ClarkeTrans(stc_UVWAx_t * Input,stc_AlphBetaAx_t * Output); IO Parameters Structure stc_UVWAx_t Name I/O Data Type Range Description i32Q8_U In signed long 0x80000000~0x7fffffff U phase value i32Q8_V In signed long 0x80000000~0x7fffffff V phase value i32Q8_W In signed long 0x80000000~0x7fffffff W phase value stc_AlphBetaAx_t i32Q8_Xa Out signed long 0x80000000~0x7fffffff Value on alpha-axis i32Q8_Xb Out signed long 0x80000000~0x7fffffff Value on beta-axis Description The Clarke Transformation is used to transform the 3-phase (U/V/W) stationary coordinates to the 2-phase (alpha-beta) orthogonal coordinates as the following equations shown: Iα = Iu Iβ = (Iu + 2Iw)/√3 Special Result NA Use Case stc_UVWAx_t Motor_3sCurrent; stc_AlphBetaAx_t Motor_2sCurrent; void main(void) { while(1) { BMC_ClarkeTrans(&Motor_3sCurrent,&Motor_2sCurrent); } } 3.5.2 BMC_ParkTrans The function ‘BMC_ParkTrans’ returns the value by Park coordinates transform. Prototype September 19, 2014, FM3_AN706-00091-1v0-E 33 U S E R M A N U A L void BMC_ParkTrans(stc_AlphBetaAx_t * Input,stc_dqAx_t * Output); IO Parameters Structure Name I/O Data Type Range Description stc_AlphBetaAx_t i32Q8_Xa In signed long 0x80000000~0x7fffffff Value on alpha-axis i32Q8_Xb In signed long 0x80000000~0x7fffffff Value on beta-axis i32Q12_Cos In signed long 0x80000000~0x7fffffff Sin value of rotor position i32Q12_Sin In signed long 0x80000000~0x7fffffff Cos value of rotor position i32Q8_d Out signed long 0x80000000~0x7fffffff Value on D-axis i32Q8_q Out signed long 0x80000000~0x7fffffff Value on Q-axis stc_dqAx_t component component Description The Park Transformation function ‘BMC_ParkTrans’ transforms values on the 2-phase (α − β) stationary orthogonal coordinates to the two-phase (d − q) rotational orthogonal coordinates as the following equations shown: Id = Iα ∗ Cosθ + Iβ ∗ Sinθ Iq = −Iα ∗ Sinθ + Iβ ∗ Cosθ Where: θ is the rotor ele-angle. Special Result NA Use Case stc_AlphBetaAx_t Motor_2sCurrent; stc_dqAx_t Motor_2rCurrent; void main(void) { while(1) { BMC_ClarkeInvTrans(&Motor_2sCurrent,&Motor_3sCurrent); } } 3.5.3 BMC_ClarkeInvTrans The Inverse Clarke function ‘BMC_ClarkeInvTrans’ returns the value by Inverse Clarke Transform Prototype void BMC_ClarkeInvTrans(stc_AlphBetaAx_t * Input,stc_UVWAx_t * Output); IO Parameters Structure Name I/O Data Type stc_AlphBetaAx_t i32Q8_Xa In signed long 0x80000000~0x7fffffff Value on alpha-axis i32Q8_Xb In signed long 0x80000000~0x7fffffff Value on beta-axis i32Q8_U Out signed long 0x80000000~0x7fffffff U phase value i32Q8_V Out signed long 0x80000000~0x7fffffff V phase value i32Q8_W Out signed long 0x80000000~0x7fffffff W phase value stc_UVWAx_t Range Description Description 34 FM3_AN706-00091-1v0-E, September 19, 2014 U S E R M A N U A L The Inverse Clarke Transformation function ‘BMC_ClarkeInvTrans’ transforms the values from the 2-phase (α − β) orthogonal coordinates to the 3-phase (U/V/W) coordinates. Iu = Iα Iv = (√3 ∗ Iα − Iβ )/2 Iw = −(√3 ∗ Iα + Iβ )/2 Special Result NA Use Case stc_UVWAx_t Motor_3sCurrent; stc_AlphBetaAx_t Motor_2sCurrent; void main(void) { while(1) { BMC_ClarkeInvTrans(&Motor_2sCurrent,&Motor_3sCurrent); } } 3.5.4 BMC_ParkInvTrans The Inverse Park function ‘BMC_ParkInvTrans’ returns the value by Inverse Park Transform. Prototype void BMC_ParkInvTrans(stc_dqAx_t * Input,stc_AlphBetaAx_t * Output); IO Parameters Structure stc_dqAx_t Name I/O Data Type Range Description i32Q12_Cos In signed long 0x80000000~0x7fffffff Sin value of rotor position i32Q12_Sin In signed long 0x80000000~0x7fffffff Cos value of rotor position i32Q8_d In signed long 0x80000000~0x7fffffff Value on D-axis component i32Q8_q In signed long 0x80000000~0x7fffffff Value on Q-axis stc_AlphBetaAx_t i32Q8_Xa In signed long 0x80000000~0x7fffffff Value on alpha-axis component i32Q8_Xb In signed long 0x80000000~0x7fffffff Value on beta-axis Description The Inverse Park Transformation function ‘BMC_ParkInvTrans transforms values on the 2-phase (d-q) rotational orthogonal coordinates to the 2-phase (α-β) stationary orthogonal coordinates as the following equations shown: Iα = Id ∗ Cosθ − Iq ∗ Sinθ Iβ = Id ∗ Sinθ + Iq ∗ Cosθ Where: θ is the rotor ele-angle Special Result NA Use Case September 19, 2014, FM3_AN706-00091-1v0-E 35 U S E R M A N U A L stc_dqAx_t Motor_2rCurrent; stc_AlphBetaAx_t Motor_2sCurrent; void main(void) { while(1) { BMC_ParkInvTrans(&Motor_2rCurrent,&Motor_2sCurrent); } } 3.5.5 BMC_Pid The PID function ‘BMC_Pid’ returns the value that corrects the error between the input value and the reference value by the PID regulator. Prototype void BMC_Pid(stc_Pid_t *pstcPid, int32_t i32QN_E0); IO Parameters Structure Name \ stc_Pid_t I/O Data Type Range Description i32QN_E0 In signed long 0x80000000~0x7fffffff Error between the current and reference value i32Q15_Kp In signed long 0x80000000~0x7fffffff Factor of P-regulator i32Q15_Ki In signed long 0x80000000~0x7fffffff Factor of I-regulator i32Q15_Kd In signed long 0x80000000~0x7fffffff Factor of D-regulator i32QN_OutMax Inner signed long 0x80000000~0x7fffffff PID output upper limit i32QN_OutMin Inner signed long 0x80000000~0x7fffffff PID output lower limit i32QN_EAbsMax \ Inner signed long 0x80000000~0x7fffffff Input error limitation i32QN_E1 Inner signed long 0x80000000~0x7fffffff Error of last time i32QN_E2 Inner signed long 0x80000000~0x7fffffff Error of the time before last i32QN_Out1 Inner signed long 0x80000000~0x7fffffff Last PID output i32QN_Du0 Inner signed long 0x80000000~0x7fffffff Keep decimal part of PID regulating result to decrease calculation error Return Out signed long 0x80000000~0x7fffffff The regulated value Description The BMC_Pid function calculates the Proportional-Integral (PI) algorithm according to the equations below. The regulator output is limited and the limit values (i32QN_OutMax and i32QN_OutMin) are set by the user. Out = Kp ∗ Err + Ki ∫ Err Where: Err is the error between the current and reference value; Kp is Factor of PI regulator; Ki is the Factor of PI regulator. Special Result NA Use Case 36 FM3_AN706-00091-1v0-E, September 19, 2014 U S E R stc_Pid_t M A N U A L CompCtrl_stcIqPidReg; int32_t PiEr; // the error between the current and reference value int32_t PiOut; // the output of PID regulator void main(void) { /** Init the PID parameter of CompCtrl_stcIqPidReg before the execution */ while(1) { BMC_Pid(&CompCtrl_stcIqPidReg, PiEr); PiOut = CompCtrl_stcIqPidReg.i32QN_Out1; } } 3.5.6 BMC_SvmCalc The BMC_SvmCalc function realizes the calculation of the space vector pulse width modulation. Prototype void BMC_SvmCalc(stc_svm_calc_t *obj); IO Parameters Table 3-1: Key Variable Lists for SVPWM Calculation Function Structure Name I/O Data Type Range Description In signed long 0x80000000~ 0x7fffffff Alpha component of reference voltage vector In signed long 0x80000000~ 0x7fffffff Beta component of reference voltage vector In signed long 0x80000000~ 0x7fffffff DC-Link voltage In signed long 0x80000000~ 0x7fffffff The ratio of the maximum duty and cycle u16Cylce In unsigned int 0x8000~0x7fff Cycle of SVPWM u16DutyMax In unsigned int 0x8000~0x7fff Maximum duty of SVPWM In signed long 0x8000~0x7fff Alpha component of compensated voltage vector In signed long 0x8000~0x7fff Beta component of compensated voltage vector i32QN_VaIn i32QN_VbIn i32QN_VdcIn i32Q30_DutyK0 stc_ i32QN_VaReal svm_calc_t i32QN_VbReal u16T1 Out unsigned int 0x8000~0x7fff Duration of the first active vector u16T2 Out unsigned int 0x8000~0x7fff Duration of the second active vector u16Uon Out unsigned int 0x8000~0x7fff Comparison value for phase u u16Von Out unsigned int 0x8000~0x7fff Comparison value for phase v u16Won Out unsigned int 0x8000~0x7fff Comparison value for phase w u16Sector Out unsigned int 0x8000~0x7fff The sector number where the real voltage vector resides in u16OvFlag Out unsigned int 0x8000~0x7fff Out of modulation range flag Description The SVPWM function ‘BMC_SvmCalc’ can be used to calculate the SVPWM sector and the comparison value with MFT for each phase. September 19, 2014, FM3_AN706-00091-1v0-E 37 U S E R M A N U A L The diagram of the BMC_SvmCalc is shown as Figure 3-12, and the description for each variable can be found in Table 3-1. u16T1 u16T2 i32QN_VaIn i32QN_VaIn i32QN_VaIn Vα i32QN_VaIn i32QN_VaIn Vα i32QN_VaIn BMC_SvmCalc Vα u16Uon u16Von u16Won u16Sector i32QN_VaReal i32QN_VbReal u16OvFlag Figure 3-12: Overview of under-modulation module Special Result NA Use Case /** initialize the MFT and OCCP peripheral can be found in the sample projection */ void Motor_Process(void) { /** other function execution*/ if (Motor_stcRunPar.u8Status == MOTOR_RUNNING) { while (Adc_stcSample.u8CompCompleteFlag != 1); Adc_stcSample.u8CompCompleteFlag = 0; /** other function execution*/ /** below for the SVPWM calculation */ Motor_stcSvmCalc.i32QN_VaIn = Motor_stcVabRef.i32Q8_Xa; Motor_stcSvmCalc.i32QN_VbIn = Motor_stcVabRef.i32Q8_Xb; Motor_stcSvmCalc.i32QN_VdcIn = Motor_stcRunPar.i32Q8_Vbus; BMC_SvmCalc(&Motor_stcSvmCalc); Motor_stcSvmGen.i16Aon = Motor_stcSvmCalc.u16Uon; Motor_stcSvmGen.i16Bon = Motor_stcSvmCalc.u16Von; Motor_stcSvmGen.i16Con = Motor_stcSvmCalc.u16Won; Motor_stcSvmGen.i16T1 = Motor_stcSvmCalc.u16T1; Motor_stcSvmGen.i16T2 = Motor_stcSvmCalc.u16T2; Motor_stcSvmGen.i8Sector = Motor_stcSvmCalc.u16Sector; Motor_stcVabReal.i32Q8_Xa = Motor_stcSvmCalc.i32QN_VaReal; Motor_stcVabReal.i32Q8_Xb = Motor_stcSvmCalc.i32QN_VbReal; } } 3.5.7 BMC_Ovm The BMC_OvmCalc function realizes the over space vector pulse width modulation Prototype void BMC_OvmCalc(stc_ovm_calc_t* obj) ; IO Parameters 38 FM3_AN706-00091-1v0-E, September 19, 2014 U S E R M A N U A L Table 3-2: Variable Lists for Over-PWM function Structure Name Range Description In signed long 0x80000000~0x7fffffff The alpha component of the reference voltage vector In signed long 0x80000000~0x7fffffff The beta component of the reference voltage vector In signed long 0x80000000~0x7fffffff i32Q16_Mi Out signed long 0x80000000~0x7fffffff i32Q16_MiMax Out signed long 0x80000000~0x7fffffff i32QN_Vdcf Out signed long 0x80000000~0x7fffffff i32QN_Du0 Out signed long 0x80000000~0x7fffffff The remained bits of filtered DC-Link voltage i32QN_VaOut Out signed long 0x80000000~0x7fffffff The alpha component of the compensated voltage vector i32QN_VbOut Out signed long 0x80000000~0x7fffffff The beta component of the compensated voltage vector i32QN_VaIn i32QN_VbIn i32QN_VdcIn stc_ovm_calc_t I/O Data Type The sampled DC-Link voltage The modulation index The maximal modulation index allowed The filtered DC-link voltage Description The Over-PWM function ‘BMC_OvmCalc’ can be used to calculate the SVPWM sector and the comparison value with MFT for each phase. The diagram of the BMC_OvmCalc is shown as Figure 3-13 and the description for each variable can be found in Table 3-2 Over-modulation i32QN_VaOut i32QN_VbIn BMC_OvmCalc i32QN_VdcIn Vdc i32QN_VbOut i32QN_Vdcf i32Q16_Mi Figure 3-13: Overview of New Over-PWM Module Special Result NA Use Case September 19, 2014, FM3_AN706-00091-1v0-E 39 U S E R M A N U A L /** init over-SVPWM at motor start stage when the motor is started */ void Motor_Start(uint16_t u16SampleFreq) { stc_ovm_cfg_t OvmCfg; OvmCfg.i32Q15_C0 = Q15(0.01); OvmCfg.i32Q16_MiMax = 65000; OvmCfg.u8OvmEn = 0; BMC_OvmInit(&OvmCfg ,&Motor_stcOvmCalc); } void Motor_Process(void) { /** other function execution*/ if (Motor_stcRunPar.u8Status == MOTOR_RUNNING) { while (Adc_stcSample.u8CompCompleteFlag != 1); Adc_stcSample.u8CompCompleteFlag = 0; /** other function execution*/ /** below for the Over-PWM calculation */ Motor_stcOvmCalc.i32QN_VaIn = Motor_stcVabRef.i32Q8_Xa; Motor_stcOvmCalc.i32QN_VbIn = Motor_stcVabRef.i32Q8_Xb; Motor_stcOvmCalc.i32QN_VdcIn= Q30mpy(Motor_stcRunPar.i32Q8_Vbus,0x3F5C28F5); BMC_OvmCalc(&Motor_stcOvmCalc); Motor_stcVabRef.i32Q8_Xa = Motor_stcOvmCalc.i32QN_VaOut; Motor_stcVabRef.i32Q8_Xb = Motor_stcOvmCalc.i32QN_VbOut; } } 40 FM3_AN706-00091-1v0-E, September 19, 2014 U S E R 3.6 M A N U A L AMCLIB Advanced Motor Control Library (AMCLIB) generates the advanced functions of motor control algorithm. All functions in the AMCLIB are shown below. 3.6.1 Name Description AMC_PllEstimate Sensor-less Angle Observer AMC_AvgSpdCalc Speed Calculator AMC_Hall HALL AMC_GetDeltaAngleByEncoder_A QPRC AMC_PllEstimate The AMC_PllEstimate function returns the values for the rotor position and speed by the sensor-less angle observer. Prototype void AMC_PllEstimate(stc_ebemf_pll_t *pstcEstimPar, stc_AlphBetaAx_t *pstc2sVol, stc_AlphBetaAx_t *pstc2sCurrent); IO Parameters Note: there are so many variables used for the ‘AMC_PllEstimate’ function. Most of the inner used variables are ignored in this table. The description in detail can be found in the H files ‘AMCLIB.h’. Table 3-3: Variable Lists for Rotor Observer Function Structure Name I/O Data Type Range Description i32Q8_Res In signed long 0~0x7fffffff The coefficient for phase resistance of motor i32Q8_Lddt In signed long 0~0x7fffffff The coefficient for the d-axis inductance of motor i32Q12_LdLq In signed long 0~0x7fffffff The coefficient for the D-axis and Q-axis inductance of motor i32Q12_RecipKe In signed long 0~0x7fffffff Reciprocal of the BEMF of motor stc_AlphBetaAx_t i32Q8_Xa In signed long 0x80000000~0x7fffffff Value on alpha-axis i32Q8_Xb In signed long 0x80000000~0x7fffffff Value on beta-axis i32Q22_ElecAngle Out signed long 0~2 i32Q8_EstimWmHz Out signed long 0x80000000~0x7fffffff Real-time rotor speed i32Q8_EstimWmHzf Out signed long 0x80000000~0x7fffffff Filtered rotor speed stc_ebemf_pll_t stc_ebemf_pll_t 22 22 Rotor angle, 2 =360deg Description The sensor-less angle observer function ‘AMC_PllEstimate ‘ can be used to calculate the rotor speed and angle by the PLL estimator. The diagram of the AMC_PllEstimate is shown as Figure 3-14 and the description for each variable can be found in Table 3-3 September 19, 2014, FM3_AN706-00091-1v0-E 41 U S E R M A N U A L Rotor Observer Motor parameter pstc2sVol ->i32Q8_Xa i32Q22_ElecAngle AMC_PllEstimate pstc2sVol Vdc ->i32Q8_Xb i32Q8_EstimWmHz i32Q8_EstimWmHzf pstc2sCurrent ->i32Q8_Xa pstc2sCurrent l ->i32Q8_Xa Figure 3-14: Overview of AMC_PllEstimate Special Result NA Use Case /* Global variable definitions*/ stc_AlphBetaAx_t Motor_stcVabReal; stc_AlphBetaAx_t Motor_stcIabSensed; stc_ebemf_pll_t Motor_stcPll; /** init over-SVPWM at motor start stage when the motor is started */ void Motor_Start(uint16_t u16SampleFreq) { AMC_PllEstimateInit(u16SampleFreq); } void Motor_Process(void) { /** other function execution*/ if (Motor_stcRunPar.u8Status == MOTOR_RUNNING) { while (Adc_stcSample.u8CompCompleteFlag != 1); Adc_stcSample.u8CompCompleteFlag = 0; /** other function execution*/ /** below for the rotor angle observer */ AMC_PllEstimate(&Motor_stcPll, &Motor_stcVabReal, &Motor_stcIabSensed); } } 3.6.2 AMC_AvgSpdCalc The AMC_AvgSpdCalc function returns the rotor average speed. Prototype void AMC_AvgSpdCalc(stc_avergae_speed_t *pstcAver, int32_t i32Q22_ElecAngle); IO Parameters Structure stc_ebemf_pll_t stc_avergae_speed Name I/O Data Type Range 22 Description i32Q22_ElecAngle In Signed 0~2 long The real-time angle rotor i32Q8_AvWmHz Out signed 0x80000000~0x7fffffff The average speed in long each ele-cycle Note: The inner used variables are ignored in this table. The description in detail can be found in the H files ‘AMCLIB.h’ 42 FM3_AN706-00091-1v0-E, September 19, 2014 U S E R M A N U A L Description The rotor speed calculation function ‘AMC_AvgSpdCalc’ returns the average speed of rotor in each ele-cycle. The diagram of the AMC_AvgSpdCalc is shown as Figure 3-14 and the description for each variable can be found in Table 3-3 Speed Calculator i32Q22_ElecAngle i32Q8_AvWmHz AMC_AvgSpdCalc Figure 3-15: Overview of AMC_AvgSpdCalc Special Result NA Use Case /* Global variable definitions*/ stc_avergae_speed_t Motor_stcAverSpd; int32_t Comp_f32PolePairs = 6 // the pole pairs of rotor uint8_t Comp_u8AvrThetaCalcFreq = 2; // 1->one electrical circle, // 2->two electrical circle /** init relevant variables at motor start stage when the motor is started */ void Motor_Start(uint16_t u16SampleFreq) { AMC_AvgSpdInit(&Motor_stcAverSpd, Q12(u16SampleFreq/4096.0f/Comp_f32PolePairs), Comp_u8AvrThetaCalcFreq); } void Motor_Process(void) { /** other function execution*/ if (Motor_stcRunPar.u8Status == MOTOR_RUNNING) { while (Adc_stcSample.u8CompCompleteFlag != 1); Adc_stcSample.u8CompCompleteFlag = 0; /** other function execution*/ /** below for the rotor angle observer */ AMC_AvgSpdCalc(&Motor_stcAverSpd, Motor_stcPll.i32Q22_ElecAngle); } } 3.6.3 AMC_GetDeltaAngleByEncoder_A This function is to calculate variation of the rotor position by QPRC unit. Three types of variation can be selected by user: angle value (degree), angle value (rad), and QPRC counter value. Before applying this function, the following QPRC mode should be configured: 1. QPRC position counting mode should be configured to work mode 2 (Phase difference count mode). September 19, 2014, FM3_AN706-00091-1v0-E 43 U S E R M A N U A L 2. QPRC revolution counting should be configured to work mode 2 (The revolution counter can count up or down with an output value of position counter only). 3. ZIN signal should be disabled. 4. QMPR register (QPRC Maximum Position Register) should be configured to 4 times of the encoder resolution. Prototype int32_t AMC_GetDeltaAngleByEncoder_A(uint8_t WhichQPRC, int32_t *pLastPosiCnt, int32_t Val_QMPR); IO Parameters Structure Name I/O Data Type \ WhichQPRC In unsigned char \ pLastPosiCnt In Pointer of signed int \ Val_QMPR In signed int Range 0x00~0xff \ Description Which QPRC is to be operated Point to the variable address of QPRC last position counter. 0x80000000~0x7fffffff The maximum position counter for the rotor running a cycle. Description Below figure shows how QPRC position counter works. For the detailed description, please refer to the hardware manual. Below figure shows how QPRC revolution counter works. For the detailed description, please refer to the hardware manual. Below figure shows the QPRC configuration details. 44 FM3_AN706-00091-1v0-E, September 19, 2014 U S E R M A N U A L Figure 3-16: QPRC Configuration Example Special Result NA Use Case NA 3.6.4 AMC_Hall The HALL function returns the rotor angle and speed value in the PWC interrupt ISR generated by the hall input signal. Prototype void AMC_Hall(void); IO Parameters Note: there are so many variables used for the HALL function, most of the inner used variables are ignored in this table. The detailed description can be found in the H files ‘AMCLIB.h’ Structure Name stc_HallCapture_t cIsrEn I/O Data Type Range Description In char u8AStatu In unsigned char u8BStatu In unsigned char 0 or 1 Status on the Hall B Port u8CStatu In unsigned char 0 or 1 Status on the Hall B Port u8AllStatus Out unsigned char 0~7 Hall Status u8StatusNumber Out unsigned char 0~7 Hall status number cStatuRunFault Out char TRUE/FALSE Hall status fault flag cHallSearchComplete Out char TRUE/FALSE Hall search function doing over flags Out char TRUE/FALSE Hall status exception cStatuError stc_PosiCalHall_t u8AllStatus TRUE/FALSE The hall interrupt enable 0 or 1 Status on the Hall A Port Out unsigned char 0~7 Hall all status u8StatuFaultRecoverCnt Out unsigned char 0~255 Check recover i32Q22_CorrectAngle Out signed long 0~2 u32APulseWidth Out signed long 0~0x7fffffff record the A hall pulse count i32Q4_AHallSpd Out signed long 0~0x7fffffff Q4 format A hall speed i32Q4_SpdKts inner signed long 0~0x7fffffff Q4 format speed calculation factor cAPulseOver Out TRUE/FALSE The pulse count over flow flag stc_SpdCalHall_t September 19, 2014, FM3_AN706-00091-1v0-E char 22 status weather Hall search angle 45 U S E R M A N U A L Description The Hall function ‘AMC_Hall’ returns the rotor correct angle and speed by the PWC timer function (pulse width measurement function) through the hall signal. The output of this function is as the equation shows. 𝜔𝑟𝑎𝑑 = 𝐾𝑡/𝑇𝐻 𝜃𝑐𝑜𝑟𝑟𝑒𝑐𝑡 = 𝜃ℎ𝑎𝑙𝑙 Where: Kt is coefficient for speed calculation, TH is the time of half Hall cycle Figure 3-17 and Figure 3-18 can be taken for your reference for the Hall module. There are mainly three variables for the rotor angle and speed calculation shown as Figure 3-17. When the edge appears on any of the hall signal, the PWC interrupt is entered and the Hall function ‘AMC_Hall’ is called in the interrupt ISR. AMC_Hall 𝐻𝑎 Hall statues judge Posi_stcCalHall.i32 Q22_CorrectAngle 𝐻𝑏 Rotor correct angle 𝐻𝑐 Rotor real-time speed Posi_stcCalHall. u8AllStatus Spd_stcCalHall.u 32APulseWidth Figure 3-17: Hall Module Diagram Example: 010 110 6 5 4 3 2 1 101 : C statue<<2 | B statue<<1 | A statue 100 011 011 010 001 001 PWC ISR trigger by Hall 𝜃𝑐𝑜𝑟𝑟𝑒𝑐𝑡 = 𝜃ℎ𝑎𝑙𝑙 0 degree --------------> 360 degree 𝜔𝑟𝑎𝑑 = 𝐾𝑡/𝑇𝐻 𝜃𝑟𝑜𝑡𝑜𝑟 = 𝜃𝑐𝑜𝑟𝑟𝑒𝑐𝑡 + 𝜔𝑟𝑎𝑑 × 𝑡 Where: Kt is coefficient for speed calculation, 𝑇𝐻 is the time of the half cycle of Hall cycle 46 : 6 positions was known by hall interrupt FM3_AN706-00091-1v0-E, September 19, 2014 U S E R M A N U A L Figure 3-18: Correct Angle and Rotor Speed Generated by Hall Edge Interrupt Special Result NA Use Case /** initialize the port and key variable before the hall function is used */ /* 1. initialize the hall port and PWC peripheral at the power stage, function shown as following: AMC_HallInit() 2. initialize the key variables at the motor start initial, function shown as following Init_MMCL() */ __root void ISR_Base_Timer(void) { AMC_Hall(); //the rotor angle and speed will output after the function execution } September 19, 2014, FM3_AN706-00091-1v0-E 47 U S E R M A N U A L 4. Reference Documents [1]. Cortex-M3 r2p0 Technical Reference Manual, 2008 [2]. ARMv7-M Architecture Application Level Reference Manual, 2008 [3]. MB9BF500A-DS706-00021-1v0-E (MB9B500 Data Sheet) [4]. MB9Bxxx-MN706-00002-1v0-E (MB9Axxx/MB9Bxxx Series Peripheral Manual) 48 FM3_AN706-00091-1v0-E, September 19, 2014 U S E R M A N U A L 5. Additional Information For more Information on Spansion semiconductor products, visit the following websites: English version address: http://www.spansion.com/Products/microcontrollers/Pages/default.aspx Chinese version address: http://www.spansion.com/CN/Products/microcontrollers/Pages/index.aspx Please contact your local support team for any technical question America: [email protected] China: [email protected] Europe: [email protected] Japan: [email protected] Other: http://www.spansion.com/Support/SES/Pages/Ask-Spansion.aspx September 19, 2014, FM3_AN706-00091-1v0-E 49 U S E R M A N U A L 6. Appendix 6.1 Data Type Description The data types used in the MMCL are defined in the following table. Name 6.2 Description boolean_t basic boolean type int8_t signed 8-bit integer type unt8_t unsigned 8-bit integer type char_t signed 8-bit integer type int16_t signed 16-bit integer type uint16_t unsigned 16-bit integer type int32_t signed 32-bit integer type uint32_t unsigned 32-bit integer type Data Format Description There are many Qn formats in the motor control field. The typical data formats of common used variables are shown as following table. Type Format Description 8 Voltage Q8 2 =1V Current Q8 2 =1A Rotor Angle Q22 2 Rotor Speed Q8 8 22 8 =360 o 8 2 =1rpm or 2 =1Hz The other data format used in the sample project can take this table for the reference. 50 FM3_AN706-00091-1v0-E, September 19, 2014 U S E R M A N U A L AN706-00091-1v0-E Spansion Controller Manual FM3 Family 32-BIT MICROCONTROLLER MATH AND MOTOR CONTROL LIBRARY September 2014 Rev. 1.0 Published: Edited: Spansion Inc. Marketing Communications Dept. September 19, 2014, FM3_AN706-00091-1v0-E 51 U S E R M A N U A L Colophon The products described in this document are designed, developed and manufactured as contemplated for general use, including without limitation, ordinary industrial use, general office use, personal use, and household use, but are not designed, developed and manufactured as contemplated (1) for any use that includes fatal risks or dangers that, unless extremely high safety is secured, could have a serious effect to the public, and could lead directly to death, personal injury, severe physical damage or other loss (i.e., nuclear reaction control in nuclear facility, aircraft flight control, air traffic control, mass transport control, medical life support system, missile launch control in weapon system), or (2) for any use where chance of failure is intolerable (i.e., submersible repeater and artificial satellite). Please note that Spansion will not be liable to you and/or any third party for any claims or damages arising in connection with above-mentioned uses of the products. Any semiconductor devices have an inherent chance of failure. You must protect against injury, damage or loss from such failures by incorporating safety design measures into your facility and equipment such as redundancy, fire protection, and prevention of over-current levels and other abnormal operating conditions. If any products described in this document represent goods or technologies subject to certain restrictions on export under the Foreign Exchange and Foreign Trade Law of Japan, the US Export Administration Regulations or the applicable laws of any other country, the prior authorization by the respective government entity will be required for export of those products. Trademarks and Notice The contents of this document are subject to change without notice. This document may contain information on a Spansion product under development by Spansion. Spansion reserves the right to change or discontinue work on any product without notice. The information in this document is provided as is without warranty or guarantee of any kind as to its accuracy, completeness, operability, fitness for particular purpose, merchantability, non-infringement of third-party rights, or any other warranty, express, implied, or statutory. Spansion assumes no liability for any damages of any kind arising out of the use of the information in this document. ® ® ® TM Copyright © 2013 Spansion Inc. All rights reserved. Spansion , the Spansion logo, MirrorBit , MirrorBit Eclipse , TM ORNAND and combinations thereof, are trademarks and registered trademarks of Spansion LLC in the United States and other countries. Other names used are for informational purposes only and may be trademarks of their respective owners. 52 FM3_AN706-00091-1v0-E, September 19, 2014