Contenido principal

Estimate Control Gains and Tune Control Parameters

Tune speed and torque control loops that are part of the Field-Oriented Control (FOC) algorithm. You can choose from these methods to compute the control loop gains from the system or block transfer functions that are available for the motors, inverter, and controller:

  • Use the Field Oriented Control Autotuner block.

  • Use the FOC Default Controller Gains block.

  • Use Simulink® Control Design™.

  • Use the model initialization script.

To compute control loop gains, each method requires the following control parameters:

  • Motor, inverter, and target parameters

  • Control execution time

  • Delays and per-unit system values

Field-Oriented Control Autotuner

The Field-Oriented Control Autotuner block of Motor Control Blockset™ enables you to automatically tune the PID control loops in your Field-Oriented Control (FOC) application in real time. You can automatically tune the PID controllers associated with the following loops (for more details, see How to Use Field Oriented Control Autotuner Block):

  • Direct-axis (d-axis) current loop

  • Quadrature-axis (q-axis) current loop

  • Speed loop

For each loop that the block tunes, the Field-Oriented Control Autotuner block performs autotuning experiment in a closed-loop manner without using a parametric model associated with that loop. The block enables you to specify the order in which the block tunes the control loops. When the tuning experiment runs for one loop, the block has no effect on the other loops. For more details about FOC autotuner, see Field Oriented Control Autotuner and Tune PI Controllers Using Field Oriented Control Autotuner.

FOC Default Controller Gains Block

The FOC Default Controller Gains block of Motor Control Blockset enables you to integrate control gain calculations into the controller code. Using the library block, you can determine controller gains during runtime without recompiling the code when switching between different motor setups.

Simulink Control Design

Simulink Control Design enables you to design and analyze the control systems modeled in Simulink. You can automatically tune the arbitrary single-input, single-output (SISO) and multiple-input, multiple-output (MIMO) control architectures, including the PID controllers. You can deploy PID autotuning to the embedded software to automatically compute the PID gains in real time.

You can find the operating points and compute the exact linearizations of the Simulink models at different operating conditions. Simulink Control Design provides tools that let you compute the simulation-based frequency responses without modifying your model. For details, see Offline Frequency Response Estimation (Simulink Control Design).

Model Initialization Script

You can use the initialization scripts included with Motor Control Blockset examples to initialize the control parameters needed to estimate control gains. For a list of initialization functions, see Initialize Control Parameters. For a list of control gain estimation functions, see Compute Control Gains and Perform Control Analysis.

For example, for a PMSM that is connected to a quadrature encoder, these steps describe the procedure to initialize control parameters from the system details by using the initialization script:

  1. Open an example that uses an initialization script. For instance:

    openExample('mcb/FOCQepExample')

  2. Open the initialization script (.m) file of the example in MATLAB®. To find the associated script file name:

    1. Open the example model. Select Modeling > Model Settings > Model Properties. The Model Properties Dialog box opens.

    2. In the Model Properties dialog box, navigate to the Callbacks tab > InitFcn field. This field contains the name of the script that Simulink executes at the beginning of model compilation.

    This figure shows the contents of the mcb_pmsm_foc_qep_f28069m_data.m initialization script.

    Contents of script that initializes control parameters using utility functions

  3. Use the Workspace to edit the control variables values. For example, to update Stator resistance (Rs), use the variable pmsm to add the parameter value to the Rs field.

Initialize Control Parameters

The model initialization script associated with a target model calls these functions and sets up the workspace with the necessary variables.

Function Called By Model Initialization ScriptDescription
mcb.getPMSMParameters

Input to the function is the make and manufacturer name of the PMSM (for example, BLY171D).

The function returns a structure named pmsm in the MATLAB workspace, which is used by the model.

It also computes the permanent magnet flux and rated torque for the selected motor.

If you specify the name of a new motor, the function returns a pmsm structure with default values that you can configure with custom values.

This function also loads the structure motorParam, obtained by running parameter estimation, to the structure pmsm. If the structure motorParam is not available in the MATLAB workspace, the function loads the default parameters.

mcb.getACIMParameters

Input to the function is the make and manufacturer name of the ACIM (for example, EM_Synergy).

The function returns a structure named acim in the MATLAB workspace.

If you specify the name of a new motor, the function returns an acim structure with default values that you can configure with custom values.

This function also loads the structure motorParam, obtained by running parameter estimation, to the structure acim. If the structure motorParam is not available in the MATLAB workspace, the function loads the default parameters.

mcb.getInverterParameters

Input to the function is the make and manufacturer name of the inverter (for example, BoostXL-DRV8305).

The function returns a structure named inverter in the MATLAB workspace, which is used by the model.

The function also computes the inverter resistance for the selected inverter.

If you specify the name of a new inverter, the function returns an inverter structure with default values that you can configure with custom values.

mcb.getProcessorParameters

Inputs to the function are processor type (for example, F28379D) and the Pulse-Width Modulation (PWM) switching frequency.

The function returns a structure named target in the MATLAB workspace.

The function also computes the PWM counter period that is a parameter for the ePWM block in the target model.

mcb.getPUSystemParameters

Inputs to the function are motor and inverter parameters.

The function sets the base values of the per-unit system for voltage, current, speed, torque, and power.

The function returns a structure named PU_System in the MATLAB workspace, which is used by the model.

mcb.getSISystemParameters

Inputs to the function are motor and inverter parameters.

The function sets the base values of the SI system for voltage, current, speed, torque, and power.

The function returns a structure named SI_System in the MATLAB workspace, which is used by the model.

mcb.updateInverterParameters

Inputs to the function are motor and inverter parameters.

The function updates the inverter parameters based on the selected hardware and motor.

Note

For predefined processors and drivers, the model initialization script uses the default values.

Compute Control Gains and Perform Control Analysis

The model initialization script uses these functions to estimate the control gains needed to implement field-oriented control.

Computed Control Parameter CategoryFunctionFunctionality
Base speed of the motormcb.getMotorBaseSpeed

Calculates the base speed of PMSM at the rated voltage and rated load.

Base speed is the maximum motor speed at the rated voltage and rated load, outside the field-weakening region.

Motor characteristics for the given motor and invertermcb.PMSMCharacteristics

Obtain these drive characteristics of a PMSM motor.

  • Torque as opposed to speed characteristics

  • Power as opposed to speed characteristics

  • Idq as opposed to speed characteristics

  • Maximum phase current (Ipeak=Id2+Iq2) of the motor as opposed to speed characteristics

mcb.ACIMCharacteristics

Obtain these motor characteristics of an induction motor.

  • Torque as opposed to speed characteristics

  • Power as opposed to speed characteristics

Obtain these drive characteristics of an induction motor.

  • Torque as opposed to speed characteristics

  • Power as opposed to speed characteristics

  • Idq as opposed to speed characteristics

  • Maximum phase current (Ipeak=Id2+Iq2) of the motor as opposed to speed characteristics

Control algorithm parametersmcb.getPIControllerParameters

Compute the gains for these PI controllers:

  • Current (torque) control loop gains (Kp, Ki) for currents Id and Iq

  • Speed control loop gains (Kp, Ki)

  • Field weakening control gains (Kp, Ki)

To compute PI controller gains for a PMSM, use mcb.calcFOCGains instead.

mcb.calcFOCGains

Compute the gains and transfer functions for these PI controllers:

  • Current (torque) control loop gains (Kp, Ki) for currents Id and Iq

  • Speed control loop gains (Kp, Ki)

  • Field weakening control gains (Kp, Ki)

Control analysis for the motor and inverter you are usingmcb.getMotorControlAnalysis

Performs frequency domain analysis for the computed gains of PI controllers used in the field-oriented motor control system.

Note

This function requires Control System Toolbox™.

See Also

Topics