CODESYS CTD

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.

Source checked18/18 values · 2026-10-26

Specification

2 sources
Languagestructured text
CodeCTD
GroupCounter
SyntaxCTDInst(CD:=VarBOOL1, LOAD:=VarBOOL2, PV:=VarWORD1);
DialectCODESYS

Parameters

NameData typeDescription
CDBOOLRising edge: decrementing CV by one
LOADBOOLTRUE: Set CV to the start value PV
PVWORDStart value for decrementing
QBOOLTRUE if CV = 0
CVWORDCurrent 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.
↑↓ navigate↵ openesc close