7.2.3 CTD_DINT
Function
CTD_DINT 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 | DINT | Preset value |
| LD | Var_Input | BOOL | Load preset value, set CV to PV |
| Q | Var_Output | BOOL | Counter status, output bit |
| CV | Var_Output | DINT | The value of the current count |
Corresponding syntax
- Counting range: -2147483648~2147483647
- The rest of the syntax refers to CTD_INT
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_DINT_1(
CD:=DOWN,
LD:=LOAD,
PV:=1,
Q=>OUT,
CV=>cVar
);
IF OUT THEN
iVar:=1;
ELSE
iVar:=0;
END_IF;