The design of a closed-loop positioning system demands that special trade-offs be made in loop gain and bandwidth to ensure stability. Otherwise, the system may oscillate during a move or exhibit other behavior that degrades positioning accuracy. One way of providing the needed stability is by adding special filtering in the position loop.
Filtering is also used to reduce following error to essentially zero in certain systems. The usual technique is to anticipate a certain amount of following error by integrating. Integration effectively causes the processor to command a higher velocity than it would normally, thus reducing the amount of position error.
This integration is applied to the position feedback from the encoder. Differentiation filtering is also used. This generally compensates for the mechanical time constant of a motor by incrementing or decrementing the position feedback depending on how fast it changes. Also, feedback is multiplied by a constant or proportional term that is basically a gain.
The three actions -- proportional, integral, and differential (PID) -- can be thought of as implementing a bandpass characteristic in the position feedback loop. By changing constants associated with each of the three operations, the system can be tuned for stability under different loads and position resolutions.
Some systems implement only the PD part of PID functions. This is called phase-lead filtering because it introduces positive phase over some frequency band. The effect is that of a high-pass filter.