Variable Table - Siemens Simatic S7 Series System Manual

Hide thumbs Also See for Simatic S7 Series:
Table of Contents

Advertisement

Programming concepts

5.6 Variable table

5.6
Variable table
A variable table allows you to define variables that are local to a specific POU. The following
situations define when to use a local variable:
● You want to create portable subroutines that do not make references to absolute
addresses or global symbols.
● You want to use interim variables (local variables declared as TEMP) to perform
calculations in order to free up PLC memory.
● You want to define inputs and outputs for your subroutines.
If these descriptions do not fit your situation, you do not need to use local variables; you can
make all of your symbolic values global by defining them in the symbol table (Page 100).
Understanding local variables
You can use the variable table of the program editor to assign variables that are unique to an
individual subroutine or interrupt routine.
Local variables can be used as parameters that are passed in to a subroutine and can be
used to increase the portability or reuse of a subroutine.
Each POU (Page 87) in your program has its own variable table, with 64 bytes of L memory
(60 bytes if you are programming in LAD or FBD). These local variable tables allow you to
define variables that are restricted in scope: a local variable is only valid inside the POU
where it was created. By contrast, global symbols, which are valid in every POU, can only be
defined in the symbol table. In cases where you use the same symbolic name (e.g., INPUT1)
for a global symbol and a local variable, the local definition takes precedence inside the POU
where the local variable has been defined and the global definition is used in the other
POUs.
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.
104
System Manual, 09/2015, A5E03822230-AC
S7-200 SMART

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Simatic s7-200 smart series

Table of Contents