Main Content

Run 3-Phase AC Motors in Open-Loop Control and Calibrate ADC Offset

This example uses open-loop control (also known as scalar control or Volts/Hz control) to run a motor. This technique varies the stator voltage and frequency to control the rotor speed without using any feedback from the motor. You can use this technique to check the integrity of the hardware connections. A constant speed application of open-loop control uses a fixed-frequency motor power supply. An adjustable speed application of open-loop control needs a variable-frequency power supply to control the rotor speed. To ensure a constant stator magnetic flux, keep the supply voltage amplitude proportional to its frequency.

Open-loop motor control does not have the ability to consider the external conditions that can affect the motor speed. Therefore, the control system cannot automatically correct the deviation between the desired and the actual motor speed.

This model runs the motor by using an open-loop motor control algorithm. The model helps you get started with Motor Control Blockset™ and verify the hardware setup by running the motor. The target model algorithm also reads the ADC values from the current sensors and sends these values to the host model by using serial communication.

You can use this model to:

  • Check connectivity with the target.

  • Check serial communication with the target.

  • Verify the hardware and software environment.

  • Check ADC offsets for current sensors.

  • Run a new motor with an inverter and target setup for the first time.

Models

The example includes these models:

You can use these models for both simulation and code generation.

For the model names that you can use for different hardware configurations, see the Required Hardware topic in the Generate Code and Deploy Model to Target Hardware section.

Required MathWorks Products

To simulate model:

1. For the models: mcb_open_loop_control_f28069M_DRV8312 and mcb_open_loop_control_f28069MLaunchPad

  • Motor Control Blockset™

  • Fixed-Point Designer™

2. For the model: mcb_open_loop_control_f28379d

  • Motor Control Blockset™

To generate code and deploy model:

1. For the models: mcb_open_loop_control_f28069M_DRV8312 and mcb_open_loop_control_f28069MLaunchPad

  • Motor Control Blockset™

  • Embedded Coder®

  • C2000™ Microcontroller Blockset

  • Fixed-Point Designer™

2. For the model: mcb_open_loop_control_f28379d

  • Motor Control Blockset™

  • Embedded Coder®

  • C2000™ Microcontroller Blockset

  • Fixed-Point Designer™ (only needed for optimized code generation)

Prerequisites

1. For BOOSTXL-DRV8323, use these steps to update the model:

  • Navigate to this path in the model: /Open Loop Control/Codegen/Hardware Initialization.

  • For LAUNCHXL-F28379D: Update DRV830x Enable block from GPIO124 to GPIO67.

  • For LAUNCHXL-F28069M: Update DRV830x Enable block from GPIO50 to GPIO12.

2. For BOOSTXL-3PHGANINV, use these steps to update the model:

  • For LAUNCHXL-F28379D: In the Configuration panel of mcb_open_loop_control_f28379d, set Inverter Enable Logic to Active Low.

NOTE: When using BOOSTXL-3PHGANINV inverter, ensure that proper insulation is available between bottom layer of BOOSTXL-3PHGANINV and the LAUNCHXL board.

Simulate Model

This example supports simulation. Follow these steps to simulate the model.

1. Open a model included with this example.

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

3. Click Data Inspector on the Simulation tab to view and analyze the simulation results.

Generate Code and Deploy Model to Target Hardware

This section instructs you to generate code and run the motor by using open-loop control.

The example uses a host and a target model. The host model is a user interface to the controller hardware board. You can run the host model on the host computer. The prerequisite to use the host model is to deploy the target model to the controller hardware board. The host model uses serial communication to command the target Simulink® model and run the motor in a closed-loop control.

Required Hardware

This example supports these hardware configurations. You can also use the target model name to open the model for the corresponding hardware configuration, from the MATLAB® command prompt.

For connections related to the preceding hardware configuration, see F28069 control card configuration.

  • LAUNCHXL-F28379D controller + (BOOSTXL-DRV8301 or BOOSTXL-DRV8305 or BOOSTXL-DRV8323 or BOOSTXL-3PHGANINV) inverter: mcb_open_loop_control_f28379d

To configure the model mcb_open_loop_control_f28379d, set the Inverter Enable Logic field (in the Configuration panel of target model) to:

  • Active High: To use the model with BOOSTXL-DRV8301 or BOOSTXL-DRV8305 or BOOSTXL-DRV8323 inverter.

  • Active Low: To use the model with BOOSTXL-3PHGANINV inverter.

For connections related to the preceding hardware configurations, see LAUNCHXL-F28069M and LAUNCHXL-F28379D Configurations.

NOTE:

  • This example supports any type of three-phase AC motor (PMSM or induction) and any type of inverter attached to the supported hardware.

  • Some PMSMs do not run at higher speeds, especially when the shaft is loaded. To resolve this issue, you should apply more voltages corresponding to a given frequency. You can use these steps to increase the applied voltages in the model:

1. Navigate to this path in the model: /Open Loop Control/Control_System/VabcCalc/.

2. Update the gain Correction_Factor_sinePWM as 20%.

3. For safety reasons, regularly monitor the motor shaft, motor current, and motor temperature.

Generate Code and Run Model to Implement Open-Loop Control

1. Simulate the target model and observe the simulation results.

2. Complete the hardware connections.

3. Open the target model for the hardware configuration that you want to use. If you want to change the default hardware configuration settings for the target model, see Model Configuration Parameters.

4. Update these motor parameters in the Configuration panel of the target model.

  • Number of Pole Pairs

  • PWM Frequency [Hz]

  • Base Speed [RPM]

  • Data type for control algorithm

  • Inverter Enable Logic (only available in mcb_open_loop_control_f28379d target model)

5. Load a sample program to CPU2 of LAUNCHXL-F28379D, for example, a program that operates the CPU2 blue LED by using GPIO31 (c28379D_cpu2_blink.slx), to ensure that CPU2 is not mistakenly configured to use the board peripherals intended for CPU1. For more information about the sample program (model), see the Task 2 - Create, Configure and Run the Model for TI Delfino F28379D LaunchPad (Dual Core) section in Getting Started with Texas Instruments C2000 Microcontroller Blockset (C2000 Microcontroller Blockset).

6. Click Build, Deploy & Start on the Hardware tab to deploy the target model to the hardware.

NOTE: Ignore the warning message "Multitask data store option in the Diagnostics page of the Configuration Parameter Dialog is none" displayed by the model advisor, by clicking the Always Ignore button. This is part of the intended workflow.

7. Click the host model hyperlink in the target model to open the associated host model.

For details about the serial communication between the host and target models, see Host-Target Communication.

8. Select a target (either TI F28069M, TI F28379D, or Other) in the Target Selection area of the host model.

NOTE: If you select Other, you can enter the Baud rate for the target hardware that you are using, in the Host Serial Setup block parameter dialog box.

9. In the host model, open the blocks Host Serial Setup, Host Serial Receive, and Host Serial Transmit, and select a Port.

10. Enter the Reference Speed value in the host model.

11. Click Run on the Simulation tab to run the host model.

12. Change the position of the Start / Stop Motor switch to On, to start running the motor.

13. After the motor is running, observe the ADC counts for the ${I_a}$ and ${I_b}$ currents in the Time Scope.

NOTE: This example may not allow the motor to run at full capacity. Begin running the motor at a small speed. In addition, it is recommended to change the Reference Speed in small steps (for example, for a motor having a base speed of 3000 rpm, start running the motor at 500 rpm and then increase or decrease the speed in steps of 200 rpm).

If the motor does not run, change the position of the Start / Stop Motor switch to Off, to stop the motor and change the Reference Speed in the host model. Then, change the position of the Start / Stop Motor switch to On, to run the motor again.

Generate Code and Run Model to Calibrate ADC Offset

1. Simulate the target model and observe the simulation results.

2. Complete the hardware connections.

3. Disconnect the motor wires for three phases from the hardware board terminals.

4. Open the target model for the hardware configuration that you want to use. If you want to change the default hardware configuration settings for the target model, see Model Configuration Parameters.

5. Load a sample program to CPU2 of LAUNCHXL-F28379D (for example, program that operates the CPU2 blue LED using GPIO31) to ensure that CPU2 is not mistakenly configured to use the board peripherals intended for CPU1.

6. Click Build, Deploy & Start on the Hardware tab to deploy the target model to the hardware.

NOTE: Ignore the warning message "Multitask data store option in the Diagnostics page of the Configuration Parameter Dialog is none" displayed by the model advisor, by clicking the Always Ignore button. This is part of the intended workflow.

7. Click the host model hyperlink in the target model to open the associated host model.

8. In the host model, open the blocks Host Serial Setup, Host Serial Receive, and Host Serial Transmit, and select a Port.

9. Click Run on the Simulation tab to run the host model.

10. Observe the ADC counts for the ${I_a}$ and ${I_b}$ currents in the Time Scope. The average values of the ADC counts are the ADC offset corrections for the currents ${I_a}$ and ${I_b}$. To obtain the average (median) values of ADC counts:

  • In the Scope window, navigate to Tools > Measurements and select Signal Statistics to display the Trace Selection and Signal Statistics areas.

  • Under Trace Selection, select a signal (${I_a}$ or ${I_b}$). The characteristics of the selected signal are displayed in the Signal Statistics pane. You can see the median value of the selected signal in the Median field.

For the Motor Control Blockset examples, update the computed ADC (or current) offset value in the inverter.CtSensAOffset and inverter.CtSensBOffset variables in the model initialization script linked to the example. For instructions, see Estimate Control Gains and Use Utility Functions.

NOTE: The computed ADC offset depends on the ADC gain value inverter.SPI_Gain_Setting that you configure in the model initialization script. Changing ADC gain also changes the ADC offset.