Variables
This section contains:
Keywords of the variable declaration for Basic Level
Keywords of the variable declarations for Extended Level
Basic Level data types
Extended Level data types
The keywords and data types that are available depend on the programming level of the POU.
In the FBD program code, which is created in the Safety FBD editor, variables appear exclusively in the form of names (symbolic variables). You can use a simple name, an identifier as per IEC. An identifier with which a variable is referenced in the implementation section must be declared in the declaration section (see Variable Declaration Editor) of the POU.
Categories for variables in the Input Assistant
The following categories are displayed for variables in the Input Assistant:
PROGRAM POU
: local variables and global variablesFUNCTION_BLOCK POU
: local variables
The Local variables category encompasses all variables of the local declaration section, including VAR_EXTERNAL
.
The Global variables category encompasses all variables of the GVLs of the application, all mapped I/Os and all implicit instances of the logical I/Os (see: I/O Mapping).
Keywords of the variable declaration for Basic Level
VAR
VAR CONSTANT
VAR_EXTERNAL
for channel variables and stack instancesVAR_EXTERNAL CONSTANT
allowed only fromVAR_GLOBAL CONSTANT
VAR
VAR CONSTANT
VAR_INPUT
VAR_OUTPUT
VAR
: Declaration of normal internal variables, POU-wide variableVAR_INPUT
: Declaration of input variablesVAR_OUTPUT
: Declaration of output variablesThe
CONSTANT
modifier serves the declaration of symbolic constants
Keywords of the variable declarations for Extended Level
VAR
VAR CONSTANT
VAR_EXTERNAL
VAR_EXTERNAL CONSTANT
VAR
VAR CONSTANT
VAR_INPUT
VAR_OUTPUT
VAR
: Declaration of normal internal variables, POU-wide variableVAR_INPUT
: Declaration of input variablesVAR_OUTPUT
: Declaration of output variablesVAR_EXTERNAL
: Declaration of global variables already declared in the application withVAR_GLOBAL
, in order to make them usable in the POU.Global variables having the
CONSTANT
modifier must be declared asVAR_EXTERNAL CONSTANT
.The
CONSTANT
modifier serves the declaration of symbolic constants
VAR_EXTERNAL
and VAR_EXTERNAL CONSTANT
:Global variables of the GVL object of the safety application.
If a variable of the GVL object of the safety application is used in the implementation section, then it is automatically declared as an external variable in the declaration section.
According to IEC it is explicitly forbidden to use global variables in a POU without declaring them as "External".
Mapping variables of the logical I/Os (logical exchange devices and safe field devices)
Basic Level data types
BOOL
INT
: Only as a constant input parameter for a function block callDINT
: Only as a constant input parameter for a function block callWORD
: Only as an output for diagnostic purposesTIME
: Only as a constant input parameter in a function block callSAFEBOOL
SAFEINT
: Only as constant function block input in a callSAFEDINT
: Only as a constant input parameter in a function block callSAFEWORD
: Only as a constant input parameter in a function block callSAFETIME
: Only as a constant input parameter in a function block call
The REAL
data type is not available.
Extended Level data types
The following data types are available to the developer for the implementation of a POU in the Extended programming level.
BOOL
BYTE
: For the exchange of encoded information (status code, diagnostic code, control code) between predefined function blocks and the environmentDINT
DWORD
: For the exchange of encoded information (status code, diagnostic code, control code) between predefined function blocks and the environmentINT
TIME
: Allowed as a constant input parameter and for local variables.External declarations of global variables of the type
SAFETIME
are not permissibleWORD
: For the exchange of encoded information (status code, diagnostic code, control code) between predefined function blocks and the environmentNo
REAL
data typeSAFEBOOL
SAFEBYTE
: For the exchange of encoded information (status code, diagnostic code, control code) between predefined function blocks and the environmentSAFEDINT
SAFEDWORD
: For the exchange of encoded information (status code, diagnostic code, control code) between predefined function blocks and the environmentSAFEWORD
: For the exchange of encoded information (status code, diagnostic code, control code) between predefined function blocks and the environmentSAFEINT
SAFETIME
; Allowed as a constant input parameter and for local variables.External declarations of global variables of the type
SAFETIME
are not permissible if they are neither symbolic constants nor imported logical I/Os.
The REAL
data type is not available.