CTUDΒΆ

Provided by standard.lib.

Function Block Incrementer/Decrementer

The input variables CU, CD, RESET, LOAD as well as the output variables QU and QD are type BOOL, PV and CV are type WORD.

If RESET is valid, the counter variable CV will be initialized with 0. If LOAD is valid, CV will be initialized with PV.

If CU has a rising edge from FALSE to TRUE, CV will be raised by 1. If CD has a rising edge from FALSE to TRUE, CV will be lowered by 1 provided this does not cause the value to fall below 0.

QU returns TRUE when CV has become greater than or equal to PV.

QD returns TRUE when CV has become equal to 0.

Declaration example:

CTUDInst : CUTD ;

Example in IL

CAL  CTUDInst(CU:=VarBOOL1, RESET:=VarBOOL3, LOAD:=VarBOOL4, PV:=VarINT1)

LD   CTUDInst.Q

ST   VarBOOL5

LD   CTUDInst.QD

ST   VarBOOL5

LD   CTUInst.CV

ST   VarINT2

Example in FBD

../_images/cb6601ba437578bb0a33139006eab46b

Example in ST

CTUDInst(CU := VarBOOL1, RESET := VarBOOL3, LOAD:=VarBOOL4 , PV:= VarINT1);

VarBOOL5 := CTUDInst.QU ;

VarBOOL6 := CTUDInst.QD ;

VarINT2 := CTUDInst.CV;