100BBasic instructions
7.2 Timers
S7-1200 Programmable controller
176
System Manual, 11/2011, A5E02486680-05
Time data retention after a RUN-STOP-RUN transition or a CPU power cycle
If a run mode session is ended with stop mode or a CPU power cycle and a new run mode
session is started, then the timer data stored in the previous run mode session is lost, unless
the timer data structure is specified as retentive (TP, TON, TOF, and TONR timers).
When you accept the defaults in the call options dialog after you place a timer instruction in
the program editor, you are automatically assigned an instance DB which cannot be made
retentive. To make your timer data retentive, you must either use a global DB or a Multi-
instance DB.
Assign a global DB to store timer data as retentive data
This option works regardless of where the timer is placed (OB, FC, or FB).
1.
Create a global DB:
–
Double-click "Add new block" from the Project tree
–
Click the data block (DB) icon
–
For the Type, choose global DB
–
If you want to be able to select individual data elements in this DB as retentive, be
sure the DB type "Optimized" box is checked. The other DB type option "Standard -
compatible with S7-300/400" only allows setting all DB data elements retentive or
none retentive.
–
Click OK
2.
Add timer structure(s) to the DB:
–
In the new global DB, add a new static tag using data type IEC_Timer.
–
In the "Retain" column, check the box so that this structure will be retentive.
–
Repeat this process to create structures for all the timers that you want to store in this
DB. You can either place each timer structure in a unique global DB, or you can place
multiple timer structures into the same global DB. You can also place other static tags
besides timers in this global DB. Placing multiple timer structures into the same global
DB allows you to reduce your overall number of blocks.
–
Rename the timer structures if desired.
3.
Open the program block for editing where you want to place a retentive timer (OB, FC, or
FB).
4.
Place the timer instruction at the desired location.
5.
When the call options dialog appears, click the cancel button.
6.
On the top of the new timer instruction, type the name (do not use the helper to browse)
of the global DB and timer structure that you created above (example:
"Data_block_3.Static_1").