Designing a MCU-driven permanent magnet BLDC motor controller: Part 2
Alignment Phase
Since the rotor position is not known, it must be placed in a position
that can be reliably used as a reference point. The controller aligns
the rotor to a known position by powering two phases. That is, by
pulling one phase to supply and one phase to ground. There are two
things to worry about.
The first is motor resistance. There is very little motor resistance in a non-spinning motor. This translates to a huge amount of current flow and resulting torque, which leads to the second issue.
Too much torque applied all at once can cause the rotor to oscillate as it pulls into position way too quickly. The steady state point of two-phases-on is the lowest torque point in the rotational position.
Pulling a rotor into position too quickly will cause it to overshoot and oscillate. This is especially the case if there is not a lot of friction in the system. Just turning these switches full-on can cause the rotor to oscillate and draw enormous amounts of current.
Depending on the motor / system being driven, the alignment phase is a gradual stepping up of the stator current. This is done by PWM-ing the stator current with an increasing duty cycle until the rotor is in a known position.
This gently moves the rotor into position without a lot of mechanical overshoot / oscillation and limits the current in the motor. If there is a lot of "stick-tion" or static friction in the motor assembly, the algorithm can be modified to provide a high current pulse for a few milliseconds to break the rotor free.
Once the rotor is freed, the current can then be dropped back down and slowly ramped up to the hold position prior to starting. The software routine which controls the alignment ramp-up is
UInt8 AlignRotor(void)
This routine is a two-state state machine. The first state initializes some RAM variables, determines the maximum PWM duty cycle based on battery voltage, and places the motor control cell into direct access mode.
The direct access mode allows setting up the output registers for the starting position. Once the outputs are set to the desired start position, the direct access mode is exited.
The second state of the state machine controls the ramp-up and hold stages of the alignment phase. This part of the state machine increases the PWM duty cycle until the maximum duty cycle is reached.
The maximum duty cycle is maintained until the hold timer expires, ending the alignment phase. This routine is graphically depicted by the flowchart in Figure 12 below.
![]() |
| Figure 12. Start-up algorithm. |
The BEMF voltage seen on the unused phase can be used to determine how long the alignment time should be. Zooming in on the lower voltage of the unused phase with the oscilloscope will show some dampening oscillations. These oscillations must settle before the micro starts into the "Stepping Blindly" , or switched, mode.
![]() |
| Figure 13. Start-up alignment phase. |
The PWM duty cycle and the battery voltage are factors that must be considered when determining the alignment time. The battery voltage and PWM duty cycle are inversely related.
That is, with higher battery voltages, the PWM duty cycle should be lower and vice versa. The intent is to minimize the oscillations for a given voltage range. This can be found in the software under the following function:
UInt16 Determine_VBAT_PWM( void )
This function scales the PWM duty cycle based on the battery voltage measured by the A/D converter. The PWM duty cycles for a given range, and the battery voltage points can be adjusted to minimize the alignment oscillations for a given system.
Switched and Auto-Switched Mode
Once the rotor is put into a "known" position, the controller can now
start stepping through the phases in a known direction at a
predetermined increasing rate continually looking for BEMF. There is a
gradual increase in commutation speed as the rotor begins to rotate
faster with each step.
At some point, there will be adequate rotation to generate enough BEMF to sense. At that point, the control algorithm can switch from blindly stepping and searching for BEMF to auto-switch mode using BEMF zero crossings as a rotor position reference.
The controller software monitors three events which occur during rotor rotation. These three events are Commutation, Demagnetization, and Zero Crossing. These events always happen in a set sequence.
The Commutation event (C-event) occurs when the controller steps to the next phase. The act of commutating to the next step will cause a voltage spike in the just-turned-off phase to appear due to the winding inductance.
For a low-side driven phase, the spike is positive - a diode above the supply voltage. For a high-side driven phase, the spike is clamped to just below ground. The voltage is limited by the intrinsic diodes of the inverter MOSFETS.
The voltage spike will remain as long as the current in that phase is decaying. The controller waits until this inductive current has dissipated before monitoring this phase for BEMF.
Otherwise, this inductive spike looks like a zero crossing event has already occurred and messes up everything. This wait time is the Demagnetization event (or D-event).
![]() |
| Figure 14. Relationship between Commutation, Demagnetization, and Zero Crossing Events. |
The next event in the sequence is the Zero Crossing event (or Z-event). The controller monitors the unused phase to determine when the BEMF crosses zero (or near zero) Volts. This event tells the controller where the rotor is.
With timing based on rotor speed, the controller determines when to perform the next commutation (or C-event). The controller repeats the sequence of C-event, D-event, Z-event (and back to C-event) to keep the rotor spinning.
To read Part 1, go to Dealing with the basics
Next in Part 3: Motor control timing
considerations
David Swanson is a principal
engineer in the Automotive Business Unit of STMicroelectronics.
He has a BSEE from North Carolina State University and holds several
automotive-related patents. Kurt Perski is a Microcontroller Field
Applications Engineer with STMicroelectronics, whose professional
interests focus on embedded software design.





Loading comments... Write a comment