Technical data

Table Of Contents
IEC Timers and IEC Counters
System Software for S7-300/400 System and Standard Functions - Volume 2/2
A5E00739858-01
25-5
25.4 Counting Up with SFB 0 "CTU"
Description
You can count up with SFB 0 "CTU." The counter is incremented by 1 by a rising
edge at the CU input (compared with the last SFB call). If the counted value
reaches the upper limit of 32767, it is no longer incremented. Each subsequent
rising edge at the CU input no longer has an effect.
Signal level 1 at the R input resets the counter to the value 0 regardless of the
value currently at the CU input.
The Q output indicates whether the current counted value is greater or equal to the
preset value PV.
SFB 0 "CTU" complies with the IEC 1131-3 standard.
The operating system resets the instances of SFB 0 "CTU" during a cold restart. If
you want instances of this SFB to be initialized following a warm restart, you must
call SFB 0 with R = 1 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
CU INPUT BOOL I, Q, M, D, L,
constant
Counter input
R INPUT BOOL I, Q, M, D, L,
constant
Reset input R is dominant over CU.
PV INPUT INT I, Q, M, D, L,
constant
Preset value. Refer to parameter Q for
the effect of PV.
Q OUTPUT BOOL I, Q, M, D, L Status of the counter: Q has the following
value
1, if CV > PV
0 otherwise
CV OUTPUT INT I, Q, M, D, L Current count value
(possible value: 0 to 32 767)