Variables
Variables store and process information. Initial values are the values of a variable when the target starts the first cycle. Initial values can be assigned to variables of the elementary IEC 61131-3 data types. The default initial value is 0 (False).
The variable types are as follows:
- Local variables are assigned to a specific program in the project and are available only to the program.
- Global variables belong to the controller in the project and are available to any programs in the project.
The variable naming conventions are as follows:
- Variable names cannot exceed 40 characters.
- Variable names must start with a letter.
- Variable names can contain letters, numbers, or underscores.
- Variable names cannot contain consecutive underscores.
Variable attributes
Each variable must have an assigned attribute.
Attribute | Description |
---|---|
Read/Write | Variables that can be read from and written to, and have an initial value |
Read | Read-only variables with an initial value |
Write | Write-only variables with an initial value |
Variable directions
Variable directions are available for the local variables of user-defined functions or user-defined function blocks. Some variables cannot have an input or output direction. For example, time.
Direction | Description |
---|---|
Var | Internal variables updated by the programs |
VarOutput | Variables connected to an input device (refreshed by the system) |
VarInput | Variables connected to an output device |
Values of variables
Value types of a variable:
- Value
- When viewing the variable online, it is the value of a variable in an executing controller.
- When viewing the variable offline, it is a snapshot of the value when the variable is viewed online, and it is saved in an offline project.
- Physical valueThe value is a property unique to controller global input and output variables. Because the value of an I/O variable can be forced using theForceproperty, the physical value shows the true value of the physical I/O.
Initializing user variable after download and restore
Initial value and value set the value after download and restore. Initial value is entered as part of the project configuration offline and can be changed without rebuilding the project. Value contains uploaded or backed-up logical data to save the status of the controller's variables for later download and restore. However, it can be modified offline in the project. If both initial value and value exist, initial value takes precedence over value.
Initial Value | Value (Offline) | Value After Download and Restore (Online) |
---|---|---|
None | None | Default value |
None | Yes | Value |
Exists | Exists | Initial value |
Value of user variables after power-on
Retained Checkbox | Value After Power-on (Online) |
---|---|
Cleared | Reset |
Selected | Value before power-off |
Provide Feedback