Retaining data in optimized and non-optimized blocks
When a PLC loses power, runtime variable data is lost and reset back to its default values, unless it is checked to be retained. Retained data persists after a power fail or a download to the PLC, and it only resets to its default values when a reinitialization occurs or a memory clear of the PLC occurs. If a variable needs to retain information, the Retain function needs to be selected in the corresponding data block or interface:
Figure 13.8 shows an example of four values set to Retain in a data block. Once the Retain box has been checked for some given data, the changes must be downloaded to the PLC. This will cause a reinitialization of the data.
Retaining data in instance data
Function blocks and associated instance data blocks can also have data retention set. However, there are more options involved, and it also depends on whether the function block...