Main Content

Prepare Target Hardware

Follow these steps to prepare the target hardware before you deploy the control algorithm developed using Motor Control Blockset™ to it.

Note

You need C2000™ Microcontroller Blockset to run these steps.

We recommend that you see these references before following this procedure:

In addition, try running the motor using open-loop control first using the Run 3-Phase AC Motors in Open-Loop Control and Calibrate ADC Offset example.

Verify Direction of Rotation of Motor

The phase sequence of the motor connection in the target hardware determines the direction of rotation of the motor. The Motor Control Blockset example models consider the direction of rotation during the position ramp-up as a positive direction and the corresponding measured speed as positive. It is recommended that you run the motor in open-loop control with a position ramp from 0 to 1 and ensure that the position feedback is positive. The example models in Motor Control Blockset use this convention for the motor's direction of rotation.

For the supported hardware, the algorithm in the example Quadrature Encoder Offset Calibration for PMSM, runs the motor and finds the offset between the d-axis of the rotor and the encoder index pulse (when the rotor is aligned to the d-axis of the stator). The red LED in the host model for this example turns on when the direction of rotation is opposite. When this happens, you should change the phase sequence of the motor wiring (swap any two motor wires).

See the example Hall Offset Calibration for PMSM to identify the direction of rotation of a motor that uses Hall sensors.

Note

When you use a Hall sensor, ensure that the Hall sequence updated in the Hall Speed and Position and Hall Validity blocks matches the sequence of the actual Hall signals. If you update an incorrect Hall sequence, the direction read by the target hardware is the opposite of the actual direction.

Calibrate Current Sensor

The signal conditioning circuits for the current sensor introduces a voltage offset in the analog to digital converter (ADC) input when measuring both the positive and negative current. For example, an ADC with a voltage reference of 3.3 V can have an offset of 1.65 V when using the Texas Instruments® BOOSTXL-DRV8305 hardware. This offset varies due to tolerances of the passive components available in the signal conditioning circuit. It is recommended that you measure the ADC offset of the hardware during initialization.

The hardware initialization subsystem, which is used in the majority of Motor Control Blockset example models, computes the average current sensor ADC values and uses them as ADC offset values for measuring the current. The subsystem represents the ADC offset values in ADC counts.

See the example Run 3-Phase AC Motors in Open-Loop Control and Calibrate ADC Offset to manually calibrate the ADC offset and update the computed offset value in the model initialization script file.

See the Hardware Init subsystem available in the example Field-Oriented Control of PMSM Using Quadrature Encoder to understand the ADC offset calculations that the example model performs before starting the closed-loop motor control.

Calibrate Position Sensor

For a PMSM, the position used in the current control algorithm should align with the d-axis position of the rotor. By default, the quadrature encoder position sensor reads the mechanical position of the rotor with reference to its index pulse. The position offset is the position read by the quadrature encoder when d-axis of the rotor aligns with phase a. To obtain an accurate motor position, use this position offset value to correct the position read by the quadrature encoder sensor. Then provide the corrected motor position value as an input to the current control algorithm.

A mismatch between the actual rotor position and the position provided to the current controller affects the motor functionality and performance.

For more details, see the examples Quadrature Encoder Offset Calibration for PMSM and Hall Offset Calibration for PMSM.