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.
| Language | structured text |
|---|---|
| Code | CTUD |
| Group | Counter |
| Syntax | CTUDInst(CU := VarBOOL1, CD := VarBOOL2, RESET := VarBOOL3, LOAD := VarBOOL4, PV := VarWORD1); |
| Dialect | CODESYS |
| 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 |