Six-Step Commutation of BLDC Motor Using Sensor Feedback - MATLAB & Simulink Example - MathWorks India
Six-Step Commutation of BLDC Motor Using Sensor Feedback - MATLAB & Simulink Example - MathWorks India
A Hall effect sensor varies its output voltage based on the strength of the applied magnetic field. According to the
standard configuration, a BLDC motor consists of three Hall sensors located electrically 120 degrees apart. A BLDC
with the standard Hall placement (where the sensors are placed electrically 120 degrees apart) can provide six valid
combinations of binary states: for example, 001,010,011,100,101, and 110. The sensor provides the angular position
of the rotor in degrees in the multiples of 60, which the controller uses to determine the 60-degree sector where the
rotor is present.
The controller controls the motor by using the Hall sequence or the rotor position. It energizes the next two phases of
the stator winding, so that the rotor always maintains a torque angle (angle between rotor d-axis and stator magnetic
field) of 90 degrees with a deviation of 30 degrees.
Note: The Hall sequence can vary. Use the example Hall Sensor Sequence Calibration of BLDC Motor to determine
the Hall sequence.
The example supports simulation. You can simulate a plant model containing a three-phase switching inverter along
with wye-wound BLDC from Simscape™ Electrical™.
Models
The example includes these models:
mcb_bldc_sixstep_f28069mLaunchPad
mcb_bldc_sixstep_f28379d
You can use these models for both simulation and code generation.
For details of the supported hardware configuration, see Required Hardware in the Generate Code and Deploy Model
to Target Hardware section.
Fixed-Point Designer™
Simscape™ Electrical™
Simscape Electrical
Embedded Coder®
Fixed-Point Designer
Embedded Coder
Prerequisites
1. Obtain the motor parameters. We provide default motor parameters with the Simulink model that you can replace
with values from either the motor datasheet or other sources.
However, if you have the motor control hardware, you can estimate the parameters for the motor that you want to use
by using the Motor Control Blockset parameter estimation tool. For instructions, see Estimate PMSM Parameters
Using Recommended Hardware.
The parameter estimation tool updates the motorParam variable (in the MATLAB® workspace) with the estimated
motor parameters.
2. If you obtain the motor parameters from a motor datasheet or from other sources, update the motor parameters
and the inverter parameters in the model initialization script associated with the Simulink models. For instructions,
see Estimate Control Gains and Use Utility Functions.
If you use the parameter estimation tool, you can update the inverter parameters, but do not update the motor
parameters in the model initialization script. The script automatically extracts the motor parameters from the
updated motorParam workspace variable.
Simulate Model
This example supports simulation. Follow these steps to simulate the model.
2. Select either the QEP or the Hall Speed_Feedback radio button in the model.
4. Click Data Inspector on the Simulation tab to view and analyze the simulation results.
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 these hardware configurations. You can also use the target model name to open the model for
the corresponding hardware configuration, from the MATLAB® command prompt.
For connections related to these hardware configurations, see LAUNCHXL-F28069M and LAUNCHXL-F28379D
Configurations.
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. If you are using a quadrature encoder, compute the quadrature encoder index offset value and update it in the
bldc.PositionOffset variable available in the model initialization script associated with the target model. For
instructions, see Quadrature Encoder Offset Calibration for PMSM.
5. If you are using a Hall sensor, compute the Hall sequence value and update it in the bldc.hallsequence variable
available in the model initialization script associated with the target model. For instructions, see Hall Sensor
Sequence Calibration of BLDC Motor.
6. Open the target model. If you want to change the default hardware configuration settings for the model, see Model
Configuration Parameters.
7. Select either the Quadrature Encoder or Hall Speed_Feedback radio button in the target model.
8. 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. 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 Getting Started with
Texas Instruments C2000 Microcontroller Blockset (C2000 Microcontroller Blockset).
9. Click Build, Deploy & Start on the Hardware tab to deploy the target model to the hardware and load the variables
from the target model to the base workspace.
10. Click the host model hyperlink in the target model to open the associated host model.
For on the serial communication between the host and target models, see Host-Target Communication.
11. In the model initialization script associated with the target model, specify the communication port using the
variable target.comport. This variable updates the Port parameter of the Host Serial Setup, Host Serial Receive, and
Host Serial Transmit blocks available in the host model.
12. Update the reference speed value in the Reference Speed (RPM) field in the host model.
13. In the host model, select the debug signals that you want to monitor.
14. Click Run on the Simulation tab to run the host model.
15. Change the position of the Motor switch to Start, to start running the motor.
16. Observe the debug signals from the RX subsystem, in the Scope and Display blocks in the host model.