Main Content

Sensorless Field-Oriented Control of PMSM Using C2000 Processors

This example implements the field-oriented control (FOC) technique to control the speed of a three-phase permanent magnet synchronous motor (PMSM). For details about FOC, see Field-Oriented Control (FOC) (Motor Control Blockset).

This example uses the sensorless position estimation technique. You can select either the sliding mode observer or flux observer to estimate the position feedback for the FOC algorithm used in the example.

A closed-loop FOC algorithm is used to regulate the speed and torque of a three-phase PMSM. This example uses C28x peripheral blocks from the Embedded Coder Support Package for Texas Instruments C2000 Processors and MCB library blocks from Motor Control Blockset.

The Sliding Mode Observer (SMO) block generates a sliding motion on the error between the measured and estimated position. The block produces an estimated value that is closely proportional to the measured position. The block uses stator voltages $({V_\alpha },{V_\beta })$ and currents $({I_\alpha },{I_\beta })$ as inputs and estimates the electromotive force (emf) of the motor model. It uses the emf to further estimate the rotor position and rotor speed. The Flux Observer block uses identical inputs $({V_\alpha },{V_\beta },{I_\alpha },{I_\beta })$ to estimate the stator flux, generated torque, and the rotor position.

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.

For connections related to the preceding hardware configuration, see Hardware Connections.

Available Models

The example includes these models:

Note: For LAUNCHXL-F28069M controller and LAUNCHXL-F28379D controller, refer to Sensorless Field-Oriented Control of PMSM (Motor Control Blockset).

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

open_system('mcb_pmsm_foc_sensorless_f28069m.slx');

You may need to change the model parameters to fit your specific motor. Match motor voltage and power characteristics to the controller.

A conventional voltage-source inverter drives motor. The controller algorithm generates six pulse width modulation (PWM) signals using a vector PWM technique for six power switching devices. The inverter measures the current of the two motor inputs (ia and ib) input currents of the motor (ia and ib) using two analog-to-digital converters (ADCs) and sends the measurements to the processor.

Peripheral Block Configurations

Set the peripheral block configurations for this model. Double-click on the blocks to open block parameter configurations. You can use the same parameter values if you want to run this example for other hardware boards.

  • ePWM Block configuration

  • ADC Block configuration

The algorithm in this example uses an asynchronous scheduling. The pulse width modulation (PWM) block triggers the ADC conversion. At the end of conversion, the ADC posts an interrupt that triggers the main FOC algorithm. For more information, refer ADC Interrupt Based Scheduling.

Configure the Model

1. Open the mcb_pmsm_foc_sensorless_f28069m model. This model is configured for TI Piccolo F28069x hardware.

2. To run the model on other TI C2000 processors, first press Ctrl+E to open the Configuration Parameters dialog box. Then, select the required hardware board by navigating to Hardware Implementation > Hardware board.

3. The following screenshots show the scheduler configurations performed in the model. You can use the same parameter values if you want to run this example for other hardware boards.

Note:

  • Sampling rate of the ADC block should be same as the base rate of the model determined by the PWM period of the ePWM block.

  • Base rate trigger selection should be same as the interrupt triggered by the ADC module. For more information, see Model Configuration Parameters for Texas Instruments C2000 Processors.

  • Ensure that the Default parameter behavior (Configuration Parameters > Code Generation > Optimization) is set to Inlined.

4. Ensure that the baud rate is set to 5.625e6 bits/sec.

Note:

  • For F28335 processor you need to use external FTDI for serial communication.

  • For F28035/F28335 processors sensorless example, the motor spins at a default speed of 0.5 per unit.

Required MathWorks® Products

To simulate model:

For the models: mcb_pmsm_foc_hall_f28035 and mcb_pmsm_foc_hall_f28335

  • Motor Control Blockset™

  • Fixed-Point Designer™

To generate code and deploy model:

For the models: mcb_pmsm_foc_hall_f28035 and mcb_pmsm_foc_hall_f28335

  • Motor Control Blockset™

  • Embedded Coder®

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

  • Fixed-Point Designer™

Prerequisites

  • If you obtain the motor parameters from the datasheet or other sources, update the motor parameters and inverter parameters in the model initialization script associated with the Simulink® models. For instructions, see Estimate Control Gains from Motor Parameters (Motor Control Blockset).

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 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 Analog-to-Digital Converter (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 it manually in the model initialization scripts. For instructions, see Open-Loop Control of 3-Phase AC Motors using C2000 Processors.

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 model, see Model Configuration Parameters (Motor Control Blockset).

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

6. In the target model, click the host model hyperlink 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_pmsm_foc_host_model.slx');

For details about the serial communication between the host and target models, see Host-Target Communication (Motor Control Blockset).

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

8. Update the Reference Speed value in the host model.

NOTE: Before you run the motor at the required Reference Speed (by using either Sliding Mode Observer or Flux Observer), start running the motor at 0.1 x pmsm.N_base speed by using open-loop control. Then transition to closed-loop control by increasing the speed to 0.25 x pmsm.N_base (where, pmsm.N_base is the MATLAB workspace variable for base speed of the motor).

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

10. Change the position of the motor switch to Start, to start running the motor in the open-loop condition.

NOTE: Do not run the motor (using this example) in the open-loop condition for a long time duration. The motor may draw high currents and produce excessive heat.

We designed the open-loop control to run the motor with a Reference Speed that is less than or equal to 10% of base speed.

When you run this example on the hardware at a low Reference Speed, due to a known issue, the PMSM may not follow the low Reference Speed.

11. Increase the motor Reference Speed beyond 10% of base speed to switch from open-loop to closed-loop control.

NOTE: To change the motor's direction of rotation, reduce the motor Reference Speed to a value less than 10% of the base speed. This brings the motor back to open-loop condition. Change the direction of rotation but keep the Reference Speed magnitude as constant. Then transition to the closed-loop condition.

12. Observe the debug signals from serial communication , in the Time Scope of host model.

Other Things to Try

  • You can use SoC Blockset™ to implement a sensorless closed-loop motor control application that addresses challenges related to ADC-PWM synchronization, controller response, and studying different PWM settings. For details, see Partition Motor Control for Multiprocessor MCUs.