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-7
25.6 Up / Down Count with SFB 2 "CTUD"
Description
You can count up and down with SFB 2 "CTUD." The count value is changed by a
rising edge, compared with the last SFB call as follows:
At input CU it is incremented by 1
At input CD it decrements by 1.
If the count value reaches the limits, the counter reacts as follows:
The lower limit of -32768, it is no longer decrements
The upper limit of 32767, it is no longer incremented.
If there is a rising edge at both input CU and input CD in one cycle, the counter
retains its current value. This reaction does not comply with the standard
IEC 1131-3. In the standard, the CU input is dominant if both signals are active at
the same time. This change has been proposed to the IEC.
A signal level 1 at the LOAD input presets the counter to the value PV regardless
of the values at the CU and CD inputs.
The signal level 1 at the R input resets the counter to the value 0 regardless of the
values at the CU, CD and LOAD inputs. The QU output indicates whether the
current count value is greater than or equal to the preset value PV; the QD output
indicates whether the value is less than or equal to 0.