Programming concepts
5.6 Variable table
S7-200 SMART
122
System Manual, V2.3, 07/2017, A5E03822230-AF
You assign a declaration type (TEMP, IN, IN_OUT, or OUT) and a data type, but not a
memory address, when you make assignments in a Local Variable Table; the Program
Editor automatically assigns memory locations in L memory for all local variables.
A variable table symbolic address assignment associates a symbol name with an L memory
address, where the data value of concern is stored. The Local Variable Table does not
support symbolic constants that assign a value directly to a symbol name (this is allowed in
the Symbol\Global Variable tables).
Note
Local data values are not initialized to zero by the PLC. You must initialize the local variables
that you use, in your program logic.
Declaration types for local variables
The type of local variable assignment you can make depends on the POU where you are
making the assignment. The main program (OB1), interrupt routines, and subroutines can
use temporary (TEMP) variables. Temporary variables are only available while the block is
being executed and are then free to be overwritten when the block is completed.
Data values can be passed as parameters in and out of a subroutine as follows:
●
If you want to pass a data value into a subroutine, then create a variable in the
subroutine's variable table and specify its declaration type as IN.
●
If you want to pass a data value established in the subroutine back to the calling routine,
then create a variable in the subroutine's variable table and specify its declaration type as
OUT.
●
If you want to pass an initial data value into a subroutine, perform an operation that may
modify the data value, and pass the modified result back to the calling routine, then
create a variable in the subroutine's variable table and specify its declaration type as
IN_OUT.
Declaration type Description
IN
Input parameter provided by the calling POU.
OUT
Output parameter returned to the calling POU.
IN_OUT
Parameter whose value is supplied by the calling POU, modified by the subrou-
tine, and then returned to the calling POU.
TEMP
Temporary variable that is saved temporarily in the local data stack. Once the
POU has been executed completely, the value of the temporary variable is no
longer available. Temporary variables do not keep their value between POU exe-
cutions.
Data type checking for local variables
When you pass local variables as parameters for a subroutine, the data type that you have
assigned in the Local Variable Table of that subroutine must match the data type of the value
in the calling POU.