CTUΒΆ

Provided by Standard Library.

Function block working as an incrementer:

Inputs:

CU : BOOL; With each rising edge at this input the Counter-Value (CV) is incremented by 1. When CV reaches or exceeds PV, Q will be set to TRUE.

RESET : BOOL; if TRUE, CV will be reset to 0.

PV : WORD; Upper limit for the incrementing of CV, that means that Q gets TRUE as soon as CV >= PV.

Attention

Datatype WORD, which is used for PV in CODESYS, does not match the IEC standard, which for PV defines datatype INT.

Outputs:

Q : BOOL; Gets TRUE as soon as CV is equal or greater than the limit given by PV.

CV : WORD; Contains the value to be incremented; gets initialized with 0 if RESET is TRUE; will be raised by 1 always when CU gets a rising edge, until the maximum value of 65535 (16#FFFF) is reached; as soon as CV >= PV, Q will be set to TRUE.

Declaration example:\ \ \ \

CTUInst : CTU ;

Example in IL:\ \ \ \

../_images/2014b2891e8f7998c0a8640e01947982

Example in FBD:\ \ \ \

../_images/8049a5c51e8f7811c0a8640e01947982

Example in ST\ \ \ \ :

CTUInst(CU:= VarBOOL1, RESET:=VarBOOL2 , PV:= VarWORD1);
VarBOOL3 := CTUInst.Q ;
VarWORD2 := CTUInst.CV;