Main Content

Design Speed Control Algorithm

To design a speed control algorithm:

  1. Create a speed controller subsystem. The Iq_ref current output of the speed controller subsystem is used as an input to the current controller subsystem that you created earlier.

    To create a speed controller subsystem, from the Simulink® Library Browser, select the Discrete PI Controller with anti-windup & reset block from the Motor Control Blockset/Controls/Controllers library.

    The MATLAB® function mcb.internal.SetControllerParameters (in the model initialization script) calculates the PI control gains for the d-axis and q-axis current controller and speed controller. For details regarding the control parameter gain estimation, see Estimate Control Gains from Motor Parameters. See the model initialization script file mcb_pmsm_foc_qep_f28379d_data.m (used in the example Field-Oriented Control of PMSM Using Quadrature Encoder) for the sampling time (Ts_speed) of 500μs. Use Enable Data-Store Memory block to reset the controller but this is optional.

  2. Create a subsystem for the speed controller and add a Rate Transition block ( from the Simulink/Signal Attributes library) to the inputs with the sample time as Ts_speed (execution time of the speed control loop).

  3. Integrate the Speed Controller subsystem with the integrated Current Controller and plant model subsystems. Connect the Iq_ref_PU output port of the Speed Controller subsystem to the Current Controller subsystem input port through a Rate Transition block as both ports execute in different sample rates. This figure shows an example of settings of the Rate Transition block connected to the Speed Controller and Current Controller subsystems.

    This figure shows the integrated Speed Controller, Current Controller, and plant model subsystems.