CTUD

The CTUD function block is an up and down counter.
If RESET = TRUE, the counter variable CV is initialized with 0. If LOAD = TRUE, the counter variable CV is initialized with the upper limit PV.
If the CU input has a rising edge from FALSE to TRUE, the counter variable CV is increased by one. If the counter variable CV reaches the value of the counter limit PV, the QU output is set to TRUE.
If the CD input has a rising edge from FALSE to TRUE, the counter variable CV is reduced by one as long as CV is greater than 0. If the counter variable CV reaches the value 0, the QD output is set to TRUE.
Inputs
VAR_INPUT
CU : BOOL; (* Count Up on Rising Edge*)
CD : BOOL; (* Count Down on Rising Edge*)
RESET : BOOL; (* Reset Counter to 0 *)
LOAD : BOOL; (* Load Start Value *)
PV : WORD; (* Start Value / Counter Limit *)
END_VARName | Type | Description |
|---|---|---|
CU | BOOL | On a rising edge: count up by one |
CD | BOOL | On a rising edge: count down by one |
RESET | BOOL | TRUE: Reset counter variable CV to the value 0 |
LOAD | BOOL | TRUE: Set counter variable CV to the start value PV |
PV | WORD | Start value/counter limit |
Outputs
VAR_OUTPUT
QU : BOOL; (* Counter reached Limit *)
QD : BOOL; (* Counter reached 0 *)
CV : WORD; (* Current Counter Value *)
END_VARName | Type | Description |
|---|---|---|
QU | BOOL | TRUE if the counter value CV is greater than or equal to the counter limit PV. |
QD | BOOL | TRUE if the counter value CV is 0. |
CV | WORD | Counter variable (current counter value) |
Requirements
Development environment | Target platform | PLC library to include |
|---|---|---|
TwinCAT v3.0.0 | PC or CX (x86) | Tc2_Standard |