Declaring global variables

To declare variables using the declaration editor, follow the procedure below. Variables can also be declared very comfortably in the POU body (using LD/FBD, ST/IL or SFC) or in the Variables pane.

NOTE
  • Do not assign addresses unless you have to! Provide addresses for PLC inputs and outputs (X, Y) or if access to certain memory areas is required.

  • The compiler automatically assigns addresses after the power has been turned on. This prevents errors caused by duplicate outputs and ensures that the addresses are automatically updated when the PLC type is changed.

  • To structure your program, you should declare all global variables in the global variable list before starting to program.

  1. Open a global variable list under GVLs from the Project pane

    Several global variable lists are allowed in the GVL pool of the project. In user libraries, only one GVL is allowed. You can delete all global variable lists from the project except for one list, which is mandatory for each project.

    The following restrictions exist for GVL names:

    • Do not use special characters such as !, ", $, %, brackets, etc.
    • The first character may not be a digit.
    • The last character may not be an underscore. An underscore may not be followed by another underscore.
    • The identifier may not consist of only an address, e.g. 'R0', 'DT0', 'LD0'. The identifier may not consist of only a keyword, e.g. 'ADD', 'ARRAY', 'INT'.
  2. Under Class, select a variable class
  3. Under Identifier, enter a symbolic name

    Only execute the next two steps for inputs and outputs of the PLC or when a certain address assignment is required for the variable, e.g. when data are exchanged with operator devices.

  4. Enter address in FP format, e.g. X0

    The corresponding IEC address is generated automatically when you move to the next field.

    or enter address in IEC format, e.g. %IX0.0

    I = input, X = bit and 0.0 for first unit and first input. The corresponding FP address is generated automatically when you move to the next field.

  5. Under Type, select to open the Type selection dialog
  6. Under Type class, select the desired data type class
    • Elementary data types
    • Data unit types
    • Function blocks
  7. Under Library, select the desired library
  8. OK
    The initial value preset for the selected data type is displayed automatically. You can change this value at any time.
    Optional:
    • Select Autoextern to automatically insert them into all POU headers
    • Under Comment, enter a text, if desired

Explanation of fields

A project has a list of global variables. The global variable list (GVL) applies to all POUs in the project.

The fields in the variable lists have the following meaning:

  1.  (1) Class is the variable class, e.g. VAR_GLOBAL, VAR_GLOBAL_CONSTANT, etc.
  2.  (2) Identifier is the symbolic name that is used in the program.
  3.  (3) FP address or IEC address is the physical address which is assigned to the variable.
  4.  (4) Type: after entering an address, a data type is automatically preselected (e.g. BOOL, INT, STRING). Another type can be selected from the list.
  5.  (5) Initial is the starting value which is assigned to the variable whenever your PLC is started. You can change the value if required.
  6.  (6) Autoextern inserts the global variable automatically into the headers of all current and future POUs displayed in the Project pane. This function can be permanently activated under Extras > Options > Program options > Editors > Declaration editors.
  7.  (7) Comment is a description of a variable.
NOTE
  • Identifiers may not start with a number.
  • Identifiers using a special syntax can determine the data type according to the prefix table.
  • FP addresses (X0, Y1, etc.) are fixed terms and may not be used as identifiers.
  • Do not assign addresses unless you have to! Provide addresses for PLC inputs and outputs (X, Y) or if access to certain memory areas is required.

  • You can enter addresses in one of the following formats:

    • FP format, e.g. X0. The corresponding IEC address is generated automatically when you move to the next field.
    • IEC format, e.g. %IX0.0. I = input, X = bit and 0.0 for first unit and first input. The corresponding FP address is generated automatically when you move to the next field.
  • To add empty lines to the list, press <Shift>+<Return>
  • Insert new lines with Edit > New declaration > Top > Before > After > Bottom
Related topics:

Modified on: 2025-07-09Feedback on this pagePanasonic hotline