Program instructions
7.9 PID
S7-200 SMART
274 System Manual, 09/2015, A5E03822230-AC
In steady state operation, a PID controller regulates the value of the output so as to drive the
error (e) to zero. A measure of the error is given by the difference between the setpoint (SP)
(the desired operating point) and the process variable (PV) (the actual operating point). The
principle of PID control is based upon the following equation that expresses the output, M(t),
as a function of a proportional term, an integral term, and a differential term:
Output = Proportional term + Integral term + Differential term
=
C
*
C
0
t
initial
+
C
*
where:
Loop output as a function of time
C
Loop error (the difference between setpoint and process variable)
initial
Initial value of the loop output
In order to implement this control function in a digital computer, the continuous function must
be quantized into periodic samples of the error value with subsequent calculation of the
output. The corresponding equation that is the basis for the digital computer solution is:
Output = Proportional term + Integral term + Differential term
n
=
c
*
n
+
I
*
1
n
x
+
initial
+
D
* (
n
-
n-1
)
where:
n
Calculated value of the loop output at sample time n
n
Value of the loop error at sample time n
n-1
Previous value of the loop error (at sample time n - 1)
I
Proportional constant of the integral term
initial
Initial value of the loop output
Proportional constant of the differential term
From this equation, the integral term is shown to be a function of all the error terms from the
first sample to the current sample. The differential term is a function of the current sample
and the previous sample, while the proportional term is only a function of the current sample.
In a digital computer, it is not practical to store all samples of the error term, nor is it
necessary.