Remanent Variables

Overview

Remanent data refers to variables that are defined in Programming Organization Units (POUs) as retain or retain-persistent. In the event of power outages, reboots, resets, and application program downloads, remanent variables can either be reinitialized or retain their values.

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

Download of application program(3)

X

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 application is downloaded using an SD card, any existing retain-persistent variables used by the application are reinitialized. If the application is downloaded using EcoStruxure Machine Expert, however, existing retain-persistent variables maintain their values. In both cases, if the downloaded application contains the same retain-persistent variables as the existing application, the existing retain variables maintain their values.

Adding Retain-Persistent Variables

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.

Retain and Persistent Variables: Performance Impact

Retain or retain-persistent variables are located in a dedicated non-volatile memory. Each time these variables are accessed during Programming Organization Unit (POU) execution, the non-volatile memory is accessed. The access time of these variables is slower than the access time of regular variables, which can impact performance. This is an important fact to take into account when writing performance-sensitive POUs.

For more information about the impact of retain and retain persistent variables on cycle time during POU execution, see Processing Performance.