{"id":"iec-ctud","model_id":"CTUD","name":"CODESYS CTUD","summary":"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.","study_notes":["The source notes that datatype WORD, used for PV in CODESYS, does not match the IEC standard, which defines PV as INT."],"safety_notes":[],"sources":[{"url":"https://infosys.beckhoff.com/content/1033/tcplclib_tc2_standard/74402059.html","title":"Beckhoff Information System","accessed":"2026-10-26"},{"url":"https://content.helpme-codesys.com/en/libs/Standard/Current/Counter/CTUD.html","title":"CODESYS Group","accessed":"2026-10-26"}],"verification":{"status":"source_checked","checked_at":"2026-10-26","values":27,"method":"llm_source_check"},"updated_at":"2026-10-26","type":"instruction","spec":{"language":"structured_text","code":"CTUD","group":"Counter","syntax":"CTUDInst(CU := VarBOOL1, CD := VarBOOL2, RESET := VarBOOL3, LOAD := VarBOOL4, PV := VarWORD1);","parameters":[{"name":"CU","data_type":"BOOL","description":"Rising edge: Incrementing CV by one"},{"name":"CD","data_type":"BOOL","description":"Rising edge: Decrementing CV by one"},{"name":"RESET","data_type":"BOOL","description":"TRUE: Reset CV to 0"},{"name":"LOAD","data_type":"BOOL","description":"TRUE: Set CV to the start value PV"},{"name":"PV","data_type":"WORD","description":"Start value for decrementing / upper limit for incrementing"},{"name":"QU","data_type":"BOOL","description":"TRUE if CV >= PV"},{"name":"QD","data_type":"BOOL","description":"TRUE if CV = 0"},{"name":"CV","data_type":"WORD","description":"Current counter value"}],"dialect":"CODESYS","related":[],"standards":[]},"url":"https://machineschema.com/instruction/iec-ctud","license":"https://creativecommons.org/licenses/by/4.0/"}