2.2.1.2 Motor Control and Diagnosis

Proper and optimal control of a motor requires tuning various parameters such as PI controllers, PWM modulators, and other settings based on your specific project requirements. Refer to Field Oriented Control for more details.

The Motor Control and Diagnosis GUI enables users to configure the following settings:

Graphical User Interface

Control Type

The Control Type feature allows users to choose the control mode for the motor. Follow the steps to select the control type:

  1. Select the control mode in control type drop-down menu.
    • Open Loop Control: This mode operates the motor without position feedback. This mode is used for debugging purposes.
    • Torque Control: This mode controls the motor torque directly.
    • Speed Control: This mode maintains a desired motor speed for applications where speed regulation is critical.
    • Position Control: This mode controls the motor position for applications requiring precise positioning.

Ramp Profiler

The Ramp Profiler feature allows users to configure the input reference for the controller. It provides a smooth transition for the motor's speed or position by gradually increasing or decreasing the reference value. This helps in avoiding sudden changes that could cause mechanical stress or instability.

Follow the steps below to configure the ramp profiler:

  1. Click on the Ramp Profiler block to configure the ramp profiler.
  2. Select the ramp type: Step or Linear.
  3. If the linear profile is selected, configure the linear ramp profile:
FieldsDescription
Ramp rate (RPM/s)Set ramp rate in RPM per second

Position Loop PID Controller

The Position Loop PID Controller is used to control the motor's position. It uses a Proportional-Integral-Derivative (PID) algorithm to minimize the error between the desired and actual positions. Users can configure the PID parameters to achieve the desired response.

Follow the steps below to configure the position PID controller:

  1. Click on the Position PID block to configure the position PID controller.
  2. Set the following fields in the configuration panel:
FieldsDescription
Anti-windupSelect anti-windup method: Integral Clamp or Back Calculation
KpSet proportional gain value
KiSet integral gain value
KcSet anti-windup gain value (only applicable if Back Calculation is selected for anti-windup)
Maximum integralSet integral clamp value (only applicable if Integral Clamp is selected for anti-windup)
Maximum outputSet maximum PID controller output

Speed Loop PID Controller

The Speed Loop PID Controller is used to control the motor's speed. It uses a PID algorithm to minimize the error between the desired and actual speeds. Users can configure the PID parameters to achieve the desired speed response.

Follow the steps below to configure the speed PID controller:

  1. Click on the Speed PID block to configure the speed PID controller.
  2. Set the following fields in the configuration panel:
FieldsDescription
Anti-windupSelect anti-windup method: Integral Clamp or Back Calculation
KpSet proportional gain value
KiSet integral gain value
KcSet anti-windup gain value (only applicable if Back Calculation is selected for anti-windup)
Maximum integralSet integral clamp value (only applicable if Integral Clamp is selected for anti-windup)
Maximum outputSet maximum PID controller output

Torque Loop PID Controller

The Torque Loop PID Controller is used to control the motor's torque. It uses a PID algorithm to minimize the error between the desired and actual torque. Users can configure the PID parameters to achieve the desired torque response.

Follow the steps below to configure the torque PID controller:

  1. Click on the Torque PID block to configure the torque PID controller.
  2. Set the following fields in the configuration panel:
FieldsDescription
Anti-windupSelect anti-windup method: Integral Clamp or Back Calculation
KpSet proportional gain value
KiSet integral gain value
KcSet anti-windup gain value (only applicable if Back Calculation is selected for anti-windup)
Maximum integralSet integral clamp value (only applicable if Integral Clamp is selected for anti-windup)
Maximum outputSet maximum PID controller output

Flux Loop PID Controller

The Flux Loop PID Controller is used to control the motor's magnetic flux. It uses a PID algorithm to minimize the error between the desired and actual flux. Users can configure the PID parameters to achieve the desired flux response.

Follow the steps below to configure the flux PID controller:

  1. Click on the Flux PID block to configure the flux PID controller.
  2. Set the following fields in the configuration panel:
FieldsDescription
Anti-windupSelect anti-windup method: Integral Clamp or Back Calculation
KpSet proportional gain value
KiSet integral gain value
KcSet anti-windup gain value (only applicable if Back Calculation is selected for anti-windup)
Maximum integralSet integral clamp value (only applicable if Integral Clamp is selected for anti-windup)
Maximum outputSet maximum PID controller output

Maximum Torque Per Ampere (MTPA) and Field Weakening (FW)

The Maximum Torque Per Ampere (MTPA) and Field Weakening (FW) features optimize the motor's performance.

Follow the steps below to configure the MTPA and FW:

  1. Click on the FW and MTPA block to enable/disable field weakening (FW) and Maximum Torque Per Ampere (MTPA).
  2. Set the following fields in the configuration panel:
FieldsDescription
Enable field weakeningEnable field weakening
Enable MTPAEnable MTPA

Decoupling Network

This module is disabled for future use.

PWM Modulator

The PWM Modulator feature generates Pulse Width Modulation (PWM) signals to drive the motor. Users can configure the PWM parameters to achieve the desired switching frequency and duty cycle, ensuring efficient and smooth motor operation.

Follow the steps below to configure the PWM modulator:

  1. Click on the PWM Modulator block to set over-modulation.
  2. Set the following fields in the configuration panel:
FieldsDescription
Enable over modulationEnable over modulation

Model-Based Development

The Model-Based Development option generates only the wrapper files necessary for integration, leaving the development of motor control logic to the user. This approach leverages the X2C Model-Based Design framework, providing flexibility to create custom control algorithms.

For further information, refer to X2C Model-Based Development with QSpin.