PLC concepts
5.1 Execution of the user program
S7-1200 Programmable controller
System Manual, V4.2, 09/2016, A5E02486680-AK
111
You can avoid data loss after power failure by marking certain data as retentive. The CPU
allows you to configure the following data as retentive:
● Bit memory (M): You can define the size of retentive memory for bit memory in the PLC
tag table or in the assignment list. Retentive bit memory always starts at MB0 and runs
consecutively up through a specified number of bytes. Specify this value from the PLC
tag table or in the assignment list by clicking the "Retain" toolbar icon. Enter the number
of M bytes to retain starting at MB0.
Note: For any block, you can display the assignment list by selecting a block in the
Program Blocks folder and then selecting he
menu command.
● Tags of a function block (FB): If an FB is of type "Optimized block access", then the
interface editor for this FB includes a "Retain" column. In this column, you can select
either "Retain", "Non-retain", or "Set in IDB" individually for each tag. When you place
such an FB in the program, the instance DB that corresponds to the FB includes this
"Retain" column as well. You can only change the retentive state of a tag from within the
instance DB interface editor if you selected "Set in IDB" (Set in instance data block) in the
Retain selection for the tag in the optimized FB.
If an FB is
of type "Optimized block access", then the interface editor for this FB does
not include a "Retain" column. When you place such an FB in the program, the instance
DB that corresponds to the FB does, however, include a "Retain" column that is available
for edit. In this case, selecting the "Retain" option for any tag results in the selection of
tags. Similarly, deselecting the option for any tag results in the deselection of
tags.
To view or modify whether an FB is optimized, open the properties of the FB and select
the attributes.
● Tags of a global data block: The behavior of a global DB with regard to retentive state
assignment is similar to that of an FB. Depending on the block access setting you can
define the retentive state either for individual tags or for all tags of a global data block.
– If you select "Optimized" when you create the DB, you can set the retentive state for
each individual tag.
– If you select "Standard - compatible with S7-300/400" when you create the DB, the
retentive-state setting applies to all tags of the DB; either all tags are retentive or no
tag is retentive.
The CPU supports a total of 10240 bytes of retentive data. To see how much is available,
from the PLC tag table or the assignment list, click the "Retain" toolbar icon. Although this is
where the retentive range is specified for M memory, the second row indicates the total
remaining memory available for M and DB combined. Note that for this value to be accurate,
you must compile all data blocks with retentive tags.
Note
Downloading a program does not clear or make any changes to existing values in retentive
memory. If you want to clear retentive memory before a download, then reset your CPU
to
factory settings prior to downloading the program.