Variables

The scope of variables can be local to a program organization unit (POU) or global to a controller. Local variables are available for use within one POU only. Global variables are available for use within any POU of the controller.
Variable names are limited to 128 characters beginning with a letter or single underscore character followed by letters, digits, and single underscore characters. The last character for a variable name must be a letter or digit; variable names cannot end with an underscore character. Names cannot be reserved words, defined words, or data types (elementary, structures, or arrays). Names must be unique for the same type of elements within a scope.
TIP: Avoid using the same name for a local and global variable. When a local and global variable share the same name, only the global variable is used in the built project.
All variables have an attribute and direction. Variables can have one of the following attributes:
Read/Write
Variable which can be used for reading or writing, with an initial value
Read
Read-only variable with an initial value
Write
Write-only variable with an initial value
Variables can have one of the following directions. However, some variables such as time cannot have the input or output direction. Refer to the corresponding data type for restrictions.
Var
Internal variable updated by the programs
VarInput
Variable connected to an input controller (refreshed by the system)
VarOutput
Variable connected to an output controller
VarGlobal
System variable used to access diagnostic information
VarDirectlyRepresented
I/O channel of an I/O device
Initial values can be assigned to variables of elementary IEC 61131-3 data types. Default initial values are 0 or FALSE. An initial value is the value of a variable when a target starts its first cycle.
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.
Normal