Declaration of buffered Variables and ConstantsΒΆ

To guarantee the correct initialization or backing up of variables according to the table shown above, the following rules have to be observed when declaring variables.

Retentive internal variables

The variables have to be declared as VAR_RETAIN PERSISTENT or VAR_GLOBAL RETAIN PERSISTENT.

Example

(* Declaration in the global variable lists *)

VAR_GLOBAL RETAIN PERSISTENT
  byVar : BYTE;
  wVar  : WORD;
  rVar  : REAL;
END_VAR

(* Declaration in the program *)

VAR RETAIN PERSISTENT
  byVar1 : BYTE;
END_VAR

Buffered variables in %M area

The variables have to be declared as VAR_RETAIN PERSISTENT or VAR_GLOBAL RETAIN PERSISTENT.

See Inputs, Outputs and Flags for AC500 V2 Products

Constants

Constants are declared as VAR_GLOBAL CONSTANT or VAR_CONSTANT.

Example

(* Declaration as global constants *)

VAR_GLOBAL CONSTANT
  byConst_1 : BYTE := 1;
END_VAR

(* Declaration in the program *)

VAR CONSTANT
  byConst_2 : BYTE := 2;
END_VAR