# CODESYS CTD

Instructions · `CTD` · verification: source checked

CTD is a standard function block that decrements a counter value. A rising edge on the CD input reduces the current counter value CV by one, and LOAD set to TRUE loads CV with the start value PV. The output Q is TRUE when CV equals zero.

## Specification

| Property | Value |
|---|---|
| Language | structured text |
| Code | CTD |
| Group | Counter |
| Syntax | CTDInst(CD:=VarBOOL1, LOAD:=VarBOOL2, PV:=VarWORD1); |
| Dialect | CODESYS |

### Parameters

| Name | Data type | Description |
|---|---|---|
| CD | BOOL | Rising edge: decrementing CV by one |
| LOAD | BOOL | TRUE: Set CV to the start value PV |
| PV | WORD | Start value for decrementing |
| Q | BOOL | TRUE if CV = 0 |
| CV | WORD | Current counter value |

## Study notes

- The block must be declared as an instance before use, e.g. CTDInst : CTD;
- Results are read from the instance after the call, e.g. VarBOOL3 := CTDInst.Q; and VarWORD2 := CTDInst.CV;
- Listed under the Counter group of the Standard library.

## Sources

1. [Beckhoff Information System](https://infosys.beckhoff.com/content/1033/tcplclib_tc2_standard/74398987.html) (accessed 2026-10-26)
2. [CODESYS Group](https://content.helpme-codesys.com/en/libs/Standard/Current/Counter/CTD.html) (accessed 2026-10-26)

---

Source page: https://machineschema.com/instruction/iec-ctd  
JSON: https://machineschema.com/instruction/iec-ctd.json  
License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Cite Machine Schema and the original sources.
