CODESYS CTUD

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.

Source checked27/27 values · 2026-10-26

Specification

2 sources
Languagestructured text
CodeCTUD
GroupCounter
SyntaxCTUDInst(CU := VarBOOL1, CD := VarBOOL2, RESET := VarBOOL3, LOAD := VarBOOL4, PV := VarWORD1);
DialectCODESYS

Parameters

NameData typeDescription
CUBOOLRising edge: Incrementing CV by one
CDBOOLRising edge: Decrementing CV by one
RESETBOOLTRUE: Reset CV to 0
LOADBOOLTRUE: Set CV to the start value PV
PVWORDStart value for decrementing / upper limit for incrementing
QUBOOLTRUE if CV >= PV
QDBOOLTRUE if CV = 0
CVWORDCurrent 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.
↑↓ navigate↵ openesc close