The problem
Most Indian e-scooters, e-bikes and e-rickshaws use BLDC hub motors with simple six-step (trapezoidal) controllers because they are cheap and robust. Their weak points are torque ripple at each commutation, audible noise and poor low-speed smoothness. A simulation lets a student see exactly where these come from before touching a real high-current controller.
Objectives
- Model a BLDC motor with trapezoidal back-EMF and Hall sensor outputs in Simscape Electrical.
- Build a six-switch inverter and a Hall-state commutation table.
- Close a speed loop with a PI controller acting on PWM duty.
- Measure phase current, torque ripple and speed response under load steps.
- Compare two PWM strategies and explain the difference in ripple.
What you need
Tools and toolboxes
- Simulink — Top-level model, commutation logic, speed controller and signal logging.
- Simscape Electrical — BLDC machine block with Hall outputs, MOSFET or ideal-switch inverter and DC source.
- Simscape — Physical-network solver, mechanical inertia and load torque source (installed with Simscape Electrical).
Software
- MATLAB R2023b or later
- Simulink
- Simscape Electrical
- A motor datasheet or example parameter set
Extra parts and data
None beyond the software above.
Key concepts
- Six-step commutation
- At any instant two of the three phases conduct and the third floats. The three Hall sensors give six valid states, each mapped to one pair of switches, so the stator field steps 60 electrical degrees at a time.
- Trapezoidal back-EMF
- A BLDC motor's windings are arranged so that each phase back-EMF has a flat top for 120 electrical degrees. Driving a constant current during that flat region gives nearly constant torque.
- Commutation torque ripple
- When conduction moves from one phase to the next, the outgoing current cannot fall and the incoming current cannot rise instantly because of winding inductance, so torque dips at every step.
- Electrical versus mechanical speed
- Electrical frequency equals mechanical speed times the number of pole pairs, so a hub motor with many pole pairs commutates fast even at low road speed.
Step-by-step guide
- 1
Set the example specification
Write down example values for a scooter hub drive, for instance a 48 V battery, 1 kW rated power, 4 pole pairs, phase resistance 0.1 ohm, phase inductance 0.3 mH, back-EMF constant 0.12 V·s/rad and rotor inertia 0.002 kg·m². Label them clearly as an example set, not a product. Compute the no-load speed from 48 V and the back-EMF constant, and the rated torque from power and rated speed, so you know what numbers to expect later.
Checkpoint: A parameter script (bldc_params.m) that runs and prints expected no-load speed and rated torque.
- 2
Build the motor and mechanical load
Create a Simulink model, add a Solver Configuration block and the Simscape Electrical BLDC block, and enter the parameters from the script. Connect its mechanical port to an Inertia block and an Ideal Torque Source for load torque, referenced to a Mechanical Rotational Reference. Enable the Hall sensor or rotor-angle output. Start with a variable-step solver such as ode23t, or set a local Backward Euler solver with a 1 µs step for switching models.
Checkpoint: Spinning the rotor with an Ideal Angular Velocity Source shows trapezoidal back-EMF with flat tops 120 electrical degrees wide.
- 3
Add the inverter and DC supply
Build a three-phase bridge of six MOSFET (Ideal, Switching) blocks with body diodes, or use a Simscape Electrical three-phase converter block, fed from a DC Voltage Source of 48 V with a small series resistance and DC-link capacitor. Add current sensors on each phase and on the DC link. Convert six gate signals from Simulink to physical signals with Simulink-PS Converter blocks. Keep switching frequency at an example 16 kHz.
Checkpoint: Forcing one fixed switch pair on at standstill gives the expected current I = V / (2R) settling with time constant L/R.
- 4
Write the commutation table
Read the three Hall bits, combine them into a state 1 to 6 with a small MATLAB Function block, and map each state to the high-side and low-side switches that must conduct. Check the table against the back-EMF waveforms: the energised phases must be the ones whose back-EMF is in its flat region. Invalid states 0 and 7 should turn all switches off. Add a direction input that reverses the table.
Checkpoint: With 100 per cent duty and no load the motor accelerates smoothly to close to the predicted no-load speed in both directions.
- 5
Add PWM and a speed loop
Generate PWM by comparing a duty command with a 16 kHz carrier and apply it to the high-side switches only (unipolar) while the low side stays on during its conduction interval. Add a discrete PI speed controller whose output is the duty command, saturated between 0 and 1, with anti-windup enabled. Tune it first on a simple first-order approximation of the motor, then refine in the full model.
Checkpoint: A speed step from 0 to 50 per cent of no-load speed settles within your target time (for example 0.3 s) with overshoot below 10 per cent.
- 6
Test load steps and record ripple
Apply a load torque step at rated torque once speed has settled and log speed, electromagnetic torque, phase currents and DC-link current with Simulation Data Inspector. Measure peak-to-peak torque ripple as a percentage of average torque and zoom into one commutation event. Compare the current shape at low and high speed, where the back-EMF leaves less voltage margin for current to rise.
Checkpoint: Torque plot shows dips at every 60 electrical degrees, with ripple percentage noted at two speeds.
- 7
Compare PWM strategies
Run the same speed and load with two schemes: PWM on the high side only, and PWM on both switches of the conducting pair (bipolar). Script both runs with sim() and a loop over a variable that selects the scheme. Compare current ripple, torque ripple and DC-link current ripple, and explain the results from the voltage applied to the winding during the off-time in each scheme.
Checkpoint: A table of current and torque ripple for both schemes with a written explanation of the difference.
- 8
Write up results
Assemble plots of back-EMF, phase current, torque, speed response and the PWM comparison. State the solver and step settings, the parameter set and its source, and the limits of the model, for example ideal Hall sensors, no magnetic saturation and lossless switching. Finish with what you would change for a smoother real controller, such as advancing commutation at high speed or moving to sinusoidal control.
Checkpoint: A report with every figure reproduced by one script that runs the model from scratch.
Testing & validation
- Back-EMF shape and amplitude match the back-EMF constant at a known speed.
- Stall current at fixed switching state matches V / (2R).
- No-load speed within a few per cent of the prediction from the back-EMF constant.
- Speed loop meets the settling and overshoot targets under a rated load step.
- Torque ripple measured and explained at two speeds and for two PWM schemes.
Expected results
A working six-step BLDC drive model with Hall commutation and speed control, plus measured current shapes, torque ripple and speed response that explain the behaviour of common two-wheeler hub drives.
Take it further
- Add commutation advance as a function of speed and measure the effect at high speed.
- Replace Hall sensors with back-EMF zero-crossing detection on the floating phase.
- Feed the model with a drive-cycle speed demand such as IDC and log energy use.
- Add MOSFET conduction losses and estimate controller efficiency.
Viva and review questions
Why do only two phases conduct at a time in six-step control?
Each phase back-EMF is flat for 120 electrical degrees, and the two phases in their flat regions are energised so that a constant current produces nearly constant torque; the third phase is in transition and is left floating.
Where does commutation torque ripple come from?
Winding inductance stops the outgoing phase current falling and the incoming phase current rising instantly, so for a short time the total torque-producing current dips.
How did you choose the solver?
Switching models have fast events, so I used a stiff solver (ode23t) or a fixed-step local solver with a step much smaller than the PWM period, and checked that halving the step did not change the results.
Learn it at DIYguru
These DIYguru courses and programmes teach what this project needs.
