Siemens SIMATIC S7-200 System Manual page 220

Programmable controller
Hide thumbs Also See for SIMATIC S7-200:
Table of Contents

Advertisement

S7-200 Programmable Controller System Manual
Example: Subroutine Call
There are two STL examples provided. The first set of STL instructions can be displayed only in the STL
editor since the BOOL parameters used as power flow inputs are not saved to L memory.
The second set of STL instructions can be displayed also in the LAD and FBD editors because L memory is
used to save the state of the BOOL inputs parameters that are shown as power flow inputs in LAD and FBD.
Address parameters such as IN4 (&VB100) are passed into a subroutine as a DWORD (unsigned
double word) value. The type of a constant parameter must be specified for the parameter in the
calling routine with a constant descriptor in front of the constant value. For example, to pass an
unsigned double word constant with a value of 12,345 as a parameter, the constant parameter
must be specified as DW#12345. If the constant describer is omitted from the parameter, the
constant can be assumed to be a different type.
There are no automatic data type conversions performed on the input or output parameters. For
example, if the local variable table specifies that a parameter has the data type REAL, and in the
calling routine a double word (DWORD) is specified for that parameter, the value in the subroutine
will be a double word.
When values are passed to a subroutine, they are placed into the local memory of the subroutine.
The left-most column of the local variable table shows the local memory address for each passed
parameter. Input parameter values are copied to the subroutine's local memory when the
subroutine is called. Output parameter values are copied from the subroutine's local memory to
the specified output parameter addresses when the subroutine execution is complete.
The data element size and type are represented in the coding of the parameters. Assignment of
parameter values to local memory in the subroutine is as follows:
Parameter values are assigned to local memory in the order specified by the call subroutine
-
instruction with parameters starting at L.0.
One to eight consecutive bit parameter values are assigned to a single byte starting with
-
Lx.0 and continuing to Lx.7.
Byte, word, and double word values are assigned to local memory on byte boundaries (LBx,
-
LWx, or LDx).
In the Call Subroutine instruction with parameters, parameters must be arranged in order with
input parameters first, followed by input/output parameters, and then followed by output
parameters.
If you are programming in STL, the format of the CALL instruction is:
CALL
subroutine number, parameter 1, parameter 2, ... , parameter
206
STL only:
Network 1
LD
I0.0
CALL
SBR_0, I0.1, VB10, I1.0, &VB100, *AC1, VD200
To display correctly in LAD and FBD:
Network 1
LD
I0.0
=
L60.0
LD
I0.1
=
L63.7
LD
L60.0
CALL
SBR_0, L63.7, VB10, I1.0, &VB100, *AC1,
VD200

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents