Siemens SIMATIC S7-200 System Manual page 219

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

Advertisement

Calling a Subroutine With Parameters
Subroutines can contain passed parameters. The parameters are defined in the local variable
table of the subroutine. The parameters must have a symbol name (maximum of 23 characters), a
variable type, and a data type. Sixteen parameters can be passed to or from a subroutine.
The variable type field in the local 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). Table 6-79 describes the parameter types for a subroutine. To add a parameter entry,
place the cursor on the variable type field of the type (IN, IN_OUT, or OUT) 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 entry of the selected type appears below the current entry.
Table 6-79
Parameter Types for a Subroutine
Parameter
Description
IN
Parameters are passed into the subroutine. If the parameter is a direct address (such as
VB10), the value at the specified location is passed into the subroutine. If the parameter is an
indirect address (such as *AC1), the value at the location pointed to is passed into the
subroutine. If the parameter is a data constant (16#1234) or an address (&VB100), the
constant or address value is passed into the subroutine.
IN_OUT
The value at the specified parameter location is passed into the subroutine, and the result
value from the subroutine is returned to the same location. Constants (such as 16#1234) and
addresses (such as &VB100) are not allowed for input/output parameters.
OUT
The result value from the subroutine is returned to the specified parameter location.
Constants (such as 16#1234) and addresses (such as &VB100) are not allowed as output
parameters. Since output parameters do not retain the value assigned by the last execution
of the subroutine, you must assign values to outputs each time the subroutine is called. Note
that the SET and RESET instructions only affect the value of the Boolean operand(s) when
power flow is ON.
TEMP
Any local memory that is not used for passed parameters can be used for temporary storage
within the subroutine.
As shown in Figure 6-37, the data type field in the local variable table defines the size and format
of the parameter. The parameter types are listed below:
BOOL: This data type is used for
-
single bit inputs and outputs. IN3 in
the following example is a Boolean
input.
BYTE, WORD, DWORD: These
-
data types identify an unsigned
input or output parameter of 1, 2,
or 4 bytes, respectively.
INT, DINT: These data types
-
identify signed input or output
y g
parameters of 2 or 4 bytes,
f
respectively.
REAL: This data type identifies a single precision (4 byte) IEEE floating-point value.
-
STRING: This data type is used as a four-byte pointer to a string.
-
Power Flow: Boolean power flow is allowed only for bit (Boolean) inputs. This declaration
-
tells STEP 7-Micro/WIN that this input parameter is the result of power flow based on a
combination of bit logic instructions. Boolean power flow inputs must appear first in the local
variable table before any other type input. Only input parameters are allowed to be used
this way. The enable input (EN) and the IN1 inputs in the following example use Boolean
logic.
p
p
b
Figure 6-37 Local Variable Table
S7-200 Instruction Set
Chapter 6
205

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents