This example implements the field-oriented control (FOC) technique to control the speed of a three-phase AC induction motor (ACIM). The FOC algorithm requires rotor speed feedback, which is obtained in this example by using a quadrature encoder sensor. For details about FOC, see Field-Oriented Control (FOC)
This example uses the quadrature encoder sensor to measure the rotor speed. The quadrature encoder sensor consists of a disk with two tracks or channels that are coded 90 electrical degrees out of phase. This creates two pulses (A and B) that have a phase difference of 90 degrees and an index pulse (I). Therefore, the controller uses the phase relationship between A and B channels and the transition of channel states to determine the direction of rotation of the motor.
The example includes the model mcb_acim_foc_qep_f28379d.
You can use this model for simulation and code generation. You can use the open_system command to open the Simulink® model.
For details on the supported hardware configuration, see the Required Hardware section under Generate Code and Deploy Model to Target Hardware.
To simulate model:
Motor Control Blockset™
To generate code and deploy model:
Motor Control Blockset™
Embedded Coder® Support Package for Texas Instruments™ C2000™ Processors
Fixed-Point Designer™ (needed only for optimized code generation)
1. Obtain the motor parameters. We provide the default motor parameters with the Simulink® model that you can replace with values from either the motor datasheet or other sources.
2. If you obtain the motor parameters from the datasheet or other sources, update the motor and inverter parameters in the model initialization script associated with the Simulink® models. For instructions, see Estimate Control Gains from Motor Parameters.
This example supports simulation. Follow these steps to simulate the model.
1. Open the 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.
This section instructs you on how to generate code and run the FOC algorithm on the target hardware.
This 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 closed-loop control.
This example supports the following hardware configuration. Use the target model name (highlighted in bold) to open the model for the corresponding hardware configuration from the MATLAB® command prompt.
LAUNCHXL-F28379D controller + BOOSTXL-DRV8305 inverter: mcb_acim_foc_qep_f28379d
For connections related to the preceding hardware configuration, see LAUNCHXL-F28069M and LAUNCHXL-F28379D Configurations.
Generate Code and Run Model on Target Hardware
1. Simulate the target model and observe the simulation results.
2. Complete the hardware connections.
3. The model automatically computes the ADC (or current) offset values. To disable this functionality (enabled by default), update the value 0 to the variable inverter.ADCOffsetCalibEnable in the model initialization script.
Alternatively, you can compute the ADC offset values and update them manually in the model initialization scripts. For instructions, see Run 3-Phase AC Motors in Open-Loop Control and Calibrate ADC Offset.
4. Open the target model. If you want to change the default hardware configuration settings in the model, see Model Configuration Parameters.
5. Load a sample program to CPU2 of the LAUNCHXL-F28379D, for example program that operates the CPU2 blue LED, by using the GPIO31 pin (c28379D_cpu2_blink.slx), 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.
7. 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 details about the serial communication between the host and target models, see Host-Target Communication.
8. In the Host Serial Setup block mask of the host model, select a Port name.
9. Update the Reference Speed value in the host model.
10. In the Debug signals section, select a signal that you want to monitor.
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. Observe the debug signals from the RX subsystem in the SelectedSignals time scope of the host model.