Proportional Integral Derivative PID Controllers
Terminology & Technicalities
Tutorials about PID are often very technical with a lot of mathematics that leave many people unable to comprehend. Our goal is try to explain PID controllers so that people can easily understand the theory behind them. On this first page we have to start out with terminology and some technical information so that you understand the basics of PID control. On the next page we will discuss PID in a more practical manner.
PID controllers are process controllers with the following characteristics:
Continuous process control
Analog input (also known as "measurement" or "Process Variable" or "PV")
Analog output (referred to simply as "output")
Proportional (P), Integral (I), and / or Derivative (D) constants
Examples of "continuous process control" are temperature, pressure, flow, and level control.
For example, controlling the heating of a tank. For simple control, you have two temperature limit sensors (one low and one high) and then switch the heater on when the low temperature limit sensor turns on and then turn the heater off when the temperature rises to the high temperature limit sensor. This is similar to most home air conditioning & heating thermostats.
In contrast, the PID controller would receive as input the actual temperature and control a valve that regulates the flow of gas to the heater. The PID controller automatically finds the correct (constant) flow of gas to the heater that keeps the temperature steady at the setpoint. Instead of the temperature bouncing back and forth between two points, the temperature is held steady. If the setpoint is lowered, then the PID controller automatically reduces the amount of gas flowing to the heater. If the setpoint is raised, then the PID controller automatically increases the amount of gas flowing to the heater. Likewise the PID controller would automatically compensate for hot, sunny days (when it is hotter outside the heater) and for cold, cloudy days.
The analog input (measurement) is called the "process variable" or "PV". You want the PV to be a highly accurate indication of the process parameter you are trying to control. For example, if you want to maintain a temperature of + or - one degree then we typically strive for at least ten times that or one-tenth of a degree. If the analog input is a 12 bit analog input and the temperature range for the sensor is 0 to 400 degrees then our "theoretical" accuracy is calculated to be 400 degrees divided by 4,096 (12 bits) = 0.09765625 degrees. We say "theoretical" because it would assume there was no noise and error in our temperature sensor, wiring, and analog converter. There are other assumptions such as linearity, etc.. The point being -- with 1/10 of a degree "theoretical" accuracy -- even with the usual amount of noise and other problems -- one degree of accuracy should easily be attainable.
The analog output is often simply referred to as "output". Often this is given as 0 to 100 percent. In this heating example, it would mean is the valve totally closed (0 %) or totally open (100 %).
The setpoint (SP) is simply -- what process value do you want. In this example -- what temperature do you want the process at?
How a PID Controller Works
The PID controllers job is to maintain the output at a level so that there is no difference (error) between the process variable (PV) and the setpoint (SP).
In this diagram the valve could be controlling the gas going to a heater, the chilling of a cooler, the pressure in a pipe, the flow through a pipe, the level in a tank, or any other process control system.
What the PID controller is looking at is the difference (or "error") between the PV and the SP. It looks at the absolute error and the rate of change of error. Absolute error means -- is there a big difference in the PV and SP or a little difference? Rate of change of error means -- is the difference between the PV or SP getting smaller or larger as time goes on.
When there is a "process upset", meaning, when the process variable OR the setpoint quickly changes -- the PID controller has to quickly change the output to get the process variable back equal to the setpoint. If you have a walk-in cooler with a PID controller and someone opens the door and walks in, the temperature (process variable) could rise very quickly. Therefore the PID controller has to increase the cooling (output) to compensate for this rise in temperature.
Once the PID controller has the process variable equal to the setpoint, a good PID controller will not vary the output. You want the output to be very steady (not changing). If the valve (motor, or other control element) are constantly changing, instead of maintaining a constant value, this could case more wear on the control element.
So there are these two contradictory goals. Fast response (fast change in output) when there is a "process upset", but slow response (steady output) when the PV is close to the setpoint.
Note that the output often goes past (over shoots) the steady-state output to get the process back to the setpoint. For example, a cooler may normally have it's cooling valve open 34% to maintain zero degrees (after the cooler has been closed up and the temperature settled down). If someone opens the cooler, walks in, walks around to find something, then walks back out, and then closes the cooler door -- the PID controller is freaking out because the temperature may have raised 20 degrees! So it may crank the cooling valve open to 50, 75, or even 100 percent -- to hurry up and cool the cooler back down -- before slowly closing the cooling valve back down to 34 percent.
How do PID Controllers Work
Common Sense / Practical Approach
Enough of the technical stuff -- let's look at PID control from a common sense / practical approach. On this page we will build a PID controller using Microsoft Excel so that you can see, and experiment with, the results that we are talking about.
Let's think about how we would design a PID controller
We focus on the difference (error) between the process variable (PV) and the setpoint (SP). There are three ways we can view the error.
The absolute error. This means how big is the difference between the PV and SP. If there is a small difference between the PV and the SP -- then let's make a small change in the output. If there is a large difference in the PV and SP -- then let's make a large change in the output. Absolute error is the "proportional" (P) component of the PID controller.
The sum of errors over time. Give us a minute and we will show why simply looking at the absolute error (proportional) only is a problem. The sum of errors over time is important and is called the "integral" (I) component of the PID controller. Every time we run the PID algorithm we add the latest error to the sum of errors. In other words Sum of Errors = Error1 + Error2 + Error3 + Error4 + ...
The dead time. Dead Time refers to the delay between making a change in the output and seeing the change reflected in the PV. The classical example is getting your oven at the right temperature. When you first turn on the heat, it takes a while for the oven to "heat up". This is the dead time. If you set an initial temperature, wait for the oven to reach the initial temperature, and then you determine that you set the wrong temperature -- then it will take a while for the oven to reach the new temperature setpoint. This is also referred to as the "derivative" (D) component of the PID controller. This holds some future changes back because the changes in the output have been made but are not reflected in the process variable yet.
Absolute Error / Proportional
One of the first ideas people usually have about designing an automatic process controller is what we call "proportional". Meaning, if the difference between the PV and SP is small -- then let's make a small correction to the output. If the difference between the PV and SP is large -- then let's make a larger correction to the output. This idea certainly makes sense.
We simulated a proportional only controller in Microsoft Excel (if you click on this link then you will download the Excel spreadsheet). Here is the chart showing the results of the first simulation:
In this first example, we assumed that there was no dead time, meaning, that if we made a change in the output of the controller, the input immediately changed. For example, zero dead time on our oven means that if we changed the temperature setpoint on the oven, then the temperature inside the oven instantly changed to the new setpoint (the oven did not require time to heat up or cool down).
The blue line represents a proportional constant of .1, the magenta lines represents a proportional constant of .2, the yellow line represents a proportional constant of .4, and the white line represents the setpoint (SP). From this graph, hopefully two things jump out at you. First, once the output settles out, the output (blue, magenta, and yellow lines) are no where near the setpoint (SP) (the white line). Therefore, some offset has to be added to the output to make the PV reach the SP. Second, the greater the proportional constant, the less the offset needs to be. For example the yellow line, with a proportional constant = .4 is closer to the white line than the blue line with a proportional constant of .1.
If you download the Excel spreadsheet of the PID controller simulator and look at the effects of increasing dead time you will notice that the outputs settle at the same output level -- it simply takes longer for the output to reach its final level.
In summary, automatic proportional (only) controllers are not very good because there is an offset that has to be continually adjusted.
Proportional and Integral Controllers
The integral portion of the PID controller accounts for the offset problem in a proportional only controller. We have another Excel spreadsheet that simulates a PID controller with proportional and integral control. Here is a chart of the first simulation with proportional and integral:
As you can tell, the PI controller is much better than just the P controller. However, dead time of zero (as shown in the above graph) is not common. So let's take a look when the dead time equals two.
Now this graph is starting to look more typical of a PID controller. Notice how the dark blue line quickly goes up to the SP (50) and cycles around 50 a little but quickly settles down. In contrast, the dark purple line way overshoots the SP of 50, going above 80, back down to 30, then over 50, and back and forth until it eventually settles down.
If you download the Excel spreadsheet and look through the different scenarios you will notice that the P & I parameters that look good for one dead time do not look optimal for another dead time. In other words, for each process element (valve, motor, pump, heater, chiller, etc) you are trying to control -- you will have different process characteristics and will have to determine the optimal P, I, and possibly D constants. Determining what these constants should be is called "tuning". Theoretically, you want to minimize the sum of absolute errors, as given in the spreadsheets.
Let's show one other graph to warn you about a very dangerous condition:
We wanted to show this graph to illustrate what can happen if you choose the wrong parameters. The green line illustrates an unstable or "out-of-control" controller. Notice how it continues to get worse and worse. This is not good. This is why you want to start with very small P, I, and D constants and increase them to improve performance. If you start with large constants, bad things can happen.
Derivative control takes into consideration that if you change the output, then it takes time for that change to be reflected in the input (PV). For example, let's take heating of the oven. If we start turning up the gas flow, it will take time for the heat to be produced, the heat to flow around the oven, and for the temperature sensor to detect the increased heat. Derivative control sort of "holds back" the PID controller because some increase in temperature will occur without needing to increase the output further. Setting the derivative constant correctly, allows you to become more aggressive with the P & I constants.
PID Controllers(Final Thoughts / More Information)
Actual PID Controllers
PID controllers can be stand-alone controllers (also called single loop controllers), controllers in PLCs, embedded controllers, or software in Visual Basic or C# computer programs.
Typically each manufacturer's PID controller acts differently than controllers from other manufacturers. In other words, do not expect PID controllers from different manufacturers to act exactly the same.
Many PID controllers today have an "auto tune" feature that will calculate good values for the P, I, & D constants for a process.
We typically use a product called Expertune which does exactly what it's name implies.
Remember that as a systems integrator you do not need to be a master of every technology. You are as good as the resources you manage. Therefore, learn what you can do, and what you can not do, and then call in the experts listed below to help you with the difficult applications.
Ziegler Nichols Tuning Method
There is a manual way of calculating PID constants known as the Ziegler Nichols tuning method. We will give a brief example using another Excel spreadsheet.
Initially set the integral and derivative constants to zero -- proportional control only
Increase the proportional constant until you get a sinusoidal wave with a constant amplitude (see Excel spreadsheet for examples at different deadtimes). In our Excel PID simulations, this sinusoidal wave occurs when the proportional constant = 1.0. See the chart below where the Deadtime = 1, Proportional constant = 1, and the period = 4. Note that the proportional constant of 1.0 was determined to give the process a constant amplitude wave.
For optimal P & I controller (no derivative), the proportional constant should be 0.45 times the proportional constant. In this case 0.45 times 1.0 = 0.45.
The integral constant is 1.2 / period of the sinusoidal wave. For deadtime = 0, the period is 2 so the optimal integral constant = 1.2 / 2 = 0.6. For deadtime = 1, the period is 4 so the integral constant = 1.2 / 4 = 0.3. For deadtime = 2, the period is 6 so the integral constant = 1.2 / 6 = 0.2. The new PI controller results are shown below.
More PID Information
We have only touched on the "tip of the iceberg" for PID controllers. For small, stand alone applications, the information you learned from this tutorial may solve many of the PID applications. For large, complex systems -- what we presented might only get you in trouble. As with any new ideas or technology -- start working on a small, non critical application first and as your experience grows then start tackling more complex projects.
Expertune -- makers of software that automatically determine what your P, I, & D constants should be. They also have much more elaborate products that look at the interactions of multiple parameters in control systems.