To design a speed control algorithm:
Add a speed controller for PMSM motor. Speed control loop outputs Iq_ref current and this is the input for the current controller.
In the Simulink library browser, select the Discrete PI controller with anti-windup & reset block from Motor Control Blockset/Controls/Controllers library.
The MATLAB function
mcb.internal.SetControllerParameters
calculates the
PI control gains for d and q axis current controller and speed controller.
For more details on control parameter gain estimation, refer to the section
Estimate Control Gains from Motor Parameters. Refer to
mcb_pmsm_foc_qep_f28379d_data.m
for Ts_speed (500
μs). Enable Data-store memory to reset the controller and this is
optional.
Create a subsystem for speed controller and add a rate-transition block to the inputs with sample time as Ts_speed (execution time of speed control loop).
Integrate the above speed controller that you designed with the current controller and plant integrated model. Connect Iq_ref_PU output from Speed controller to the current controller input through a rate-transition block as both are executing in different sample rates. The below figure shows the settings for the Rate-Transition block connected between the speed controller and current controller.