Program instructions
7.9 PID
S7-200 SMART
System Manual, V2.3, 07/2017, A5E03822230-AF
315
Understanding the elements of the PID equation
Proportional term of the PID equation: The proportional term MP is the product of the gain
(K
C
), which controls the sensitivity of the output calculation, and the error (e), which is the
difference between the setpoint (SP) and the process variable (PV) at a given sample time.
The equation for the proportional term as solved by the CPU is:
MP
n
= K
C
* (SP
n
- PV
n
)
where:
MP
n
Value of the proportional term of the loop output at sample time n
K
C
Loop gain
SP
n
Value of the setpoint at sample time n
PV
n
Value of the process variable at sample time n
Integral term of the PID equation: The integral term MI is proportional to the sum of the error
(e) over time. The equation for the integral term as solved by the CPU is:
MI
n
= K
1
e
n
+ MX = K
C
* (T
S
/ T
I
) * (SP
n
- PV
n
) + MX
where:
MI
n
Value of the integral term of the loop output at sample time n
K
C
Loop gain
T
S
Loop sample time
T
I
Integral time (also called the integral time or reset)
SP
n
Value of the setpoint at sample time n
PV
n
Value of the process variable at sample time n
MX
Value of the integral term at sample time n-1 (also called the integral sum or the
bias)
The integral sum or bias (MX) is the running sum of all previous values of the integral term.
After each calculation of MI
n
, the bias is updated with the value of MI
n
which might be
adjusted or clamped (see the section "Variables and Ranges" for details). The initial value of
the bias is typically set to the output value (M
initial
) just prior to the first loop output calculation.
Several constants are also part of the integral term, the gain (K
C
), the sample time (T
S
),
which is the cycle time at which the PID loop recalculates the output value, and the integral
time or reset (T
I
), which is a time used to control the influence of the integral term in the
output calculation.
Differential term of the PID equation: The differential term MD is proportional to the change
in the error. The CPU uses the following equation for the differential term:
MD
n
= K
C
* (T
D
/ T
S
) * ((SP
n
- PV
n
) - (SP
n-1
- PV
n-1
))