Main Content

Tune PI Controllers by Using Field Oriented Control Autotuner

This example computes the gain values of the PI controllers within the speed and current controllers by using the Field Oriented Control Autotuner block. For details about field-oriented control, see Field-Oriented Control (FOC).

The example supports simulation only. When you simulate the example, the model uses the crude values of gains for the PI controllers to achieve the steady state of speed-control operation.

The model begins tuning only in the steady state. It introduces disturbances depending on the controller goals (bandwidth and phase margin), in the controller output. The model uses the system response to the disturbances, to calculate the optimal controller gain.

Model

The example includes this model:

  • mcb_pmsm_foc_autotuner

You can use this model only for simulation. You can use the open_system command to open the Simulink® model:

open_system('mcb_pmsm_foc_autotuner.slx');

Required MathWorks® Products for Simulation

  • Motor Control Blockset™

  • Simulink Control Design™

Prerequisites

1. Obtain the motor parameters. We provide default motor parameters with the Simulink® model that you can replace with the values from either the motor datasheet or other sources.

However, if you have the motor control hardware, you can estimate the parameters for the motor that you want to use, by using the Motor Control Blockset parameter estimation tool. For instructions, see Estimate Motor Parameters by Using Motor Control Blockset Parameter Estimation Tool.

The parameter estimation tool updates the motorParam variable (in the MATLAB® workspace) with the estimated motor parameters.

2. If you obtain the motor parameters from the datasheet or other sources, update the motor parameters and inverter parameters in the model initialization script associated with the Simulink® models. For instructions, see Estimate Control Gains from Motor Parameters.

If you use the parameter estimation tool, you can update the inverter parameters, but do not update the motor parameters in the model initialization script. The script automatically extracts motor parameters from the updated motorParam workspace variable.

Note: In addition to the preceding products, you also need these products to use the parameter estimation tool:

  • Embedded Coder®

  • Embedded Coder® Support Package for Texas Instruments™ C2000™ Processors

Simulate and Run Model to Compute PI Controller Gains

1. Open the target model.

2. Click Run on the Simulation tab to simulate the target model.

3. Observe the computed PI controller gain values in the Display blocks available in the PI_Params_Display_and_Logging subsystem.

4. Update any target model with these gain values so that it brings the motor to a steady-speed state quickly.