CTU

CTU 1:

Incrementer:

VAR_INPUT

VAR_INPUT
    CU      : BOOL; (* Count Up *)
    RESET   : BOOL; (* Reset Counter to 0 *)
    PV      : WORD; (* Counter Limit *)
END_VAR

VAR_OUTPUT

VAR_OUTPUT
    Q       : BOOL; (* Counter reached the Limit *)
    CV      : WORD; (* Current Counter Value *)
END_VAR

The counter variable CV will be initialized with 0 if RESET is TRUE. If CU has a rising edge from FALSE to TRUE, the function block CV will be raised by 1 provided CV is smaller than PV (i.e., it doesn't cause an overflow). Q will return TRUE when CV is greater than or equal to the upper limit PV.

Requirements

Development environment

Target system type

PLC libraries to include

TwinCAT Version >= 2.6.0

PC or CX (x86)

Standard.Lib

TwinCAT Version >= 2.6.0

BC (165)

Standard.Lb6

TwinCAT Version >= 2.9.0

BCxx50 or BX

Standard.lbx

TwinCAT Version >= 2.10.0 Build >= 1301

CX (ARM)

Standard.lib