9.3 Switch-o behavior
The controller has internal buer capacitors to save data during the shutdown process. This
memory funcon is iniated automacally if a voltage failure is detected.
Certain circuit secons, e.g. backplane bus supply and USB, are switched o
directly in the event of voltage failure in order to maintain voltage for the
internal saving process for a constant amount of me.
9.3.1 Retain variables and persistent variables
Retain variables
The controller automacally saves retain variables in the event of voltage failure. In this way,
they remain available when operaon resumes. Retain variables are reinialized when devices
are reset or a new PLC program is downloaded. The values are preserved in the event of an
online change.
Example
The values of a drive system which can no longer be read out from the machine due to a
voltage failure should be persistent. These values should also be persistent if the
corresponding value only changes through the inuence of the PLC.
Variable Use case Storage
Thermal sensor Changes, requires a sensor system. Not required
Posion value Available via absolute value encoder. Not required
Number of parts in buer storage Should be persistent so the value is not lost in
the event of a reset or program change.
Persistent
Posion of a conveyor line Posion should remain stored. Homing takes
place.
Retain
Example code
VAR RETAIN
remvar1: INT; (* 1. Remanent variable*)
END_VAR
Persistent variables
Persistent variables also remain stored in the event of a stop, restart, online change, or PLC
program download.
Persistent variables are saved when the device is switched o. Persistent variables are
reinialized by execung "RESET origin".
How to create persistent variables:
Precondion
•
Access to »PLC Designer«
1. Right-click on Applicaon.
2. Select New object.
3. Click on Persistent variables.
Example code
VAR_GLOBAL PERSISTENT RETAIN
uiPerRetain : ARRAY[0..1000] OF UINT; (* Declaration of persistent variable*)
END_VAR
Device funcons
Switch-o behavior
Retain variables and persistent variables
82