Motka Articles - Issue 2

PID Motion Control in Plain English

Motion control is all about getting your motors to move to the position you want. The best way is to achieve this is for the motor to know the required correction and move accordingly. The required correction is simply the difference between the current and the desired position. This is also known as the error.

Control Loop

In practice, apart from motor itself, additional hardware will be required to perform various tasks. An encoder will read the existing position. A motion controller will compute the error and command the driver to move the motor accordingly. We call the above a closed-loop system.

Simplified PID Overview

As you might have guessed, the whole idea is about reducing the error to zero. Using the error information, control logics can be designed. PID (Proportional, Integral, and Derivative) scheme is the most common logic used. It consists of three sub-schemes, each performing a specific function.

Let us discuss the terms in further detail, using the popular analogy of parking a car.

Control Loop

The goal is to park the car such that the front is exactly in line with the parking point.


The most straightforward way is to assign a ratio between the error and the correction required. We call this the proportional gain. This ratio or gain will determine how sensitive the correction is towards the present error. The larger the number, the more aggressive the correction. This term is the main player in this motion control scheme.

Proportional analogy 1

To park the car, the driver will move the vehicle closer towards the desired position.

Proportional analogy 2

The correction action is proportioinal to the error. This is somewhat similar to the driver's intuition. Longer the distance, harder the accelerator will be applied.

Proportional analogy 3

The proportional gain is similar to the sensitivity of the accelerator. A higher gain means that the accelerator is more sensitive, which would in turn drive the car faster towards the end point.


Proportional control may not be sufficient to handle the steady-state error as mentioned earlier. This usually occurs when the existing position approaches close to the desired position. The small error will call only for a proportionally smaller corrective action, which is not sufficient to overcome the unforeseen resistance such as friction. To break out of this deadlock situation, we need a mechanism to pile up errors over time. This will then translate into a stronger corrective action. The integral term is made to do this by accumulating the stubborn error. Just like before, a gain will be assigned to this memory term. Note that integral gain is usually much smaller compared to the proportional gain to avoid excessive correction. In addition, the accumulation cannot take place infinitely. An anti-windup will be in place to limit the accumulation.

Integral analogy 1

When the car is very close to the desired position, the driver's intuition tells him to only apply a very light tap on accelerator. However, due to the friction in the wheel axies, the light tap on accelerator is barely enough to move the car.

Integral analogy 2

It is probably unwise to increase the sensitivity of the accelerator. This is to avoid an overly reactive accelerator. An althernative is to remember and accumulate the small error over time. For every moment with error, the accelerator will be applied slightly harder. The integral gain will help to regulate the error accumulation. Eventually, all small errors will be closed down if they persist for extended periods.


Apart from the size of the error, we can also make use of how fast the error is changing to further improve the response. The rate of change is basically the difference between the existing error and the previous error over a period of time. In practice, when the error is closing down very fast, an overshoot is likely happen as the momentum of the moving part will carry it beyond the desired position. Oscillations about the desired position will then follow until they reach and stay within small error band. We call this the settling time. With a differential term, we can anticipate the overshoot and reduce the settling time as well as the oscillation magnitude. In actual applications, differential term is seldom used. Its performance is very sensitive towards the noise in encoders.

Derivative analogy 1

With a relatively short distance to go, the car is still moving at a very fast speed. The momentum of the car will carry it beyond the desired position resulting in overshoot.

Derivative analogy 2

Brakes can be used to slow the car down. The faster the car, the harder the brakes will be applied. This will reduce the overshoot. Here, the sensitivity of the brakes is similar to the drivative gain.

PID control can be summed up mathematically in technical terms as follows.

Derivative analogy 2

In practice, given the complexity of the combined effects, a trial and error process is usually required. The three parameters will be varied until we get a balanced performance to meet requirements. This process is called tuning the PID gains.

Practical Applications

Almost all the control scheme for motors out there uses PID. Hence it is essential to have an understanding of how the three terms work to facilitate tuning. More importantly, the motion controller hardware must be able to support the work of tuning. Most motion controllers have sophisticated instruction manuals. For a simple PID application, they cost an exorbitant amount.

At Motka, we provide motion controllers which are easy to operate and fairly priced to suit the all common needs. Visit us for more details.