Blog
Brushless DC (BLDC) Motor Control, Explained (Part 2)

In the PID position loop, a desired position is provided by the profile generator and compared with the actual position of the motor as measured by an encoder to generate a position error. Signals from Hall-based position sensors can also be used to provide position feedback. However, the positioning resolution of these magnetic sensors will be much lower. In any case, the position error value is then put through a PID filter — short for proportional, integral, derivative — to generate a current command output value.
Note that this same position-control loop can be used for other types of servo motors, such as DC brushed motors. That’s because most of the control elements related to the multiphase nature of BLDC motors are downstream of the position loop.
While the output of the position loop generally flows into a current loop, it can also go to a velocity loop that, in turn, drives a current loop. This arrangement is called a cascaded position/velocity loop. Although it’s a more complicated scheme with more gain value settings, it may outperform the position-only controller in some applications.
In the PID position loop in Figure 4, we should be aware that the “loop” part of the controller is the summing junction in the diagram to the left, where we subtract the actual position from the commanded position to generate a position error value. The PID part of the controller is actually a type of filter called a PID filter. The PID filter takes a stream of position error values as input and generates a stream of commands to a current loop or, in some cases, a velocity loop as output.
To tune a position PID loop, it’s not necessary to know how the PID filter is calculated. However, for reference, the basic equation is below. The PID filter output value as well as its inputs are updated and calculated at each servo-loop update. Modern motion controllers operate with servo-loop update rates anywhere from 1 kHz to as high as 80 kHz, with 5 to 20 kHz being typical for controllers used in motors sized NEMA 17 through NEMA 42.
Outputn = Kp * En + Ki * sum(En) + Kd * (En – En-1)
where:
- En is the current position error value
- En-1 is the previous position error value
- Sum(En) is the sum of En values past and present
Understanding the PID Filter
The main reason the PID position control loop is so popular is that its constituent pieces — the P, the I, and the D — and their impact on motor control can be understood intuitively.
First, the P term is called the proportional term because it provides a proportional restoring correction to the amplifier output command. When presented with the position error, the P term functions like a spring. The larger the position error of the servo motor, the larger the corrective restoring motor command.
The I term is the integral (or integration) term because it integrates, over time, the servo position error. Why would this be useful? Because if only a P (proportional) term is used, it may be difficult to arrive at the exact commanded position due to forces or mechanical issues such as gravity, stiction, motor detents, or other factors. The I term builds up over time and can help get the servo “over the hump” to the final desired position.
Finally, the contribution of the D term is calculated by subtracting the previous position error from the current position error. This has two main practical effects: it delivers a feedforward boost whenever the profile velocity increases or decreases, and it provides a general-purpose drag term, thereby dampening oscillations.
How To Set Position Loop Gain Parameters
Determining appropriate gain settings for a position-control loop is a nuanced task. To keep things simple for now, we will provide a quick overview of a widely used approach: step-response tuning.
In step-response tuning, the motor controller is subjected to a small, instantaneous change in the commanded position to see what the position loop’s control response will be. The goal is to classify the system’s response as underdamped, critically damped, or overdamped. Figure 5 illustrates these characteristic responses, showing the motor’s actual position as it reacts to a step change in position.








