TwinCAT 3 PLC

Remanent Variables - PERSISTENT

Remanent variables can retain their value throughout the usual program run period. They are declared as ' 'Persistent Variables'.

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_A4

NOTICE!

If a TwinCAT 2.x PLC Control project is opened, the declarations of Retain variables will maintain effective, the declarations of persistent variables however must be reworked resp. redone, see “Persistent Variables”.

Note_A4

NOTICE!

Do not use the AT Declaration in combination with VAR PERSISTENT !

Note_A4

NOTICE!

Do not declare function blocks of Beckhoff PLC libraries PERSISTENT! The complete instance will be automatically stored in the Persistent variable file. This might make problems in functionblocks with ADS blocks internally used.

See in the following:

“Persistent Variables”

“Synoptic table on the behaviour of remanent variables”

Retain Variables

RETAIN is a reserved keyword in IEC61131-3. In TwinCAT 3 RETAIN is reserved. If RETAIN is used a compile error will be generated automatically. Use PERSISTENT instead.

Persistent Variables

Persistent variables are identified by keyword 'PERSISTENT' (VAR_GLOBAL PERSISTENT). They get only re-initialized at a reset origin. 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: “Synoptic table on the behaviour of remanent variables”.

At each re-load of the application the persistent variables list on the PLC will be checked against that of the project. The list on the PLC inter alia is identified by the application name. In case of inconsistencies the user will be prompted to re-initialize all persistent variables of the application. Inconsistency might result from renaming or removing or other modifications of the existing declarations in the list.

Note_A4

NOTICE!

So carefully consider any modifications in the declaration part of the persistent variables list and the effect of the resultantly requested re-initialization !

New declarations only can be added at the end of the list. At a download those will be detected as "new" and will not demand a re-initialization of the complete list.

Synoptic table on the behaviour of remanent variables

x = Value gets maintained - = Value gets initialized

after Online command

VAR

VAR PERSISTENT

Reset warm <application>

-

x

Reset cold <application>

-

x

Reset origin <application>

-

-

Download <application>

-

x

Online Change <application>

x

x

Reboot PLC

-

x