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
Parameter description
| Interface variables | Declaration | Data type | Description |
|---|---|---|---|
| CU | Var_Input | BOOL | Up counter input |
| PV | Var_Input | INT | Preset value |
| R | Var_Input | BOOL | Reset input, CV cleared |
| Q | Var_Output | BOOL | Counter status, output bit |
| CV | Var_Output | INT | The 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:

-
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;