To run the model on the hardware the next steps should be followed:
|Fig. 1: Sensorless Speed Control of PMSM Simulink Model|
The main difference between this model and the one one shown in Fig. 34 within Module 8: Speed Control is the fact that actual motor speed is estimated in the Fast Loop rather than being estimated based on Hall Sensor transitions.
Slow Loop Subsystem
The Slow Loop subsystem has been slightly updated to reflect better the operations that takes place at each 1ms interrupt.
|Fig. 2: Slow Loop Subsystem|
As shown in Fig. 2, the first operation is to deal with the Speed Reference profile during acceleration and deceleration regimes. The next operation is to compute the torque command based on a Speed Controller. In parallel with the speed controller we need to monitor the Speed Reference to select the mode of operation: open loop, tracking mode and closed loop. This information is need to switch from open loop to closed loop operation. The last operation done in Slow Loop is the Alignment procedure which is done only at startup.
In this subsystem the major modifications made compared with previous model in Fig. 33 within Module 8: Speed Control are:
|Fig. 3: Speed Controller Subsystem|
Fast Loop Subsystem
The fast loop subsystem has been optimized further for getting the best possible performance and to keep some tuning options available. Compared with Fig. 30 in Module 8: Speed Control the new model adds 2 new subsystems highlighted below in blue foreground: Rotor Position and BackEMF Observer
|Fig. 4: Fast Loop Subsystem|
The BackEMF Observer subsystem implements the model shown in Fig. 9 within Module 9: Position Observer (Part 1/2) but this time directly in floating point using the dedicated Automotive Math and Motor Control Library Set | NXP functions: AMCLIB_BemfObsrvDQ and AMCLIB_TrackObsrv
|Fig. 5: Speed and Position Observers|
The parameters for these observers are computed according with the guidelines from the AMMCLIB User Manual.
The other subsystem that has been modified is the Rotor Position, that handles the merging speed/angle between the open loop, tracking and closed loop modes of operation.
|Fig. 6: Speed and Position Observers|
In case of the closed loop operation, due to the delays added by the estimation procedure, we need to compensate for the the rotor phase advance from the moment we read the current/voltages and the moment we are ready to apply the new command voltages. During the computations the rotor will advance with some degrees depending on the commanded speed, hence the new angle needs to be advanced forwards.
|Fig. 7: Control system response at startup and change of speeds|
Further investigations and tuning may be deployed to achieved the best system stability. Fig. 8, shows the BackEMF observer output during startup of PMSM and show fast the estimator can cope with changes in the motor speed commands.
|Fig. 8: Rotor Position and Speed Estimation during startup of PMSM|
Keep in mind that there are multiple parameters that influence the system response, hence you need to have an holistic view of the entire system. Fig. 9 shows how the current controllers behaves during startup (from 5 to 8 sec on the scope) and then during acceleration regime.
|Fig. 9: Flux and Torque current controllers responses|
|Fig. 10: Transition from open to closed loop|
Once you have the system up and running, then is time for another settings or improvements. Tune the Speed and Current Controllers to deal with the system dynamics and loads.
If you run into issues with this particular sensorless application then perhaps you wish to have a look to other implementations too like the S32K144 Development Kit for 3-phase PMSM | NXP Reference Design.
If you have other ideas for improvements, let us know as comments below. We look forward to see more applications implemented on top of Model-Based Design Toolbox | NXP and show cased here in this community.
I noticed that the position observer implementation in the final model is different from from the one in M9. Is there a reason? I tried both of them in an S32K144 project and I can't get the M10 version to work, whereas the M9 one seems to work as expected under the same conditions. Are they supposed to work in same way?
Thank you and best regards!
Hi @dumitru-daniel_ ,
I have version 4.2 of the MBDT and the mcspte1ak144 development kit. When I open the model in M10_Sensorless.zip, all of the toolbox functions are unlinked and broken. Is there a way that either you can port the model over to version 4.2?
Alternatively, what would happen if I also install v. 4.1? would I be able to then open the model and replace the functions one by one with their 4.2 counterparts? Any help would be appreciated. Thank you for the very educational course!
Specifically I get this error when loading the model:
Failure in mbd_s32k_convert_mdl_to_latest_version: Unable to find system or file 'ammclib_bam_s32k14x'. The closest match is 'ammclib_bam_S32K14x' in 'C:\Users\mark.palframan\AppData\Roaming\MathWorks\MATLAB Add-Ons\Toolboxes\NXP_MBDToolbox_S32K1xx\mbdtbx_s32k14x\AMMCLIB_s32k14x\bam\ammclib_bam_S32K14x.slx'.
Thank you for your help.
The speed detected with respect to the command value is reversed when viewed with Freemaster.
Speed adjustment is also not possible.
Hall sensor is not connected.
The MATLAB I am using is R2019A.
The detected speed - can't be changed. It is a value computed by the observer at each 100ms.
The motor speed can be changed via:
In general all the variables can be converted from read-only to read/write from Variable/Modifying tab
In this example there is no hall sensor needed - the rotor angle estimation requires only the i_a/i_b phase currents and control voltages u_alpha and u_beta. In M8 we use the hall sensor to estimate the speed because the motor do not have an encoder. If you have motor with any other type of sensor mounted - then it would be much more easier and more robust to build a motor control application.