7programming with the »plc designer – Lenze c300 User Manual
Page 65
7
Programming with the »PLC Designer«
7.5
Creating remanent variables (retain/persistent)
65
Lenze · Controller | Parameter setting & programming · Reference Manual · DMS 1.5 EN · 04/2014 · TD17
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
7.5.1
Storage of retain data on the SD card (only Controllers 3221 C/3231 C)
For Controllers 3221 C/3231 C, the values of the RETAIN variables are by default saved to the device
only.
• Use the L_Util_Retain function (from the L_Util.lib library) to save the RETAIN values to the SD
card of the controllers. Like this, the retain data can then be re-used, for instance after a device
replacement.
• RETAIN values saved to the SD card offer the benefit of subsequent use of these values after a
device replacement (subsequent use of the SD card).
L_Util_Retain
[7-1]
Program example: Use of the L_Util_Retain function
When being called, the L_Util_Retain function saves the retain/persistent variables to the SD card
to file: retains.ret (directory: IPC\PLC).
Note!
The SD card is only suitable for storing retain data if the RETAIN values do not change
very often.
• It is not possible to save the RETAIN values to the SD card during every PLC cycle.
• SD cards only have a limited number of write/read cycles. Thus, the retain variables
should not be saved at very short time intervals.
• Please avoid calling the L_Util_Retain() function in a motion task. The creation of the
RETAIN file prolongs the current PLC cycle of the calling task by several 100 ms.
• The functions SysSaveRetains() and SysRestoreRetains() provided in the
SysPlcCtrl23.Library are not supported and must not be used.
Function
Library
Function
L_Util_Retain()
L_Util.library
Save retain data to the SD card of the
controller.
PROGRAM PLC_PRG
VAR
FB_
LUtilRetain: L_Util_Retain;
xRetainsIntoFile_LUtilRetain: BOOL;
instSetRetainValues: SetRetainValues;
xSetRetain: BOOL;
xStoreRetains_LUtilRetain: BOOL;
END_VAR
Note!
Device replacement: Avoiding the loss of retain data
The L_Util_Retain function is only required for the Controllers 3221 C/3231 C.
• Use the L_Util_Retain function in the desired application in order to be able to re-use
the retain data, if required.
• In the event of a device replacement, the L_Util_Retain function must already have
been used in the application before, since otherwise the retain data are deleted.