- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
I'm designing a BLDC driver ,with Automotive Math and Motor Control
Library Set for NXP MC9S12ZVM。
I have three questions about Function GFLIB_ControllerPIrAW。
1、Are there three functions here, and what is the relationship between them
(1)Function GFLIB_ControllerPIrAW;
(2)Function GFLIB_ControllerPIrAW_F32;
(3)Function GFLIB_ControllerPIrAW_F16;
2、How to distinguish "differentiation methods"?
(1) “Trapezoidal”,
(2)“Backward Rect”,
(3)“Forward Rect”
Which one is used in “S12ZVML-MINIBRD_BLDC_Sensorless_CW_IDE” ?
I think it's using the “Forward Rect”,then,But put the parameters in the formula
The result is
u(k) = u(k-1) + KP*(e(k)-e(k-1)) + KI*Ts*e(k-1),
However,The standard formula of discrete PI is
u(k) = u(k-1) + KP*(e(k)-e(k-1)) + KI*Ts*e(k),
The two formulas are not the same. Is there something wrong with my deduction
3、 What is the specific meaning of f32acc and f16inerrk1?
f32acc
f16inerrk1
There is no detailed description of the document, which I can't understand
Hope to get the help of experts, thank you very much!
Solved! Go to Solution.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi maxxu,
the difference between GFLIB_ControllerPIrAW, GFLIB_ControllerPIrAW_F16, and GFLIB_ControllerPIrAW_F32 is described in the AMMCLib User's Guide, chapter 1.3 "Multiple Implementation Support". We recommend to use the F16 implementation on S12ZVM since it is the fastest.
Parameters of the AMMCLib function GFLIB_ControllerPIrAW can be calculated using any of the discretization methods: trapezoidal, backward rectangular, and forward rectangular. Table 119 in the chapter 2.22 "Function GFLIB_ControllerPIrAW" in the AMMCLib User's Guide specifies how to calculate coefficients CC1 and CC2 with each of the three discretization methods.
For example, the coefficients for the backward rectangular method are listed as
If you substitute CC1 and CC2 in the equation GFLIB_ControllerPIrAW_Eq3, you get
which corresponds to what you call "standard formula of discrete PI".
If you know the desired gains Kp and Ki and the sampling period Ts, you can use any of the discretization methods to calculate the constants CC1 and CC2. The microcontroller will run the same program regardless of which discretization method you use - it is a design consideration, not a program feature. The example code for S12ZVML-MINIBRD_BLDC_Sensorless_CW_IDE comes with a set of numerical values for constants CC1 and CC2 without specifying what particular method was used to design them.
Tuning of the controller parameters can be done conveniently during the run of the motor using the FreeMASTER tool with the preset S12ZVMLMINIBRD_BLDC_SW_CW11.pmp which is provided in the S12ZVM Mini Board SW package.
Function GFLIB_ControllerPIrAW_F16 keeps its state variables in a structure pointed to by the API pointer pParam. The description of the function API in chapter 2.22.2 "Function GFLIB_ControllerPIrAW_F16" in the AMMCLib User's Guide specifies the type of this pointer GFLIB_CONTROLLER_PIAW_R_T_F16. You can simply click on this type in the Table 121, which will bring you the chapter 5.55 which provides detailed description of the structure members:
Type |
Name |
Description |
tFrac32 |
f32Acc |
State variable - internal controller |
tFrac16 |
f16InErrK1 |
State variable - controller input from the |
These state variables are automatically initialized when you call function GFLIB_ControllerPIrAWInit, see chapter 2.22.3 for details.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi maxxu,
the difference between GFLIB_ControllerPIrAW, GFLIB_ControllerPIrAW_F16, and GFLIB_ControllerPIrAW_F32 is described in the AMMCLib User's Guide, chapter 1.3 "Multiple Implementation Support". We recommend to use the F16 implementation on S12ZVM since it is the fastest.
Parameters of the AMMCLib function GFLIB_ControllerPIrAW can be calculated using any of the discretization methods: trapezoidal, backward rectangular, and forward rectangular. Table 119 in the chapter 2.22 "Function GFLIB_ControllerPIrAW" in the AMMCLib User's Guide specifies how to calculate coefficients CC1 and CC2 with each of the three discretization methods.
For example, the coefficients for the backward rectangular method are listed as
If you substitute CC1 and CC2 in the equation GFLIB_ControllerPIrAW_Eq3, you get
which corresponds to what you call "standard formula of discrete PI".
If you know the desired gains Kp and Ki and the sampling period Ts, you can use any of the discretization methods to calculate the constants CC1 and CC2. The microcontroller will run the same program regardless of which discretization method you use - it is a design consideration, not a program feature. The example code for S12ZVML-MINIBRD_BLDC_Sensorless_CW_IDE comes with a set of numerical values for constants CC1 and CC2 without specifying what particular method was used to design them.
Tuning of the controller parameters can be done conveniently during the run of the motor using the FreeMASTER tool with the preset S12ZVMLMINIBRD_BLDC_SW_CW11.pmp which is provided in the S12ZVM Mini Board SW package.
Function GFLIB_ControllerPIrAW_F16 keeps its state variables in a structure pointed to by the API pointer pParam. The description of the function API in chapter 2.22.2 "Function GFLIB_ControllerPIrAW_F16" in the AMMCLib User's Guide specifies the type of this pointer GFLIB_CONTROLLER_PIAW_R_T_F16. You can simply click on this type in the Table 121, which will bring you the chapter 5.55 which provides detailed description of the structure members:
Type |
Name |
Description |
tFrac32 |
f32Acc |
State variable - internal controller |
tFrac16 |
f16InErrK1 |
State variable - controller input from the |
These state variables are automatically initialized when you call function GFLIB_ControllerPIrAWInit, see chapter 2.22.3 for details.
