EasyManua.ls Logo

Siemens SIMATIC S7-200 - Subroutine, Return from Subroutine

Siemens SIMATIC S7-200
606 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
SIMATIC Instructions
9-149
S7-200 Programmable Controller System Manual
A5E00066097-02
Subroutine, Return from Subroutine
The Call Subroutine instruction transfers control to the
subroutine (n). You can use a Call Subroutine instruction
with or without parameters. To add a subroutine, select
Edit > Insert > Subroutine from the menu.
The Conditional Return from Subroutine instruction is
used to terminate a subroutine based upon the preceding
logic.
Operands: None
Data Types: None
Once the subroutine completes its execution, control
returns to the instruction that follows the Call Subroutine.
Figure 9-55 shows an example of the Call Subroutine,
and Return from Subroutine instructions.
Error conditions that set ENO for Call Subroutine with
parameters = 0:
SM4.3 (run-time), 0008 (maximum subroutine nesting
exceeded)
Note
STEP 7-Micro/WIN 32 automatically adds a return from each subroutine.
From the main program, you can nest subroutines (place a subroutine call within a
subroutine), to a depth of eight. From an interrupt routine, you cannot nest
subroutines. A subroutine call cannot be placed in any subroutine called from an
interrupt routine. Recursion (a subroutine that calls itself) is not prohibited, but you
should use caution when using recursion with subroutines.
When a subroutine is called, the entire logic stack is saved, the top of stack is set
to one, all other stack locations are set to zero, and control is transferred to the
called subroutine. When this subroutine is completed, the stack is restored with the
values saved at the point of call, and control is returned to the calling routine.
Accumulators are common to subroutines and the calling routine. No save or
restore operation is performed on accumulators due to subroutine use.
L
A
D
S
T
L
L
A
D
F
B
D
EN
SBRn
222 224
✓✓
221
RET
RET
SBR n
CRET
226
SBR
EN

Table of Contents

Other manuals for Siemens SIMATIC S7-200

Related product manuals