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

Open-loop control (also known as Scalar control or Volts/Hz control) is a motor control technique that 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. Whereas, 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, we 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 using an open-loop motor control algorithm. It 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 it to the host model by using serial communication.

Therefore, this model can be used to meet following objectives:

  • Check connectivity with target.

  • Check serial communication with target.

  • Verify hardware and software environment.

  • Check ADC Offsets for current sensors.

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

Models

The example includes these models:

  • mcb_open_loop_control_f28069M_DRV8312

  • mcb_open_loop_control_f28069MLaunchPad

  • mcb_open_loop_control_f28379d

You can use these models for both simulation and code generation. You can use the "open_system" command to open the Simulink® model. For example, use this command for a F28069M based controller:

open_system('mcb_open_loop_control_f28069M_DRV8312.slx');

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®

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

  • Fixed-Point Designer™

2. For the model: mcb_open_loop_control_f28379d

  • Motor Control Blockset™

  • Embedded Coder®

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

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

Pre-requisites

1. Update the motor parameters in the model initialization script associated with the target models. For instructions to update the script, see Estimate Control Gains from Motor Parameters

2. 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.

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

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

  • Add a NOT logical operator block between Enable and DRV830x Enable.

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 in the Simulation tab to simulate the model.

3. Click Data Inspector in 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 pre requisite 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. Use the target model name (highlighted in bold) to open the model for the corresponding hardware configuration, from the MATLAB® command prompt.

  • F28069M controller card + DRV8312-69M-KIT inverter: mcb_open_loop_control_f28069M_DRV8312

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

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

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

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. Load a sample program to CPU2 of LAUNCHXL-F28379D, for example, 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.

5. Click Build, Deploy & Start in 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.

6. Click the host model hyperlink in the target model to open the associated host model. You can also use the "open_system" command to open the host model. For example, use this command for a F28069M based controller:

open_system('mcb_open_loop_control_host_model.slx');

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

7. In the Host Serial Setup block mask of the host model, select a Port name.

8. Click Run in the Simulation tab to run the host model.

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

10. After the motor runs, observe the ADC counts for the ${I_a}$ and ${I_b}$ currents in the Time Scope.

If the motor does not run, change the Start / Stop Motor switch position to Off, to stop the motor and change the Reference Speed in the host model. Afterwards, change the Start / Stop Motor switch position 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 in 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 Serial Setup block mask of the host model, select a Port name.

9. Click Run in 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}$. You can use these steps to obtain the average (median) values of ADC counts: * In the Scope window, navigate to Tools > Measurements, and select the Signal Statistics option to display the Trace Selection and Signal Statistics areas.

  • In the Trace Selection area select a signal (${I_a}$ or ${I_b}$). The window display the characteristics of the selected signal in the Signal Statistics area. 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 to update the script, see Estimate Control Gains from Motor Parameters.