Skip to main content

7.2.2 CTU_INT

Function

CTU_INT is called an up counter, used to accumulate the number of input pulses (0->1 or 1->0) at the input end.

LD graphics

alt text

Parameter description

Interface variablesDeclarationData typeDescription
CUVar_InputBOOLUp counter input
PVVar_InputINTPreset value
RVar_InputBOOLReset input, CV cleared
QVar_OutputBOOLCounter status, output bit
CVVar_OutputINTThe value of the current count

Corresponding syntax

  • Counting range: -32768~32767
  • If the current value is greater than or equal to the preset value, the counter bit is turned on
  • Whenever CU changes from FALSE to TRUE, CV increases by 1;
  • When CV is equal to PV, Q outputs TRUE. After that, whenever CU changes from FALSE to TRUE, Q keeps outputting TRUE, and CV continues to increase to 1 until it reaches the maximum value of the integer type specified by the counter;
  • At any time, as long as R is TRUE, Q outputs FALSE, and CV immediately stops counting and returns to 0
warning

Function block usage requires global declaration of an instance

Example

  • LD example is shown in the following animation: alt text

  • ST example is shown in the following code:

CTU_INT_1(
CU:=UP,
R:=RESET,
PV:=1,
Q=>OUT,
CV=>cVar
);
IF OUT THEN
iVar:=1;
ELSE
iVar:=0;
END_IF;