Skip to main content

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 variables

  • FUNCTION_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

. Variables for program POU - Basic Level
  • VAR

  • VAR CONSTANT

  • VAR_EXTERNAL for channel variables and stack instances

  • VAR_EXTERNAL CONSTANT allowed only from VAR_GLOBAL CONSTANT

. Variables for function block POU - Basic Level
  • VAR

  • VAR CONSTANT

  • VAR_INPUT

  • VAR_OUTPUT

. Meaning of the keywords
  • VAR: Declaration of normal internal variables, POU-wide variable

  • VAR_INPUT: Declaration of input variables

  • VAR_OUTPUT: Declaration of output variables

  • The CONSTANT modifier serves the declaration of symbolic constants

Keywords of the variable declarations for Extended Level

. Variables for program POU - Extended Level
  • VAR

  • VAR CONSTANT

  • VAR_EXTERNAL

  • VAR_EXTERNAL CONSTANT

. Variables for function block POU - Extended Level
  • VAR

  • VAR CONSTANT

  • VAR_INPUT

  • VAR_OUTPUT

. Meaning of the keywords:
  • VAR: Declaration of normal internal variables, POU-wide variable

  • VAR_INPUT: Declaration of input variables

  • VAR_OUTPUT: Declaration of output variables

  • VAR_EXTERNAL: Declaration of global variables already declared in the application with VAR_GLOBAL, in order to make them usable in the POU.

    Global variables having the CONSTANT modifier must be declared as VAR_EXTERNAL CONSTANT.

  • The CONSTANT modifier serves the declaration of symbolic constants

. Already existing variables of the "global variables" category are available for the declaration as 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

. Basic Level data types
  • BOOL

  • INT: Only as a constant input parameter for a function block call

  • DINT: Only as a constant input parameter for a function block call

  • WORD: Only as an output for diagnostic purposes

  • TIME: Only as a constant input parameter in a function block call

  • SAFEBOOL

  • SAFEINT: Only as constant function block input in a call

  • SAFEDINT: Only as a constant input parameter in a function block call

  • SAFEWORD: Only as a constant input parameter in a function block call

  • SAFETIME: 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.

. Safety standard types:
  • BOOL

  • BYTE: For the exchange of encoded information (status code, diagnostic code, control code) between predefined function blocks and the environment

  • DINT

  • DWORD: For the exchange of encoded information (status code, diagnostic code, control code) between predefined function blocks and the environment

  • INT

  • TIME: Allowed as a constant input parameter and for local variables.

    External declarations of global variables of the type SAFETIME are not permissible

  • WORD: For the exchange of encoded information (status code, diagnostic code, control code) between predefined function blocks and the environment

  • No REAL data type

  • SAFEBOOL

  • SAFEBYTE: For the exchange of encoded information (status code, diagnostic code, control code) between predefined function blocks and the environment

  • SAFEDINT

  • SAFEDWORD: For the exchange of encoded information (status code, diagnostic code, control code) between predefined function blocks and the environment

  • SAFEWORD: For the exchange of encoded information (status code, diagnostic code, control code) between predefined function blocks and the environment

  • SAFEINT

  • 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.