Program instructions
7.18 Subroutine
S7-200 SMART
System Manual, 09/2015, A5E03822230-AC
347
Error conditions with ENO = 0
• 0006H Indirect address
• 008H Maximum subroutine nesting
exceeded
None
IN
V, I, Q, M, SM, S, T, C, L, Power Flow (LAD), Logic flow (FBD)
BYTE VB, IB, QB, MB, SMB, SB, LB, AC, *VD, *LD, *AC
1
, Constant
VW, T, C, IW, QW, MW, SMW, SW, LW, AC, AIW, *VD, *LD, *AC
1
DWORD, DINT VD, ID, QD, MD, SMD, SD, LD, AC, HC, *VD, *LD, *AC
1
, &VB, &IB, &QB, &MB,
&T, &C, &SB, &AI, &AQ, &SMB, Constant
1
IN_OUT
2
2
, SB, LB, AC, *VD, *LD, *AC
1
VW, T, C, IW, QW, MW, SMW
2
, SW, LW, AC, *VD, *LD, *AC
1
2
, SD, LD, AC, *VD, *LD, *AC
1
OUT
2
2
, SB, LB, AC, *VD, *LD, *AC
1
VW, T, C, IW, QW, MW, SMW
2
, SW, LW, AC, AQW, *VD, *LD, *AC
1
2
, SD, LD, AC, *VD, *LD, *AC
1
Only AC1, AC2 or AC3 (AC0 not allowed)
2
Must be from byte offset 30 to byte offset 999 for read/write access
Calling a subroutine with call parameters
Subroutines have the option of using passed parameters. The parameters are defined in the
variable table of the subroutine. Each parameter must be assigned a local symbol name (a
maximum of 23 characters), a variable type, and a data type. A maximum of sixteen
parameters can be passed to or from a subroutine. The VAR_Type type field in the variable
table defines whether the variable is passed into the subroutine (IN), passed into and out of
the subroutine (IN_OUT), or passed out of the subroutine (OUT).
To add a new parameter row, place the cursor on the Var_Type field of the type (IN,
IN_OUT, OUT, or TEMP) that you want to add. Click the right mouse button to get a menu of
options. Select the Insert option and then the Row Below option. Another parameter row of
the selected type will appear below the current entry.
Temporary (TEMP) parameters can be assigned in the variable table to store data that is
valid only within the scope of the subroutine execution. Local TEMP data is not passed as a
call parameter. You can also assign TEMP parameters in the main routine and interrupt
routines, but only subroutines can use IN, IN_OUT, and OUT call parameters.