# CODESYS CTUD

Instructions · `CTUD` · verification: source checked

CTUD is a function block in the CODESYS Standard library that increments and decrements a given value. A rising edge on CU increments CV by one, and a rising edge on CD decrements CV by one. RESET sets CV to 0, LOAD sets CV to PV, QU is TRUE when CV >= PV, and QD is TRUE when CV = 0.

## Specification

| Property | Value |
|---|---|
| Language | structured text |
| Code | CTUD |
| Group | Counter |
| Syntax | CTUDInst(CU := VarBOOL1, CD := VarBOOL2, RESET := VarBOOL3, LOAD := VarBOOL4, PV := VarWORD1); |
| Dialect | CODESYS |

### Parameters

| Name | Data type | Description |
|---|---|---|
| CU | BOOL | Rising edge: Incrementing CV by one |
| CD | BOOL | Rising edge: Decrementing CV by one |
| RESET | BOOL | TRUE: Reset CV to 0 |
| LOAD | BOOL | TRUE: Set CV to the start value PV |
| PV | WORD | Start value for decrementing / upper limit for incrementing |
| QU | BOOL | TRUE if CV >= PV |
| QD | BOOL | TRUE if CV = 0 |
| CV | WORD | Current counter value |

## Study notes

- The source notes that datatype WORD, used for PV in CODESYS, does not match the IEC standard, which defines PV as INT.

## Sources

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

---

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