Program instructions
7.9 PID
S7-200 SMART
318
System Manual, V2.3, 07/2017, A5E03822230-AF
7.9.4
Converting the loop output to a scaled integer value
The loop output is the control variable, such as the throttle setting of the cruise control on an
automobile. The loop output is a normalized, real number value between 0.0 and 1.0. Before
the loop output can be used to drive an analog output, the loop output must be converted to
a 16-bit, scaled integer value. This process is the reverse of converting the PV and SP to a
normalized value. The first step is to convert the loop output to a scaled, real number value
using the formula given below:
R
Scal
is the scaled, real number value of the loop output
M
n
is the normalized, real number value of the loop output
Offset is 0.0 for unipolar values
is 0.5 for bipolar values
Span
is the maximum possible value minus the minimum possible value
= 27,648 for unipolar values (typical)
= 55,296 for bipolar values (typical)
The following instruction sequence shows how to scale the loop output:
MOVR VD108, AC0 //Moves the loop output to the accumulator
-R
0.5, AC0
//Include this statement only if the value is bipolar
*R
55296.0, AC0 //Scales the value in the accumulator
Next, the scaled, real number value representing the loop output must be converted to a 16-
bit integer. The following instruction sequence shows how to do this conversion:
ROUND AC0, AC0
//Converts the real number to a 32-bit integer
DTI
AC0, LW0
//Converts the value to a 16-bit integer
MOVW LW0, AQW0 //Writes the value to the analog output