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

CU

BOOL

Count-up input. Increments CV on each rising edge.

R

BOOL

Reset input. Resets CV to zero while TRUE.

PV

INT

Preset value. The threshold at which Q becomes TRUE.

Outputs

Name

Type

Description

Q

BOOL

TRUE when the current counter value CV is greater than or equal to PV.

CV

INT

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.

PROGRAM main
   VAR
      counter : CTU;
      done : BOOL;
      count : INT;
   END_VAR

   counter(CU := TRUE, R := FALSE, PV := 1, Q => done, CV => count);
   (* After first scan: count = 1, done = TRUE *)
END_PROGRAM

See Also

  • CTD — count-down counter

  • CTUD — count up/down counter