CTD

Provided by standard.lib.

Function Block Decrementer:

The input variables CD and LOAD as well as the output variable Q are type BOOL, the input variable PV and the output variable CV are type WORD.

When LOAD_ is TRUE, the counter variable CV will be initialized with the upper limit PV. If CD has a rising edge from FALSE to TRUE, CV will be lowered by 1 provided CV is greater than 0 (i.e., it doesn’t cause the value to fall below 0).

Q returns TRUE when CVis equal 0.

Declaration example

CTDInst : CTD ;

Example in IL

CAL  CTDInst(CD := VarBOOL1, LOAD := VarBOOL2, PV := VarINT1)

LD   CTDInst.Q

ST   VarBOOL3

LD   CTDInst.CV

ST   VarINT2

Example in FBD

../_images/0270e9ed437578000a33139006eab46b

Example in ST

CTDInst(CD:= VarBOOL1, LOAD:=VarBOOL2 , PV:= VarINT1);

VarBOOL3 := CTDInst.Q ;

VarINT2 := CTDInst.CV;