Remanent variables - retain, persistent, L-force | plc designer – Lenze PLC Designer PLC Designer (R3-1) User Manual

Page 979

Advertising
background image

L-force | PLC Designer

Programming Reference

DMS 4.1 EN 03/2011 TD29

977

16.1.19

Remanent variables - RETAIN, PERSISTENT
Remanent variables can retain their value throughout the usual program run period.
They are declared as "Retain Variables" or even more stringent as "Persistent
Variables". For each case a separate memory area is used.
The declaration determines the degree of "resistance" of a remanent variable in the
case of resets, downloads or a reboot of the PLC. In applications mainly the
combination of both remanent flags will be required (see below Persistent Variables).

Note: If a V2.3-project is opened, the declarations of Retain variables will maintain
effective, the declarations of persistent variables however must be reworked, see
below: an own persistent global variables list must be created!
Note: Do not use the "AT Declaration" in combination with "VAR RETAIN" or "VAR
PERSISTENT !

See in the following:
Retain variables
Persistent variables
Synoptic table on the behaviour

Retain variables
Variables declared as "Retains" will be kept PLC-dependently but typically in a separate
memory area. They get the keyword "RETAIN" in their declaration in a POU resp. a in a
global variable list.
Example:

VAR RETAIN
iRem1 : INT; (* 1. Retain variable*)
END_VAR

Retain variables are identified by the keyword RETAIN. These variables maintain their
value even after an uncontrolled shutdown of the controller as well as after a normal
switch off and on of the controller (resp. at the online command Reset warm
<application>. When the program is run again, the stored values will be processed
further. A concrete example would be an piece-counter in a production line, that
recommences counting after a power failure.
All other variables are newly initialized, either with their initialized values or with the
standard initializations.
Contrary to Persistent variables Retain Variables are reinitialized at a new download of
the program.
Application example: A piece counter in a production machine, which should continue
counting after a power fail.
Retain variables however are re-initialized at 'Reset origin <application>' and - in
contrast to persistent variables - at 'Reset cold <application>' and an application
download.

Advertising