Professional Documents
Culture Documents
PID
Tip No. 32
SIMATIC
S7-200 Tips
Group
6
Topic
PID Controllers for the S7-200 CPU 214
Overview
This programming example shows a method for programming a Proportional Intergral Derivative
(PID) controller on a CPU 214. The example is already a fully functioning program, needing only
for the user to tie the actual inputs and outputs to appropriate variables to be a working
controller.
To prepare a user to make these programming changes, the text will explain the basics of the
PID controller implemented in the sample code. Below is a brief outline for the rest of this
document:
1. What does the example program do?
2. Where do you use a PID controller?
3. Auto Mode vs. Manual Mode
4. What does a PID controller do, and how?
5. What are the Sample, Gain, Rate, and Reset?
6. How is the Error figured?
7. How is the Proportional term figured?
8. How is the Integral term figured?
9. How is the Derivative term figured?
10. What if the final Output is too high?
11. What should the user add to make the program work for his system?
12. Adjusting the Reset, Rate, Gain, Sample time and Mode during run-time
Hardware Requirements
SIMATIC S7-200 CPU 214
NOTE: PID will only work on a SIMATIC S7-200 CPU 214 that supports real (floating point)
math.
page 1 / 21
S72_32e.doc
Version 2.0
SIMATIC S7-200 customers have free use of the application tips. These tips are only a general approach to using the S7-200 with various applications.
Your specific application may be different. It is your responsibility to use the SIMATIC S7-200 properly in your applications.
S7-200 Tip
PID
Tip No. 32
PID Explored
What does the example program do?
This compilable programming example is a skeleton program for a true PID controller and, as
such, requires that the user make a few additions (i.e. read/write input/output variables) before it
is fully functional. Before discussing these, however, lets get a better feel for what a PID
program actually does through a brief example.
Steam
Steam Flow
Turbine
Water Tank
Hot Plate
Temperature
Control
Hot Plate
SIEMENS
Output
CPU214 running a
PID program.
Temperature
Control
page 2 / 21
S72_32e.doc
Version 2.0
SIMATIC S7-200 customers have free use of the application tips. These tips are only a general approach to using the S7-200 with various applications.
Your specific application may be different. It is your responsibility to use the SIMATIC S7-200 properly in your applications.
S7-200 Tip
PID
Tip No. 32
The variable which represents the state of the system being controlled is called the Process
Variable. In our example above, you can see that the rate at which the steam spins the turbine
is a good indicator of the event that we are trying to control: the speed at which the water is
being boiled off. The output is the variable which, being altered by the controller, can affect the
process variable by different degrees based on its intensity -- By turning the hot plate up, the
water boils more quickly, more steam is produced, and the turbines speed increases.
Therefore, when a variable that accurately reflects the state of the process and an adjustable
control which proportionally affects the process variable, then it is possible to use a PID
controller. Common systems using PID controllers are air conditioning systems, solution mixing,
heaters, etc.
Auto Mode vs. Manual Mode
There are two settings available on our PID controller. Putting a controller in Manual mode
causes the PID loop do nothing, so that the user can directly control the output. The second,
Auto, is the mode in which the PID loop is actually controlling the system. For the rest of this
text, it will be assumed that the controller is in Auto mode.
What does the PID controller do, and how does it do it?
Quite simply, a PID controller adjusts the value of its output to try and balance the value of the
process variable to a given setpoint. To calculate the output value for a given instance, the
controller finds the value of three different terms (using its user defined Sample time, Gain,
Rate, and Reset values along with the calculated Error value): a Proportional term, an Integral
term, and a Derivative term.
2XWSXW 030,0'
Formula 32.1
What are the Sample, Gain, Rate, and Reset, and where do they come from?
The sample rate is the cycle time (in milliseconds) at which the PID loop recalculates the output.
The gain controls the sensitivity of the output calculation by affecting the influence of all the
terms. The reset is a time given in milliseconds which is used to increase or decrease the
influence of the Integral term in the equation. Finally, the rate value is used to control the
influence of the Derivative term in the equation. Each of these values needs to be preset by the
user before the PID controller starts.
If the user does not want integral action (no I in the PID calculation), then a value of infinity
should be specified for the integral time. If the user does not want derivative action (no D in the
PID calculation), then a value of 0 should be specified for the derivative time. If the user does
not want proportional action (no P in the PID), then a value of 0 should be specified for the gain
(gain is normally a multiplier in the integral and derivative coefficient calculation, but is removed
from the coefficient calculation, if gain = 0, to allow I, ID, or D loop control).
page 3 / 21
S72_32e.doc
Version 2.0
SIMATIC S7-200 customers have free use of the application tips. These tips are only a general approach to using the S7-200 with various applications.
Your specific application may be different. It is your responsibility to use the SIMATIC S7-200 properly in your applications.
S7-200 Tip
PID
Tip No. 32
39 UDZB39PD[BYDO
Formula 32.4
How is the Proportional term calculated?
The proportional term, MP, is calculated using the following equation:
*DLQ (UURU
03
Formula 32.2
Going back to our earlier example with the water tank, the proportional term says that as the
speed of the turbine increases further above the setpoint, the heat is decreased proportionally to
bring the speed down. As the turbine slows below the setpoint, the heat is increased to
proportionally to bring the speed up.
How is the Integral Term calculated?
The integral term, MI, is calculated using the following equation:
,
(UURU
%LDV&,
Formula 32.3
In this equation, two new terms are introduced. The first, CI, is the coefficient of the Integral
term, and is calculated from the Reset:
&, *DLQ
6DPSOH5HVHW
Formula 32.4
Both the Sample and Reset terms were introduced earlier, but in this equation their uses
become apparent. The larger the Reset value is, the less impact the integral term will have on
the output, while larger Sample times give it a bigger influence (Sample time also affects the
Derivative term, which will be explained later).
page 4 / 21
S72_32e.doc
Version 2.0
SIMATIC S7-200 customers have free use of the application tips. These tips are only a general approach to using the S7-200 with various applications.
Your specific application may be different. It is your responsibility to use the SIMATIC S7-200 properly in your applications.
S7-200 Tip
PID
Tip No. 32
The Bias term in Formula 32.3 represents (technically speaking) the area under the curve of a
graph plotting the Error vs time.
Abstractly, however, the Bias value (ideally) grows to an output level that keeps the system
stable, letting the Proportional and Derivative terms handle any small fluctuations. In relation to
our water tank example from earlier, this means that eventually the Bias portion of MI would be
the only significant contribution to the final output value, and the MP and MD terms would only be
active (non-zero) when a fluctuation occurred.
At a time n the equations for , and the Bias term are:
,Q
Formula 32.5
How is the Derivative term calculated?
The derivative formula for a given time n is calculated with the following equation:
0' &'
39Q39Q
Formula 32.6
This formula only introduces 1 new term, CD, which is calculated using Formula 32.7.
&'
*DLQ 5DWH6DPSOH
Formula 32.7
The Sample term (which is also used in figuring CI) is the sample time from earlier. In the
Derivative term, the Sample time is indirectly proportional to the derivative component, while the
Rate is directly proportional.
What if the final output value is too high?
During many processes (such as the water tank example earlier), the Process variable doesnt
respond immediately to a change in the value of the output -- if the water in the tank were ice
cold, then even an output of 100% is not going to cause an instantaneous increase in steam
flow. Likewise, setting the output to 0% when the water is boiling doesnt provide an immediate
reduction in steam production.
Because of this system inertia, the output value for a give time could take on a value greater
than 100% or less than 0%. In response to this, the PID program implements Output Clamping.
If the output is greater than 100%, then it is clamped to 100%. If the output falls lower than 0%,
then it is held to 0%.
page 5 / 21
S72_32e.doc
Version 2.0
SIMATIC S7-200 customers have free use of the application tips. These tips are only a general approach to using the S7-200 with various applications.
Your specific application may be different. It is your responsibility to use the SIMATIC S7-200 properly in your applications.
S7-200 Tip
PID
Tip No. 32
The only problem left to solve lies with the Bias portion of the Integral term. When the output for
a system remains at 100% for a long period of time (such as when heating up cold water in our
tank from earlier), the integral sum (which the Bias term represents) can grow to extremely large
values. This means that when the variable starts responding, the Bias term will be keeping the
calculated output well over 100% until it can be wound down. This generally results in the output
swinging wildly from one limit to the other, but can be avoided using Bias Clamping.
There are a few different types of Bias Clamping, but the only pertinent one here is the one used
in the program. There are two different conditions which cause Bias clamping to occur and two
formulae as well:
,I2XWSXW!
%LDV 030'
Formula 32.8
,I2XWSXW
%LDV 030'
Formula 32.9
As the formulae show, when the Output grows to be greater than 1, the value of the Bias is
adjusted so that the sum of MP, MD, and the Bias will be 1. Likewise, when the Output slips
below 0, the value of the Bias is adjusted so that the above sum will be 0. The adjusted Bias
value is then clamped such that its maximum value is 1 and its minimum value is 0.
What should be added to make the program work for the system?
1. Read in the Process Variable
2. Write the Output
3. Set the Setpoint
4. Adjust the scale for the Input and Setpoint
5. Adjust the scale for the Output
6. Adjust the Reset, Rate, Gain, and Sample time values.
page 6 / 21
S72_32e.doc
Version 2.0
SIMATIC S7-200 customers have free use of the application tips. These tips are only a general approach to using the S7-200 with various applications.
Your specific application may be different. It is your responsibility to use the SIMATIC S7-200 properly in your applications.
S7-200 Tip
PID
Tip No. 32
VD3020 (real)
VD3016 (real)
VD3008 (real)
VD3012 (real)
Adjusting the Reset, Rate, Gain, and Sample time, and Mode during run-time
The Reset, Rate, Gain, and Sample time values are all set during the first cycle through the PID
loop, and any subsequent changes to the values in VD3008-VD3020 will not be reflected in the
programs operation unless the update bit of the control byte is set. The control byte is VB3001,
and the update bit is bit 7. When V3001.7 is 1, then on the next cycle through the PID loop, all of
the above values will be updated.
The control byte can also be used to change the PIDs mode. When the update bit is set, the
value in V3001.0 indicates the new mode. A value of 1 indicates Auto, while a 0 indicates
Manual.
The program size is 335 words.
page 7 / 21
S72_32e.doc
Version 2.0
SIMATIC S7-200 customers have free use of the application tips. These tips are only a general approach to using the S7-200 with various applications.
Your specific application may be different. It is your responsibility to use the SIMATIC S7-200 properly in your applications.
S7-200 Tip
PID
Tip No. 32
Main Program
// Description:
// This S7-200 user program is intended to implement a simple PID loop. The body of the PID loop is
// embedded in a user interrupt routine attached to a timed interrupt. A block of V memory is reserved for
// the use of the PID algorithm, starting at VB3000. This loop data area is divided into 2 sections, user area
// and a working variable area, as shown below:
//
//
VB3000
-> control_byte
[bit field, described below]
//
VB3001
-> status_byte
[bit field, described below]
//
VW3002
-> raw_PV
[signed integer, range 0-32000]
//
VW3004
-> raw_SP
[signed integer, range 0-32000]
//
VW3006
-> raw_OUTPUT
[signed integer, range 0-32000]
//
VD3008
-> raw_GAIN
[real]
//
VD3012
-> raw_SAMPLE time[real, in msec intervals]
//
VD3016
-> RATE time
[real, in msec]
//
VD3020
-> RESET time
[real, in msec]
//
VD3024-3029
-> user reserved
//
// working VB3030
-> internal_status
[bit field, described below]
//
VD3031
-> PV
[real, scaled 0.0-1.0]
//
VD3035
-> SP
[real, scaled 0.0-1.0]
//
VD3039
-> OUTPUT
[real, scaled 0.0-1.0]
//
VD3043
-> ERROR
[real]
//
VD3047
-> BIAS
[real]
//
VD3051
-> PV_OLD
[real]
//
VD3055
-> I_COEF
[real]
//
VD3059
-> D_COEF
[real]
//
VD3063
-> GAIN (shadow)
[real]
//
VD3067
-> SAMPLE
[real]
//
// The PID routine will use the current PV and setpoint values stored in the raw_PV and raw_SP fields
// of the user area each time the loop calculation is performed. The control byte must be used to assert
// changes in mode, gain, sample time, and rate/reset time. First, the desired data values must be
// written to the fields of the user area and the control byte. Then the most significant bit of the
// control byte must be set to direct the PID routine to accept the new values. The PID routine will clear the
// MSB when the new values have been processed.
//
bit
7 6 5 4 3 2 1 0
//
x 0 0 0 0 0 0 x
//
^
^
//
|
|
//
|
--- mode (1=auto, 0=manual)
//
|
//
---- update values (1=update)
//
// The status byte is used to feed back current configuration of the loop to the user. The format of the
// status byte is as follows:
//
//
bit 7 6 5 4 3 2 1 0
//
0 0 0 0 0 0 0 x
//
^
//
|
//
--- mode (1=auto, 0=manual)
//
page 8 / 21
S72_32e.doc
Version 2.0
SIMATIC S7-200 customers have free use of the application tips. These tips are only a general approach to using the S7-200 with various applications.
Your specific application may be different. It is your responsibility to use the SIMATIC S7-200 properly in your applications.
S7-200 Tip
PID
Tip No. 32
//
// The internal status byte in the working data area is used by the PID routine for "private" flags. The
// format of this byte is as follows:
//
//
bit 7 6 5 4 3 2 1 0
//
x 0 0 0 0 0 0 x
//
^
^
//
|
|
//
|
--- mode (1=auto, 0=manual)
//
---- first cycle flag (1=first cycle)
//
60),//B1
(1
.,12879:
.1
029B%
(1
.,128760%
$7&+
(1
.,17
.(97
(1,
LD
FILL
MOVB
ATCH
SM0.1
0,
100,
100,
VW3000,
SMB34
10
ENI
36
//
// clear user area of V memory
// test code - setup for 100 msec
// sample time (the same value should used for the
// PID raw_SAMPLE time (VD3012)
// Enable interrupts
60029B5
(1
.5,12879'
029B5
(1
.5,12879'
page 9 / 21
S72_32e.doc
Version 2.0
SIMATIC S7-200 customers have free use of the application tips. These tips are only a general approach to using the S7-200 with various applications.
Your specific application may be different. It is your responsibility to use the SIMATIC S7-200 properly in your applications.
S7-200 Tip
PID
Tip No. 32
029B5
(1
.5,12879'
029B5
(1
.5,12879'
029B%
(1
.+,12879%
// The user program must load the user fields and operate the PID.
// The user program would replace the following demo program.
// ***** Start of demo program *****
LD
SM0.1
MOVR
100.0,
VD3012
MOVR
MOVR
MOVR
MOVB
1.0,
0.0,
60000.0,
16#81,
VD3008
VD3016
VD3020
VB3000
60029B:
(1
$,:,12879:
029B:
(1
9:,1287$4:
LD
MOVW
SM0.0
AIW0,
VW3002
MOVW
VW3006,
AQW0
// Every scan
// Transfer Analog Input value to the raw_PV
// [signed integer, range 0-32000]
// Transfer raw_OUTPUT to Analog Output
// [signed integer, range 0-32000]
// The Set Point raw_SP (VW3004 signed integer, range 0-32000] must be loaded from an operator interface
// device.
// ***** End of demo program *****
page 10 / 21
S72_32e.doc
Version 2.0
SIMATIC S7-200 customers have free use of the application tips. These tips are only a general approach to using the S7-200 with various applications.
Your specific application may be different. It is your responsibility to use the SIMATIC S7-200 properly in your applications.
S7-200 Tip
PID
Tip No. 32
0(1'
MEND
,17
9
-03
// INT 100 - PID routine
// Check for active indication to update loop values. If the bit is asserted, recalculate new integral and
// derivative coefficients and perform any required mode changes.
INT
LDN
JMP
100
V3000.7
0
//
// If (control_byte.update_values = TRUE)
//
60029B5
(1
9',12879'
029B5
(1
9',12879'
029B5
(1
9',12879'
029B5
(1
9',1287$&
',9B5
(1
9',12879'
$&,1
',9B5
(1
9',12879'
9',1
page 11 / 21
S72_32e.doc
Version 2.0
SIMATIC S7-200 customers have free use of the application tips. These tips are only a general approach to using the S7-200 with various applications.
Your specific application may be different. It is your responsibility to use the SIMATIC S7-200 properly in your applications.
S7-200 Tip
MOVR
MOVR
MOVR
MOVR
/R
MOVR
/R
VD3008,
VD3012,
VD3067,
VD3020,
AC0,
VD3016,
VD3067,
PID
VD3063
VD3067
VD3055
AC0
VD3055
VD3059
VD3059
Tip No. 32
// GAIN = raw_GAIN
// SAMPLE = raw_SAMPLE
// I_COEF = SAMPLE / RESET
.59'08/B5
5127(1
9',12879'
9',1
08/B5
(1
9',12879'
9',1
LDR=
NOT
*R
*R
0.0,
VD3063
VD3063,
VD3063,
VD3055
VD3059
999.
6
9.
5
9.
5
-03
LDN
A
S
R
R
JMP
V3000.0
V3030.0
V3030.7,
V3030.0,
V3001.0,
1
1
1
1
page 12 / 21
S72_32e.doc
Version 2.0
SIMATIC S7-200 customers have free use of the application tips. These tips are only a general approach to using the S7-200 with various applications.
Your specific application may be different. It is your responsibility to use the SIMATIC S7-200 properly in your applications.
S7-200 Tip
PID
Tip No. 32
999.
6
9.
6
9.
6
029B5
(1
9',12879'
029B:
(1
9:,12879:
LD
AN
S
S
S
MOVR
MOVW
V3000.0
V3030.0
V3030.7,
V3030.0,
V3001.0,
VD3039,
VW3002,
1
1
1
VD3047
VW3004
/%/
609.
5
LBL
LD
R
1
SM0.0
V3000.7,
// control_byte.update_values = FALSE
/%/
9:.029B5
! :(1
.5,12879'
-03
page 13 / 21
S72_32e.doc
Version 2.0
SIMATIC S7-200 customers have free use of the application tips. These tips are only a general approach to using the S7-200 with various applications.
Your specific application may be different. It is your responsibility to use the SIMATIC S7-200 properly in your applications.
S7-200 Tip
PID
LBL
LDW>=
MOVR
JMP
VW3002,
1.0,
10
32000
VD3031
Tip No. 32
9:.029B5
:(1
.5,12879'
-03
LDW<=
MOVR
JMP
VW3002,
0.0,
10
0
VD3031
6068%B',
(1
$&,1287$&
$&,1
029B:
(1
9:,1287$&
',B5($/
(1
$&,12879'
',9B5
(1
9',12879'
.5,1
LD
-D
MOVW
DTR
/R
SM0.0
AC1,
VW3002,
AC1,
32000.0,
// Else
AC1
AC1
VD3031
VD3031
//
PV = DTR(raw_pv)/32000.0
page 14 / 21
S72_32e.doc
Version 2.0
SIMATIC S7-200 customers have free use of the application tips. These tips are only a general approach to using the S7-200 with various applications.
Your specific application may be different. It is your responsibility to use the SIMATIC S7-200 properly in your applications.
S7-200 Tip
PID
Tip No. 32
/%/
9:.029B5
! :(1
.5,12879'
-03
LBL
10
LDW>=
MOVR
JMP
VW3004,
1.0,
20
32000
VD3035
9:.029B5
:(1
.5,12879'
-03
LDW<=
MOVR
JMP
VW3004,
0.0,
20
0
VD3035
6068%B',
(1
$&,1287$&
$&,1
029B:
(1
9:,1287$&
',B5($/
(1
$&,12879'
',9B5
(1
9',12879'
.5,1
page 15 / 21
S72_32e.doc
Version 2.0
SIMATIC S7-200 customers have free use of the application tips. These tips are only a general approach to using the S7-200 with various applications.
Your specific application may be different. It is your responsibility to use the SIMATIC S7-200 properly in your applications.
S7-200 Tip
LD
-D
MOVW
DTR
/R
SM0.0
AC1,
VW3004,
AC1,
32000.0,
PID
Tip No. 32
// Else
AC1
AC1
VD3035
VD3035
// SP = DTR(raw_sp)/32000.0
/%/
9
-03
LBL
LDN
JMP
20
V3030.0
30
6068%B5
(1
9',12879'
9',1
LD
MOVR
-R
SM0.0
VD3035,
VD3031,
VD3043
VD3043
//
ERROR = SP - PV
/%/
9
-03
LBL
30
LDN
JMP
V3030.0
40
page 16 / 21
S72_32e.doc
Version 2.0
SIMATIC S7-200 customers have free use of the application tips. These tips are only a general approach to using the S7-200 with various applications.
Your specific application may be different. It is your responsibility to use the SIMATIC S7-200 properly in your applications.
S7-200 Tip
PID
Tip No. 32
6008/B5
(1
9',1287$&
9',1
08/B5
(1
9',1287$&
9',1
$''B5
(1
9',1287$&
$&,1
029B5
(1
.5,1287$&
LD
MOVR
*R
MOVR
*R
+R
MOVR
SM0.0
VD3063,
VD3043,
VD3055,
VD3043,
VD3047,
0.0,
AC1
AC1
AC2
AC2
AC2
AC3
// Mp = GAIN * ERROR
// Mi = BIAS + (I_COEF * ERROR)
// Md = 0.0
.59'968%B5
5127(1
9',1287$&
9',1
08/B5
(1
$&,1287$&
9',1
LDR=
NOT
AN
MOVR
-R
*R
0.0,
VD3059
V3030.7
VD3051,
VD3031,
VD3059,
AC3
AC3
AC3
not int_status.first_cycle)
Md = D_COEF * (PV_OLD - PV)
page 17 / 21
S72_32e.doc
Version 2.0
SIMATIC S7-200 customers have free use of the application tips. These tips are only a general approach to using the S7-200 with various applications.
Your specific application may be different. It is your responsibility to use the SIMATIC S7-200 properly in your applications.
S7-200 Tip
PID
Tip No. 32
60029B5
(1
9',12879'
$''B5
(1
$&,1287$&
$&,1
$''B5
(1
$&,12879'
$&,1
LD
MOVR
+R
MOVR
+R
SM0.0
VD3031,
AC3,
AC1,
AC2,
VD3051
AC1
VD3039
VD3039
// PV_OLD = PV
// Ma = Mp + Md
// OUTPUT = Ma + Mi
9'.568%B5
5127(1
.5,1287$&
$&,1
029B5
(1
.5,12879'
-03
LDR<=
NOT
MOVR
-R
MOVR
JMP
VD3039,
1.0
//
1.0,
AC1,
1.0,
41
AC2
AC2
VD3039
//
Mi = 1.0 - Ma
//
OUTPUT = 1.0
page 18 / 21
S72_32e.doc
Version 2.0
SIMATIC S7-200 customers have free use of the application tips. These tips are only a general approach to using the S7-200 with various applications.
Your specific application may be different. It is your responsibility to use the SIMATIC S7-200 properly in your applications.
S7-200 Tip
PID
Tip No. 32
9:;25B':
(1
$&,1287$&
.+,1
029B5
(1
.5,12879'
LD
MOVR
XORD
MOVR
V3039.7
AC1,
AC2
16#80000000,
0.0,
VD3039
//
//
AC2
//
OUTPUT = 0.0
/%/
.59'
5-03
LBL
LDR=
JMP
41
0.0,
42
VD3055
//
If (I_COEF <> 0)
$&.5029B5
5127(1
.5,1287$&
-03
LDR<=
NOT
MOVR
JMP
AC2,
1.0
//
1.0,
43
AC2
//
.+$&029B5
'(1
$&.5.5,1287$&
! 5127
page 19 / 21
S72_32e.doc
Version 2.0
SIMATIC S7-200 customers have free use of the application tips. These tips are only a general approach to using the S7-200 with various applications.
Your specific application may be different. It is your responsibility to use the SIMATIC S7-200 properly in your applications.
S7-200 Tip
LDD=
LDR>=
NOT
OLD
MOVR
PID
16#80000000,
AC2,
0.0
0.0,
AC2
AC2
//
//
//
Tip No. 32
Else If (Mi = -0.0) OR
(Mi < 0.0)
Mi = 0.0
/%/
60029B5
(1
$&,12879'
LBL
LD
MOVR
43
SM0.0
AC2,
VD3047
//
//
Endif
BIAS = Mi
/%/
/%/
609.
5
LBL
LBL
LD
R
42
40
SM0.0
V3030.7,
// Endif
// Endif
1
// int_status.first_cycle = FALSE
6008/B5
(1
9',1287$&
.5,1
7581&
(1
$&,1287$&
029B:
(1
$&,12879:
5(7,
page 20 / 21
S72_32e.doc
Version 2.0
SIMATIC S7-200 customers have free use of the application tips. These tips are only a general approach to using the S7-200 with various applications.
Your specific application may be different. It is your responsibility to use the SIMATIC S7-200 properly in your applications.
S7-200 Tip
PID
Tip No. 32
//
Convert scaled output value back into signed integer value from 0 to 32000.
//
LD
SM0.0
// raw_output = TRUNC(OUTPUT * 32000.0)
MOVR
VD3039,
AC0
*R
32000.0,
AC0
TRUNC
AC0,
AC1
.
MOVW
AC1,
VW3006
RETI
// END INT 100
Conversion Notes
To Convert from IEC STL to S7-Micro/DOS STL:
z
z
z
z
General Notes
The SIMATIC S7-200 Application Tips are provided to give users of the S7-200 some indication
as to how, from the view of programming technique, certain tasks can be solved with this
controller. These instructions do not purport to cover all details or variations in equipment, nor do
they provide for every possible contingency. Use of the S7-200 Application Tips is free.
Siemens reserves the right to make changes in specifications shown herein or make
improvements at any time without notice or obligation. It does not relieve the user of
responsibility to use sound practices in application, installation, operation, and maintenance of
the equipment purchased. Should a conflict arise between the general information contained in
this publication, the contents of drawings or supplementary material, or both, the latter shall take
precedence.
Siemens is not liable, for whatever legal reason, for damages or personal injury resulting from
the use of the application tips.
All rights reserved. Any form of duplication or distribution, including excerpts, is only permitted
with express authorization by SIEMENS.
page 21 / 21
S72_32e.doc
Version 2.0
SIMATIC S7-200 customers have free use of the application tips. These tips are only a general approach to using the S7-200 with various applications.
Your specific application may be different. It is your responsibility to use the SIMATIC S7-200 properly in your applications.