Remanent Variables

Overview

Remanent variables can either be reinitialized or retain their values in the event of power outages, reboots, resets, and application program downloads. There are multiple types of remanent variables, declared individually as retain or persistent, or in combination as retain-persistent.

NOTE: For this controller, variables declared as persistent behave in the same way as variables declared as retain-persistent.

This table describes the behavior of remanent variables in each case:

Action

VAR

VAR RETAIN

VAR GLOBAL RETAIN PERSISTENT

Online change to application program

X

X

X

Online change modifying the boot application (1)

X

X

Stop

X

X

X

Power cycle

X

X

Reset warm

X (2)

X

Reset cold

X

Reset origin

Reset origin device

Download of application program using EcoStruxure Machine Expert (3)

X

Download of application program using an SD card (3)

(X) The value is maintained.

(–) The value is reinitialized.

(1) Retain variable values are maintained if an online change modifies only the code part of the boot application (for example, a:=a+1; => a:=a+2;). In all other cases, retain variables are reinitialized.

(2) For more details on VAR RETAIN, refer to Effects of the Reset warm Command.

(3) If the downloaded application contains the same retain-persistent variables as the existing application, the existing retain variables maintain their values.

NOTE: The first 1000 %MW are automatically retained and persistent if no variable is associated to them. Their values are kept after a reboot / Reset warm / Reset cold. The other %MW are managed as VAR.

For example, if you have in your program:

VAR myVariable AT %MW0 : WORD; END_VAR

%MW0 behaves like myVariable (not retained and not persistent).

Adding Retain-Persistent Variables

Declare retain-persistent (VAR GLOBAL PERSISTENT RETAIN) variables in the PersistentVars window:

Step

Action

1

In the Applications tree, select the Application node.

2

Click the right mouse button.

3

Choose Add Objects > Persistent variables

4

Click Add.

Result: The PersistentVars window is displayed.