100BBasic instructions
7.3 Counters
S7-1200 Programmable controller
System Manual, 11/2011, A5E02486680-05
181
Assign a global DB to store timer data as retentive data
This option works regardless of where the counter 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 items in this DB as retentive, be sure the
symbolic-access-only box is checked.
–
Click OK
2.
Add counter structure(s) to the DB:
–
In the new global DB, add a new static tag using one of the counter data types. Be
sure to consider the Type you want to use for your Preset and Count values.
Counter Data Type
Corresponding Type for the Preset and Count
Values
IEC_Counter
INT
IEC_SCounter
SINT
IEC_DCounter
DINT
IEC_UCounter
UINT
IEC_USCounter
USINT
IEC_UDCounter
UDINT
1.
In the "Retain" column, check the box so that this structure will be retentive.
–
Repeat this process to create structures for all the counters that you want to store in
this DB. You can either place each counter structure in a unique global DB, or you can
place multiple counter structures into the same global DB. You can also place other
static tags besides counters in this global DB. Placing multiple counter structures into
the same global DB allows you to reduce your overall number of blocks.
–
Rename the counter structures if desired.
2.
Open the program block for editing where you want to place a retentive counter (OB, FC,
or FB).
3.
Place the counter instruction at the desired location.
4.
When the call options dialog appears, click the cancel button. You should now see a new
counter instruction which has "???" both just above and just below the instruction name.
5.
On the top of the new counter instruction, type the name (do not use the helper to
browse) of the global DB and counter structure that you created above (example:
"Data_block_3.Static_1"). This causes the corresponding preset and count value type to
be filled in (example: UInt for an IEC_UCounter structure).
Assign a multi-instance DB to store counter data as retentive data
This option only works if you place the counter in an FB.