Design Current Controller Subsystem

  1. From the Motor Control Blockset™library in Simulink Library browser, use the Discrete PI controller with anti-windup & reset block (under /Controls/Controllers library), for designing d-axis and q-axis current control.

    The MATLAB function mcb.internal.SetControllerParameters calculates the PI control gains for d and q axis current controller and speed controller. For details on control parameter gain estimation, refer to Estimate Control Gains from Motor Parameters. Refer to the file mcb_pmsm_foc_qep_f28379d_data.m for Ts (50 μs).

    The Enable variable is Data-store memory to reset the controller and this is optional.

    Create a subsystem (Current_Controllers) for d-axis and q-axis PI controllers for controlling the d-axis and q-axis current.

  2. Add the blocks Clarke Transform, Park Transform, Inverse Park Transform, and Space Vector Generator from Motor Control Blockset/Controls/Math Transforms to the Current_controllers subsystem (from previous step) as shown in this figure:

  3. Create a subsystem named Closed Loop Control as shown in this figure:

  4. Create subsystem for scaling the PWM outputs. This subsystem outputs normalized PWM duty (0-1) for the plant model.

  5. Integrate the Current scaling, QEP position decoding, Closed Loop Control, and Output Scaling logic. Add trigger from Simulink\Ports & Subsystems to the subsystem and select the Trigger type as function-call.

  6. Integrate the current controller to form a subsystem. Add Function-Call Generator from Simulink/Ports & Subsystems. In Function-Call Generator dialog, enter Sample time as the control-loop sample time Ts (default 50e-6 s).

  7. Integrate the plant model and controller. For detailed steps on how to create a plant model for motor control system, refer to Creating Plant Model Using Motor Control Blockset.