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.

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 LAUNCHXL-F28069M controller and LAUNCHXL-F28379D controller, refer to.

For connections related to the preceding hardware configuration, seeHardware Connections.

Available Models

The example includes these models:

Note:For LAUNCHXL-F28069M controller and LAUNCHXL-F28379D controller, refer to.

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, referADC Interrupt Based Scheduling.

Configure the Model

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

2.To run the model on other TI C2000 processors, first pressCtrl+Eto open the Configuration Parameters dialog box. Then, select the required hardware board by navigating toHardware 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 theDefault parameter behavior(Configuration Parameters > Code Generation > Optimization) is set toInlined.

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_sensorless_f28035andmcb_pmsm_foc_sensorless_f28335

  • Motor Control Blockset™

  • Fixed-Point Designer™

To generate code and deploy model:

For the models:mcb_pmsm_foc_sensorless_f28035andmcb_pmsm_foc_sensorless_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.

Simulate Model

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

1.Open a model included with this example.

2.ClickRunon theSimulationtab to simulate the model.

3.ClickData Inspectoron theSimulationtab 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.奥特曼的模型atically 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, seeOpen-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.

5.ClickBuild, Deploy & Starton theHardwaretab to deploy the target model to the hardware.

6.In the target model, click thehost modelhyperlink 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.

7.Set the parameterPortof the following blocks in themcb_pmsm_foc_host_modelmodel to match the COM port of the host computer:

  • mcb_pmsm_foc_host_model > Host Serial Setup

  • mcb_pmsm_foc_host_model >串行通信> Host Serial Receive

  • mcb_pmsm_foc_host_model > Serial Communication > SCI_TX > Host Serial Transmit

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 xpmsm.N_basespeed by using open-loop control. Then transition to closed-loop control by increasing the speed to 0.25 xpmsm.N_base(where,pmsm.N_baseis the MATLAB workspace variable for base speed of the motor).

9.ClickRunon theSimulationtab 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.

当您运行这个例子在较低的硬件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, seePartition Motor Control for Multiprocessor MCUs.

  • For LAUNCHXL-F28069M controller and LAUNCHXL-F28379D controller, refer to.