L-force | plc designer – Lenze PLC Designer PLC Designer (R3-1) User Manual

Page 980

Advertising
background image

L-force | PLC Designer

Programming Reference

978

DMS 4.1 EN 03/2011 TD29

The Retain property can be combined with the Persistent property. See below, the
synoptic table.

Note:
If a local variable in a program is declared as VAR RETAIN, then exactly that variable
will be saved in the retain area (like a global retain variable)

If a local variable in a function block is declared as VAR RETAIN, then the complete
instance of the function block will be saved in the retain area (all data of the POU),
whereby only the declared retain variable will be handled as a retain.

If a local variable in a function is declared as VAR RETAIN, then this will be without
any effect. The variable will not be saved in the retain area ! If a local variable is
declared as PERSISTENT in a function, then this will be without any effect also !


Persistent variables
Persistent variables are identified by keyword "PERSISTENT" (VAR_GLOBAL
PERSISTENT
). They get only re-initialized at a Reset origin <application>. In contrast to
Retain variables they maintain their values after a download. An application example
for persistent variables would be a counter for operating hours, which should continue
counting even after a power fail or download. See below the synoptic table.
Persistent variables are handled like described in the following - and thus different
from »PLC Designer« V2.3
:
Persistent variables ONLY can be declared in a special global variables list of object
type 'Persistent Variables', which is assigned to an application. There might be only
ONE such list per application.

Note: As from V3.3.0.1 a declaration with "VAR_GLOBAL PERSISTENT" effects the
same as a declaration with " VAR_GLOBAL PERSISTENT RETAIN" or "VAR_GLOBAL
RETAIN PERSISTENT".

Like Retain variables the Persistent variables get stored in a separate memory area.
Example:

VAR GLOBAL PERSISTENT RETAIN
iVarPers1 : DINT; (* 1. Persistent+Retain Variable App1 *)
bVarPers : BOOL; (* 2. Persistent+Retain Variable App1 *)
END_VAR

Note: Currently only global persistent variables are possible.

The target system must provide a separate memory area for the persistent variables
list of each application.

Advertising