Global variables

Global variables are valid for the entire project. They are, for example, the input and output contacts of a process or they are used for touch terminals and visualization. Global variables are declared in the global variable list. The global variable list can be accessed from the Project pane or from the Variables pane.

Global variables can be declared with different classes. The global variables can be referenced by the POUs via VAR_EXTERNAL (external variables).

The following variables must be declared in the global variable list:
  • Variables which are assigned to inputs and outputs, e.g. X0, Y0 of the PLC
  • Variables which need to be assigned to a certain address, e.g. DT0, to enable communication with an operator device
  • Variables which need to be accessible from other POUs (via VAR_EXTERNAL)
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.
  • If under Extras > Options > Compile options > Code generation, you activated Initialize all variables except global retain variables with explicit addresses, variables for which the user assigned addresses are not reinitialized.
  • To structure your program, you should declare all global variables in the global variable list before starting to program.
Related topics:

Consistency through global variables

Declaring global variables in a library using the global variable list allows you to:

  • Check and compare variables automatically

  • Keep data, i.e. names, data types, and user-defined addresses, consistent throughout projects

  • Track changes made to variables

Related topics:

Modified on: 2020-10-01Feedback on this pagePanasonic hotline