PID Controllers in Closed Loop Control Systems – PLC Basics

In the previous article, we discussed the meaning and importance of closed-loop control systems and we talked about two of the main types of closed-loop control which are the on/off and on/off with tolerance controllers. In this article, we will discuss another type of closed-loop controller and arguably the best one, the PID controller.

Contents:

  • What is a PID controller?
  • How does a system behave with a PID controller?
  • What are the different parts of a PID?
    • Proportional P.
    • Integral I.
    • Derivative D.

What is a PID Controller?

A PID controller is an instrument or a controller that is used in automation processes to regulate/control the value of a process parameter such as temperature, level, etc.

Like any other closed-loop control system, a PID needs feedback. This feedback signal along with the set point needed creates what is known as an error. The PID controller will use this error to decide its system behavior to try and reduce this error to zero, meaning reaching the set point. The PID is considered to be the most accurate and stable type of controller.

 A PID controller has three main parts:

  • Proportional gain P
  • Integral gain I
  • Derivative gain D

Together they form the PID controller.

In this article, we are only going to discuss the working principle of the PID and how a process would behave when controlled with a PID. we will not get into the programming of the PID in the TIA Portal, this will be for another article. In this article, however, there will be a simple program simulation to show how the PID behaves with parameters change.

How does a system behave with a PID controller?

To better understand how a PID works and how the system behaves with a PID, we will use the same tank simulation system we used in the previous article to explain on/off controllers. In this tank simulation, we have a pump that operates with a flow of 0-10 liters/sec in corresponding to a 0-10v signal.

The pump is used to feed water to a 50 liters capacity tank. In the simulation system, there are some defined parameters to give the system a real-like behavior.

These parameters are:

  • %outflow: representing the demand of the system from the tank.
  • Random disturbance: to represent any random noise that might affect the system.
  • Idle time: to give the pump a real-like behavior when starting or stopping.

 We will use a PID controller block inside the TIA Portal to control the tank level of our system. We will not show any programming steps in this article as it focuses on understanding the principles of PID working.

What are the Different Parts of a PID?

As we mentioned, a PID has three main parts which are the P, I, and D component of the controller. To understand what they are and how they behave, we need to first understand what an error is.

Error

Error is the difference between your set point (the value you want to reach) and the actual value you are at.

So, if I need the tank level (as in our previous system) to be 30 liters and the tank is now at 10 liters then the error is now 20 liters.

The maximum error you can have in your system will be the difference between the highest set point you can ask for, which is 50 liters for our tank, and the lowest point it can be at, which is zero liters. So, the maximum error is 50 liters.

Why is that important?

Because the bigger the error, the stronger action the PID controller will take.

Proportional (P) Gain

 Imagine you’re heating water in a pot on a stove. Your goal is to keep the water at a specific temperature. The difference between the desired temperature and the current temperature will be the error. Using proportional control, you adjust the stove’s heat based on the size of the error.

For instance, if the water is far below the desired temperature, you turn up the heat all the way. As the temperature gets closer to the desired value, you reduce the heat gradually. This way, you’re constantly proportional to the error.

In Proportional control the controller output = P gain * %error

So, for example in our tank system if the P gain is set to 1 that means the controller output will be 1*%error. So if the % error is 25%the controller will turn the pump to 25% of its full power. See the following simulation video.

As you can see, at the start, the set point was set to 25 liters, and the P gain was set to 1, you can see the controller output starts at 25% which corresponds to 2.5 liters/sec for the pump. And then the output starts to go down as the tank is being filled and the error is getting lower.

In the simulation video, we simulated three different values to the P gain.

  • First, the P gain was set to 1 and the pump started at 2.5liters/sec, then the flow started to go down as the error decreases.
  • Secondly, the P gain was set to 2 and the pump started at 50% of the full power which is 5 liters/sec, then again started to go down as the error decreases.
  • Finally, we set the P gain to 4, and the pump started at 100%of the full power which is 10 liters/sec, then again started to go down as the error decreases.

As you can see the controller output is proportional to the error value, hence the name proportional or P. That means as the tank starts to be filled with water and the level increases the error will decrease because the level is now closer to the set point.

As the error decreases the proportional gain of the controller will also decrease. And that is why reaching the set point with only a proportional gain is not always achievable, because as the error approaches zero so will the controller output. And that is why you will have a small error that cannot be regulated with the P gain alone. This is also called the steady-state error. See picture 1.

PID Controller Steady State Error

Picture 1. Steady-state error with P gain

See the next video where we increase the P gain very much.

As you can see, the level never reaches the set point. Even when I increase the gain to a very high value, it will go over our set point and it will start to oscillate, see picture 2.

PID Controllers in Closed Loop Control Systems

picture 2. Oscillation with high P gain.

Oscillations are not something you want in a control system. And that is where the integral part of the PID controller comes in handy.

Integral (I) Control

Continuing with the tank level example, you saw that the P controller alone couldn’t achieve the required set point. And there is always a steady state error present. Integral control steps in to address this steady state error. It sums up past errors and applies a correction based on the accumulated error.

So, if you’ve consistently been below the desired tank level, the integral control will gradually increase the pump power to compensate for the persistent error to reach the desired set point. See the following video.

as you can see, we started with a P gain of 2, the level saturated at below set point, but when we used an integral part of the PID, the level started to increase.

At the beginning, there was an overshoot but after a while, the level stabilized at the required set point. And that is why the integral part is a very critical part of the PID.

You should know that if you want to improve the system response. To reduce the time needed to reach the set point or to reduce the overshot, more attention will be made to tuning the parameters

You should also know that the compact PID block in Siemens PLCs which we are using in our simulation, works in such a way that it has to have a proportional gain, if the P gain is zero, the PID will not have any effect even if the I and D parameters have values. That is why we couldn’t simulate the behavior of the system with only the I part as you saw in the previous video.

Derivative (D) Control

Now, imagine you’re driving a car and trying to maintain a constant speed. As you start going uphill, you might apply more gas to prevent the speed from dropping too much. However, if you suddenly crest the hill and start going downhill, the car might accelerate too much because of the extra gas.

Derivative control helps in situations like this. It looks at the rate of change of the error. If the error is changing rapidly (like when you suddenly switch from uphill to downhill), it applies a counteracting control action.

In our tank example this means that if there was a sudden change in the error, the derivative control will take an aggressive action to counter the effect of that sudden change. But as long as the changes in %error are steady and slow the derivative action will not have much effect. See the following video.

As you can see, when the set point changes suddenly leading to the error changing also suddenly the controller action was aggressive due to the use of the derivative part. See picture 3.

Basics of PID Controllers

picture 3. The aggressive action of the Derivative controller.

Putting all of the previous information together, a PID will use the three different controllers P, I, and D to regulate your process value and reach your set point as fast as possible and as smooth as possible.

You can try the simulation program attached to the article and see how the system will behave with different values of PID parameters. Try also to play with the %outflow and random disturbance parameters and also see how the PID will behave. Until you have a good idea about how the PID works.

Download: PID Logic

In the next articles, we will show how to configure and program our PID in TIA Portal and how to tune the PID and different types of PID in TIA Portal.

Conclusion

  • PID is one of the most accurate closed-loop controllers.
  • PID uses proportional, integral, and derivative gains to try and regulate the process value to the required set point.
  • Any change in the PID parameters will lead to a change in the system behavior, which is why it is necessary to make good tuning to the PID parameters to make sure you have the best system behavior.

If you liked this article, then please subscribe to our YouTube Channel for Instrumentation, Electrical, PLC, and SCADA video tutorials.

You can also follow us on Facebook and Twitter to receive daily updates.

Read Next:

Don't Miss Our Updates
Be the first to get exclusive content straight to your email.
We promise not to spam you. You can unsubscribe at any time.
Invalid email address

Leave a Comment

Share via
Follow us and never miss an update!