Main Content

Swap Motors with Single Deployment of Sensorless FOC Algorithm

This example shows how to run a permanent magnet synchronous motor (PMSM) in an industrial drive application setup using a sensorless field-oriented control (FOC). The example uses a sensorless Flux Observer to estimate the motor position. Industrial drives enable you to replace a motor with a new one without repeated deployment of code. An industrial drive setup needs only nameplate parameters to adapt the software to the new motor.

The example uses a motor agnostic models that is independent of the motor parameters. You do not need to know the parameters of your motor to use these hardware-deployable target models.

To use the target models, you need only these details:

  • Motor type (this example only supports a PMSM)

  • Operating power range of your motor (this should be compatible with the power output of the BOOSTXL-DRV8305 inverter supported by this example)

After successfully running a motor, the usual practice of replacing or swapping the motor includes updating the motor parameters in the control algorithm (such as FOC) and then generating and deploying the code again to the motor control hardware. This process can be time-consuming, especially in industrial and production environments where motors are regularly swapped but the controller and inverter hardware must remain fixed.

The example addresses this limitation by enabling you to replace the current motor with a new one without having to deploy the code again. After swapping a motor, you can use the host interface to update only the motor nameplate parameters. The control algorithm (sensorless FOC) running on the target hardware then automatically performs the following operations:

1. Estimates the motor parameters.

2. Computes control gains for the speed and current PI controllers.

3. Runs the motor using FOC by adhering to a reference speed. For more information about FOC, see Field-Oriented Control (FOC).

This sequence of operations enables the control algorithm to automatically adapt itself to the newly connected motor without manual code updates and deployment.

However, note that:

  • After deploying a target model to the target controller, the workflow supports motor replacement and code adaptability only when you continue to use the same inverter hardware. This is because the inverter parameters are fixed in the deployed control algorithm and the example only estimates the motor parameters.

  • The new replacement motor must be compatible (with respect to voltage, power, and current range) with the inverter hardware.

Open MATLAB Project

The example is packaged as a MATLAB® project. Use one of these methods to open the MATLAB project window:

1. Click Open Project button.

2. Run this command to access the example folder containing the supporting files and open the MATLAB project.

openExample('mcb/RunIndustrialDriveUsingSensorlessFOCExample');

Model

The MATLAB project has a model folder that includes the following Simulink® models:

  • PMSMSensorlessIndustrialDriveF28379d.slx — Deploy this target model to the target controller and inverter hardware.

  • PMSMSensorlessIndustrialDriveHostF28379d.slx — Run this host model on the host computer connected to the target hardware via the serial port.

Required MathWorks Products

To simulate model:

  • Motor Control Blockset™

  • Stateflow®

To generate code and deploy model:

  • Motor Control Blockset

  • Embedded Coder®

  • C2000™ Microcontroller Blockset

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

  • Stateflow

Simulate Model

Follow these steps to simulate the model included in the project:

1. Open the target model PMSMSensorlessIndustrialDriveF28379d.slx from the model folder.

This model includes default PMSM parameters, which you can update in the System Parameters section of the model initialization script (PMSMSensorlessIndustrialDriveF28379dData.m) available in the script folder.

2. Run the model initialization script.

3. Click Run on the Simulation tab to simulate the target model.

Generate Code and Deploy Model to Target Hardware

This section shows you how to generate and deploy the code to the target hardware and run a PMSM using a sensorless FOC algorithm in an industrial drive setup.

In addition to the target model, the MATLAB project uses a host model. The host model, which is a user interface to the controller hardware board, runs on the host computer. To use the host model, first deploy the target model to the controller hardware board. The host model uses serial communication to command the target model, provide basic motor parameters after the motor swap, run (and control) the motor, and collect and display the debug signals from the controller.

Required Hardware

The example supports the LAUNCHXL-F28379D controller + BOOSTXL-DRV8305 inverter hardware configuration. For connections related to this 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. Navigate to the MATLAB project and open the target model PMSMSensorlessIndustrialDriveF28379d.slx from the model folder.

If you want to change the default hardware configuration settings for the model, see Model Configuration Parameters.

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

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

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

For more information on the serial communication between the host and target models, see Host-Target Communication.

7. In the model initialization script associated with the target model, specify the communication port using the variable target.comport and run the script. The example uses this variable to update the Port parameter in the Host Serial Setup, Host Serial Receive, and Host Serial Transmit blocks in the host model.

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

9. Update the following fields in the Motor Setup section of the host model with the motor nameplate parameters.

  • Motor pole pairs — Number of pole pairs available in the PMSM

  • Motor rated current [A] — Rated current of the PMSM (in amperes)

  • Motor rated speed [RPM] — Rated speed of the PMSM (in RPM)

10. Enter the reference speed (in RPM) to run the PMSM in the Speed Reference [RPM] field.

11. Change the position of the Motor switch to Start to start running the motor.

12. Observe the debug signals in the scope available in the host model. You can use the Debug Signal combo box to select the debug signal that you want to monitor.

13. To swap the motor, follow these steps:

a. Turn the Motor switch to Stop to stop the motor.

b. Click Stop in the Simulink toolstrip to stop simulating the host model.

c. Turn off the DC voltage power supply.

d. Disconnect the motor phase connections and connect the phase wires of the new motor.

e. Turn on the DC voltage power supply.

f. Reset the LAUNCHXL-F28379D controller hardware.

g. Repeat steps 8 to 12 to add new motor nameplate parameters in the host model and run the new motor.