Siemens SIMATIC S7 System Manual page 392

Hide thumbs Also See for SIMATIC S7:
Table of Contents

Advertisement

Program instructions
7.18 Subroutine
There are no automatic data type conversions performed on the input or output parameters.
For example, if the 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 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.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 16
Example: Subroutine and return from subroutine instructions
LAD
MAIN
SBR0
SBR0
392
On the first scan, call subroutine 0
for initialization.
You can use a conditional return to
leave the subroutine before the last
network.
This network will be skipped if
M14.3 is ON.
System Manual, V2.3, 07/2017, A5E03822230-AF
STL
Network 1
LD SM0.1
CALL SBR_0
Network 1
LD M14.3
CRET
Network 2
LD SM0.0
MOVB 10, VB0
S7-200 SMART

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Simatic s7-200 smart

Table of Contents