Many aspiring engineers have trouble understanding closed-loop PID controllers. Drones are one of the most prominent examples of PID control and a good way to understand how it works. Drones use PID control in flight to control their position, and the driver should tune it right to get a smooth ride.

What is PID control?

Before we get into the theory, let’s break down the acronym. PID stands for “proportional-integral-derivative.” You probably learned these terms in calculus at some point. But we won’t dig in on how to tune a PID controller here, so no calculation needed.

In closed-loop systems, if the process value (PV) differs from the reference value or setpoint, then you have an error. The PID controller must bring this error to zero, thus bringing the PV to its setpoint.

Let’s say it’s a cold day and you get to work before everyone else. The temperature in the office sits at a chilly 10 degrees Celsius, so you set the heater to 18. The heater controller realizes that it has an error of 8 degrees between the PV, the current room temperature, and the reference value, the temperature you set. It must now warm the room until this error reaches zero, bringing the room temperature to 18 degrees. To do so, it uses an equation with three components – proportional, integral, and derivative.

How does a PID controller work?

Now we have an idea of what a PID controller does. But how does it actually work? I’ll break down what each component does and try to use intuitive examples. I could use a drone here, but it’s harder to visualize and few people know how to drive one. So I’ll stick with a popular example, the car.

Proportional

Let’s start with the proportional component! In the equation, we can see that the proportional part is defined by a gain (Kp), which multiplies the error. This means that if your output changes abruptly, then you have to take a bigger step to get to your setpoint. Bump this value too high and you’ll end up with an unstable system, but we can discuss tuning issues in another article. Into the example!

Imagine you’re driving a car, waiting for a traffic light to turn green. You’re in a hurry and want to drive at the speed limit, 40 miles an hour. Here we have our process value, zero miles an hour in the static car, and our reference value, the speed limit. When the light turns green, you press the pedal slowly, increasing your speed until you reach 40. Note that I used “slowly” in the last sentence, right?

What happens if you just stomp the pedal? This applies a big gain to your system, and it’ll probably go over the target speed. If you keep your gain high, when you go over the targeted speed, you’ll get a negative error. To correct this error, you stomp the brake. Your speed drops below the reference value, so you stomp the gas to correct it. At this point, your car is stuttering down the road like a drunken goat. This represents the unstable system I mentioned earlier.

Integral

Okay, on to the integral component. You’re in your car, and your friend is in a car in the lane beside you. You want to drive side by side with him.

In the beginning you’re a couple of meters behind him. This distance is your system error. You accelerate, trying to align your car with your friend’s. When you’re side by side, you might get the exact same speed as your friend, but more often than not, there will be a small difference which will lead to a small error. This small error is called the steady state error in control systems. The integral component corrects this error.

It measures this small error and records it. On the next reading, it adds this error if the system still hasn’t reached the reference value. In doing so, the error doubles for each reading, making the proportional control tune a bit more. This goes on until you reach the reference value. Then the integral component resets to zero.

This control evaluates past errors your system had that were too small for the proportional component alone to correct.

Derivative

Last but not least, we have the derivative component. This component sometimes gets left out of the equation, depending on your system. In fact, many controllers are only PI controllers. Why? Let me explain what it does so you can figure it out by yourself. If you’re still stuck, then I’ll tell you.

Imagine another driving scenario, where you’re getting close to a traffic light as it turns yellow. You should stop at the light when it turns red, so that’s your reference value. However, you’re doing 40 and are very close to the light. If you apply only the proportional control, then you’ll shoot past the light and get a negative error (and probably a ticket, if a cop or a traffic cam is nearby). So you put the car in reverse to back up, trying to reach the reference value.

The derivative component can foresee the distance you would go past the light, and forces the controller, in this case you, to slow down faster to avoid the negative error.

So why can we sometimes leave this component out of our control system? Well, if you don’t have abrupt changes in your reference value or don’t change your process value too fast, then the PI controller should suffice.

Conclusion

You can use a PID controller to control the temperature of a room with a heater, to make sure your drone flies smoothly, or to control the positioning of a valve or the power of a pump in process automation.

Even though PID controllers are an old and simple method of control, they’re still widely used in the industries. In fact, most plant controllers, whether simple or complex, still use PID.

Recommended articles

HART handheld communicator: setup, applications, and use guide

Analytics Articles Control System Industry 4.0 Wireless