Main Content

Commutation of SRM Using Sensor Feedback

This example implements a commutation system to control the speed of a three-phase 12/8 switched reluctance motor (SRM).

It uses the switching sequences generated by the SRM Commutation block to control switch the motor phases ON and OFF, and therefore, run the motor while controlling the motor speed. For more details about this block, see SRM Commutation.

The example uses the following values to generate a switching (or commutation) sequence for each phase available in the motor.

  • Electrical position signals with respect to a phase of SRM.

  • Position range for all phases during which they should be activated (also known as dwell angle).

Each switching sequence (for example, ctr(1) signal in the following image, which forms a pulse train) can be used to control (turn On or Off) the corresponding motor phase. Each pulse in a switching sequence represents the activation period of the phase, which is defined by turn-on ($\theta eOn$) turn-off ($\theta eOff$) angles as shown below:

The commutation system needs real-time motor position feedback, which is obtained from a quadrature encoder sensor.

The example utilizes Mechanical to Electrical Position block, which uses the mechanical position feedback and the number of rotor poles available in SRM to compute the motor electrical position. It computes electrical position with respect to each phase (Theta_e), which lies between 0 and 2π radians (0 and 360 degrees or 0 and 1 per unit).

The example uses this feedback along with the commutation logic to drive and control the speed of the rotor.

You can configure the example to use either per-unit and SI unit computation. When the controller uses per-unit computation, the example supports both fixed point and floating-point datatypes. However, when using SI unit, the example only supports floating-point datatype.

Model

The example includes the model mcb_srm_spdctrl_f28379d.

You can use these models for both simulation and code generation. To open a Simulink® model, you can also use the open_system command at the MATLAB command prompt. For example, use this command for the F28379D based controller:

open_system('mcb_srm_spdctrl_f28379d.slx');

For details about the supported hardware configuration, see Required Hardware in the Generate Code and Deploy Model to Target Hardware section.

Required MathWorks® Products

To simulate model:

  • Motor Control Blockset™

  • Simscape™ Electrical™

  • Fixed-Point Designer™

To generate code and deploy model:

  • Motor Control Blockset™

  • Simscape™ Electrical™

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

  • Embedded Coder®

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

Prerequisites

Obtain the SRM parameters. We provide default SRM parameters with the Simulink model that you can replace with values from either the motor datasheet or other sources.

Update SRM parameters in the model initialization script associated with the Simulink model. For instructions, see Estimate Control Gains and Use Utility Functions

In addition, update the following parameters in the model initialization script:

  • PWM_frequency — Enter the switching frequency of PWM. Note that you may need to tune controller gains again if you change this value.

  • datatype

          - single — Use this value for floating point code generation. In this mode, the example supports both per-unit and SI unit computation.

          - fixdt(1,32,17) — Use this value for fixed point code generation. In this mode, the example only supports per-unit computation.

  • controllerunit

          ▫ 1 — Use this value to enable SI unit computation.

          ▫ 0 — Use this value to enable per-unit computation.

  • Kp and Ki — Enter the PI controller gains. Note that the example does not automatically compute these values. Fine tune these gains according to the hardware setup.

  • thetaON — Enter the motor phase turn-on electrical position at which the switching sequence turns 0 to 1 and energizes the corresponding phase.

  • thetaOFF — Enter the motor phase turn-off electrical position at which the switching sequence turns 1 to 0 and de-energizes the corresponding phase.

  • phaseAlignTime — Enter the maximum time within which the rotor can align itself with stator phase a.

Simulate Model

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

1. Open the target 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 Deploy Model to Target Hardware

This section shows you how to generate code and run the control 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 a closed-loop control.

Required Hardware

The example supports the following hardware configuration. You can also use the target model name to open the model from the MATLAB® command prompt.

The example uses the ADC current sensors available in the inverter boards to measure the 3 phase motor currents needed for controlling SRM.

Hardware Connections

The example requires 2 BOOSTXL-DRV8305 inverters connected in the following configuration.

Mount the BOOSTXL-DRV8305 inverters over the LAUNCHXL-F28379D controller card such that one inverter mounts over J1, J2, J3, J4 and the other inverter mounts over J5, J6, J7, J8. Join the connectors A1, B1, C1, A2, B2, and C2 (which are connected to the inverter MOSFETs and diodes) with the motor phase windings as shown below.

  • Connectors A1, A2 — phase A terminals of SRM

  • Connectors B1, B2 — phase B terminals of SRM

  • Connectors C1, C2 — phase C terminals of SRM

Connect the quadrature encoder pins (G, I, A, 5V, B) to QEP_A on the LAUNCHXL controller board.

For other connection details 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. The model computes the ADC (or current) offset values by default. To disable this functionality, 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 script. 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 for the model, see Model Configuration Parameters.

5. Load a sample program to CPU2 of LAUNCHXL-F28379D. For example, you can use the program that operates the CPU2 blue LED by using GPIO31 (c28379D_cpu2_blink.slx) and 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. Observe and verify the variables populated by the target model in the base workspace.

8. 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. Use this command for a F28379D based controller.

open_system('mcb_srm_spdctrl_host.slx');

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

9. In the host model, open the blocks Host Serial Setup, Host Serial Receive, and Host Serial Transmit, and select a Port.

10. Update the reference speed value in the Reference Speed (RPM) field in the host model. We recommend that you enter lower speeds initially during motor start up and gradually increase the speed later.

11. In the host model, select the debug signals that you want to monitor.

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

13. Ensure that the motor is in no-load condition. Change the position of the Motor switch to Start, to start running the motor.

14. The example performs the following procedures:

  • Calibrates the quadrature encoder sensor (which includes alignment of the rotor with stator phase a).

  • Runs SRM in closed loop according to Reference Speed (RPM).

15. Observe the debug signals received from target in the Scope available in the host model.