Now I need to use MC9S12ZVM to run my motor above the electric speed of 50,000 RPM, but the maximum value of the 16-bit mathematical library is around 32000. Could you please provide the code of AMCLIB_BemfObsrvDQ function for me to modify? Thank you! I wrote my own code using the model block diagram above AMCLIB_BemfObsrvDQ parameters, but failed.
Hi,
I believe you would need to understand Fraction arithmetics first (Q1.15). With that understood, you will find that there is no speed limit of such algorithm.
Just a hint:
if you follow the AppNote for S12ZVM (https://www.nxp.com/docs/en/application-note/AN5135.pdf or https://www.nxp.com/docs/en/application-note/AN5327.pdf), you'll find that there is max speed settings in the FreeMASTER / MCAT window, which is propagated into the appconfig.h. This is the scale you can change according to your application using MCAT. Then, the entire algorithm will use this scale to run your motor.
To understand better:
Frac16 number is internally stored as 16-bit signed int. All the AMMCLib functions are working with those numbers.
Then you have to understand that numbers from -32768 to +32767 are just interpreted into range of -1.0 to 1.0. All the equations in the FOC algorithm in Frac16 must be "scaled" or "normalized" using fixed scales or maximums of each variable. And this is basically the link to the appconfig.h and its configuration. If your maximum speed is 50,000 RPM, then the algorithm will scale the equations to this speed. That would mean that 50,000 RPM is represented by 1.0, which is internally stored as 32767. Now, it is highly recommended to use higher number for scaling to create some space for the operational range of the algorithm (so the PI controllers won't saturate during the control process) - in your case I would set 60,000 RPM as the scale.
FreeMASTER and MCAT interface is working with the Frac16 numbers, but it also does recalc using the scales (you can find the settings in the variable settings window of each individual variable in the watch).
NOTE: the speed you are referring to is quite high. Please consider the pole-pair number of your motor and resulting resolution of the output sine wave at max. speed. Considering S12ZVM, typical sampling frequency is 10kHz (since the FOC algorithm may take approx 60us out of 100us sampling window). At 50,000 RPM, the stator frequency for 1-pole-pair motor is 833 Hz. With 10kHz sampling frequency, the sine wave will be created using 12 discrete steps (six levels in each polarity). If your motor is 2-pole-pair, you would need 1,667 Hz stator frequency, resulting in sine wave created out of 6 discrete steps. In that case, I would recommend to use six-step or 12-step commutation instead, which is similar in terms of quality of voltage and less CPU demanding that the FOC algorithm. Also, FOC algorithm may become instable when controlling a motor of 1,667 Hz stator frequency using just 10kHz sampling.
Hope it helps
Matej
Hi 872454246,
Sorry the library code is not available but please look at the installed:
c:\NXP\AMMCLIB\MC9S12ZVM_AMMCLIB_v1.1.25\doc\MC9S12ZVMMCLUG.pdf
Section 2.2. If you use the fractional arithmetic it should be OK even for higher rotation speed. But the rotation speed >50k is relative high and it depends on the control loop speed.
Best Regards,
Stano.