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.
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, (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. |
%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).