Attention
IronPLC can only run very simple programs. The steps described are accurate but many language features are not yet supported.
CTU¶
Count-up counter. Increments the counter value CV on each rising edge of
CU. Output Q becomes TRUE when CV reaches or exceeds the
preset value PV.
IEC 61131-3 |
Section 2.5.2.3.3 |
Support |
Supported |
Inputs¶
Name |
Type |
Description |
|---|---|---|
|
|
Count-up input (increments on rising edge) |
|
|
Reset input (sets CV to 0) |
|
|
Preset value |
Outputs¶
Name |
Type |
Description |
|---|---|---|
|
|
Counter output (TRUE when CV >= PV) |
|
|
Current counter value |
Behavior¶
On each rising edge of CU, the counter value CV is incremented by one.
When R is TRUE, CV is reset to zero. The output Q is TRUE
when CV is greater than or equal to the preset value PV.
Typed variants CTU_DINT, CTU_LINT, CTU_UDINT, and CTU_ULINT
use the corresponding integer type for PV and CV.
Example¶
This example counts up with CU held TRUE. After the first scan, CV
is 1 which equals PV, so done becomes TRUE.