PID Controller For Absolute Beginners
In this article you will find the very basics about PID Controllers.
What is a PID Controller?
A PID controller is a piece of machinery that is used to control a system. Think about an AC that will sense the temperature of the room and bring it to a certain temperature that you choose. The machine will sense the temperature of the room, compare it to the temperature that you choose, and work the cooling/warming fans according to that right? Well that all happens thanks to a PID Controller!
A PID controller is a closed loop system, which means it works as a loop as seen the diagram below.
Following the diagram you will see that when a command is received by the system, it will go through the controller. The controller will give out a signal which will be processed by (or planted to) the system, and the output will be used as a feedback for the controller to update itself and cover the system’s needs, hence creating the ‘closed loop system’.
In sum, the PID Controller will use a feedback system to take the Output signal and compare it to the received signal (aka. Setpoint). The difference between the Output value and the Setpoint value will give us the Error, and the goal of a PID Controller is to minimize the error by processing it.
Let’s explain it with the AC example. The temperature we decide that we want will be the Setpoint, and the current temperature of the room will be the Output (also called Process Variable or PV) value we receive from the Process. The Process here will be the thermometer inside the AC system. At each loop, the controller is going to compare the current temperature (output) to the desired temperature (setpoint), and calculate the difference (error). Then the controller will process the error, update itself and this will loop will continue until the system reaches the minimum error value. The error value will be an absolute number.
How does the PID Controller work?
PID is short for Proportional Integral Derivative, meaning the controller uses three different control systems (Proportional, Integral, Derivative) to minimize the error. In the diagram you will see the basic logic of how each control system works. After each control system is used the outputs of these systems will be summed and compared to the setpoint to calculate the error. Based on the error value, the parameters such as Kp, Ki and Kd inside the PID controller will be updated until the perfect value that will minimize the error is found.
To better grasp the following content, I would like for you to imagine the machine as a car and the PID controller as a driver.
1. Proportional Control
The proportional control will simply multiply the error signal value with a parameter called Kp in order to minimize the error. Kp parameter will be calculated by practicing of the system over and over again. You can think of this as the steering wheel. The more you are to the left of the road the more you will turn the steering wheel to the right and vice versa until you are right on the road. The proportional control will compare the output signal to the setpoint signal and change the direction by playing with the Kp parameter’s value.
However, even though the proportional control is the largest contributor to the correction and can be used by itself, using this type of control alone will not be enough to control the output signal. If you use the proportional control alone, you will come across a problem called “overshooting”, where the Kp is chosen a bit too high and as a result the output signal will be far above the setpoint. You can think of this as driving too much to the right of the road, turning the steering wheel to the left, but ending up going too much to the left this time. Mathematically, going right might be a positive Kp value and if so, going left will be a negative Kp value.
Also if you use the proportional control alone the time period required for our output signal to settle, aka. settling time, will be too long. To stabilize the system we will need the help of some other forms of control like Integral Control or Derivative Control as well.
2. Integral Control
The difference between the proportional control and the integral control is that, the integral control will give you a correction based on the sum of all the errors from the very beginning of the process while the proportional control will give you a correction simply based on that very moment’s data. Think of integral control as noticing that even though you try to drive right on the road you have been going slightly to the right from the beginning of the drive, and correcting your behavior according to that.
Integral, as you might remember from your math classes, is an equation which will give us the sum of the space under a curve. In this context we will use integral to calculate the sum of the space between the setpoint signal and output signal. This area will give us the error, and in order to minimize the error we will create a new signal that will give us the exact same area on the opposite side of the setpoint signal through changing the Ki parameter.
Just like in the Proportional Control, based on the chosen Ki parameter we might have problems such as overshooting and extra long settling time. However, Integral Control will give us better results as it will analyze the system’s actions in a wide period of time.
3. Derivative Control
The derivative control is what will help you avoid the overshooting problem. Think of this as this, you are driving to the left of the road you turned the steering wheel to the right. The closer you are to the road, the less you will turn your steering wheel to the right thanks to derivative control.
The derivative control is based on the variation of the error value between moments, and therefore it cannot be used alone unlike the other control methods.
Conclusion
A PID controller is a control mechanism that will use Proportional, Integral and Derivative Control methods all at once. Each control method will have a different effect on the system. In this context; you will find that there can be PI controllers, PD controllers or PID controllers based on the requirements of the system.
The parameters Kp, Ki and Kd (aka. the gains of the system) each will vary based on the properties of the system that the controller is used for.
A PID controller is very popular among other types of controllers for that it’s easy to implement to the system and very effective.