Siemens SIMATIC S7-200 System Manual page 221

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

Advertisement

Example: Subroutine and Return from Subroutine Instructions
M
A
I
N
S
B
R
0
Example: Subroutine Call with strings
This example copies a different string literal to a unique address depending upon the given input. The unique
address of this string is saved. The string address is then passed to the subroutine by using an indirect
address. The data type of the subroutine input parameter is string. The subroutine then moves the string to a
different location.
A string literal can also be passed to the subroutine. The string reference inside the subroutine is always the
same.
M
A
I
N
S
B
R
0
S7-200 Instruction Set
Network 1
//On the first scan, call subroutine 0
//for initialization.
LD
SM0.1
CALL
SBR_0
Network 1
//You can use a conditional return to leave
//the subroutine before the last network.
LD
M14.3
CRET
Network 2
//This network will be skipped if M14.3 is on.
LD
SM0.0
MOVB
10, VB0
Network 1
LD
I0.0
SSCPY
"string1", VB100
AENO
MOVD
&VB100, VD0
Network2 //
LD
I0.1
SSCPY
"string2", VB200
AENO
MOVD
&VB200, VD0
Network3 //
LD
I0.2
CALL
SBR_0, *VD0
Network 1
LD
SM0.0
SSCPY
*LD0, VB300
Chapter 6
//
//
207

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents