6 counters, 1 ctu, 2 ctd – Lenze DDS v2.3 User Manual
Page 306: Drive plc developer studio

Drive PLC Developer Studio
IEC 61131-3 Standard functions
14-14
l
DDS EN 2.3
14.6
Counters
14.6.1
CTU
Up counter
CU
, RESET and Q are of type BOOL, PV and CV are of type INT.
•
If RESET is TRUE, the counter variable CV is set to 0.
•
Every positive edge at input
CU increases CV by 1.
As long as
CV is less than PV max (i.e. no overflow).
•
Q
returns TRUE if CV is greater than or equal to the upper limit PV .
CTU(CU, RESET, PV, Q, CV)
means:
•
If RESET is TRUE, the counter variable CV will be initialized with 0.
•
If CU has a rising edge, CV will be increased by 1.
Examples
Declaration:
CTUInst : CTU;
IL
FBD
CAL CTUInst(CU:=VarBOOL1, RESET:=VarBOOL2, PV:=VarINT1)
LD CTUInst.Q
ST VarBOOL3
LD CTUInst.CV
ST VarINT2
ST
CTUInst(CU:=VarBOOL1, RESET:=VarBOOL2, PV:=VarINT1);
VarBOOL3:=CTUInst.Q;
VarINT2:=CTUInst.CV;
14.6.2
CTD
Down counter
CD
, LOAD and Q are of type BOOL, PV and CV are of type INT.
•
If LOAD is TRUE, the counter variable CV will be set equal to the upper limit PV.
•
If LOAD is FALSE, every function block call will decrease CV by 1.
•
Q
returns TRUE if CV is less than or equal to 0.
CTD(CD, LOAD, PV, Q, CV)
Examples
Declaration:
CTDInst : CTD;
IL
FBD
CAL CTDInst(CD:=VarBOOL1, LOAD:=VarBOOL2, PV:=VarINT1)
LD CTDInst.Q
ST VarBOOL3
LD CTDInst.CV
ST VarINT2
ST
CTUInst(CD:=VarBOOL1, LOAD:=VarBOOL2, PV:=VarINT1);
VarBOOL3:=CTDInst.Q;
VarINT2:=CTDInst.CV;
Show/Hide Bookmarks