Technical data

Table Of Contents
IEC Timers and IEC Counters
System Software for S7-300/400 System and Standard Functions - Volume 2/2
25-6
A5E00739858-01
25.5 Counting Down with SFB 1 "CTD"
Description
You can count down with SFB 1 "CTD." The counter decrements at a rising edge
on the CD input (compared with the last SFB call). If the count value reaches the
lower limit of -32768, it no longer decrements. Any further rising edge at the CD
input then has no further effect.
Signal level 1 at the LOAD input sets the counter to the preset value PV regardless
of the value at the CD input.
The Q output indicates whether the current counted value is less than or equal to 0.
SFB 1 "CTD" complies with the IEC 1131-3 standard.
The operating system resets instances of SFB 1 "CTD" during a cold restart. If you
want instances of this SFB to be initialized following a warm restart, you must call
SFB 1 with LOAD = 1 and PV = required initial value for CV in OB100. If instances
of this SFB are located within another block, you can reset these instances, for
example, by initializing the higher-level block.
Parameter Declaration Data Type Memory Area Description
CD INPUT BOOL I, Q, M, D, L,
constant
Count input
LOAD INPUT BOOL I, Q, M, D, L,
constant
Load input. LOAD is dominant over CD.
PV INPUT INT I, Q, M, D, L,
constant
Preset value. The counter is preset to PV
when the signal level at the LOAD input
is 1.
Q OUTPUT BOOL I, Q, M, D, L Status of the counter: Q has the following
value:
1, if CV
<
0
0 otherwise
CV OUTPUT INT I, Q, M, D, L Current count value(possible values: -32
768 to 32 767)