Sei sulla pagina 1di 7

How do PID Controllers Work Page 1 of 7

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.

1. 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.

2. 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 + ...

3. 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

http://www.htservices.com/Applications/Process/PID2.htm 2/8/2008
PDF created with pdfFactory Pro trial version www.pdffactory.com
How do PID Controllers Work Page 2 of 7

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

http://www.htservices.com/Applications/Process/PID2.htm 2/8/2008
PDF created with pdfFactory Pro trial version www.pdffactory.com
How do PID Controllers Work Page 3 of 7

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:

http://www.htservices.com/Applications/Process/PID2.htm 2/8/2008
PDF created with pdfFactory Pro trial version www.pdffactory.com
How do PID Controllers Work Page 4 of 7

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.

http://www.htservices.com/Applications/Process/PID2.htm 2/8/2008
PDF created with pdfFactory Pro trial version www.pdffactory.com
How do PID Controllers Work Page 5 of 7

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:

http://www.htservices.com/Applications/Process/PID2.htm 2/8/2008
PDF created with pdfFactory Pro trial version www.pdffactory.com
How do PID Controllers Work Page 6 of 7

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
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

http://www.htservices.com/Applications/Process/PID2.htm 2/8/2008
PDF created with pdfFactory Pro trial version www.pdffactory.com
How do PID Controllers Work Page 7 of 7

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.

We try to offer a fair and balanced opinion on every page of our website. We would appreciate more
information from other users to express their opinions which we will then incorporate. If you have
questions or comments please post them on our message board (see button in left hand column) so that
others can read and benefit.

http://www.htservices.com/Applications/Process/PID2.htm 2/8/2008
PDF created with pdfFactory Pro trial version www.pdffactory.com

Potrebbero piacerti anche