7.2.4 CTD_INT
Function
CTD_INT is called a down 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 |
|---|---|---|---|
| CD | Var_Input | BOOL | Down counter input |
| PV | Var_Input | INT | Preset value |
| LD | Var_Input | BOOL | Load preset value, set CV to PV |
| Q | Var_Output | BOOL | Counter status, output bit |
| CV | Var_Output | INT | The value of the current count |
Corresponding syntax
- Counting range: -32768~32767
- CD changes from FALSE to TRUE, CV decreases by 1;
- When CV is equal to 0, Q outputs TRUE. After that, whenever CD changes from FALSE to TRUE, Q keeps outputting TRUE, and CD continues to decrease by 1 until it reaches the minimum value of the integer type specified by the counter.
- At any time, as long as LD is TRUE, Q outputs FALSE, and CV immediately stops counting and returns to the PV value
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:
CTD_INT_1(
CD:=DOWN,
LD:=LOAD,
PV:=1,
Q=>OUT,
CV=>cVar
);
IF OUT THEN
iVar:=1;
ELSE
iVar:=0;
END_IF;