CTUD

CTUD 1:

The function block CTUD is an up and down counter.

CTUD 2: Inputs

VAR_INPUT
    CU    : BOOL; (* Count Up *)
    CD    : BOOL; (* Count Down *)
    RESET : BOOL; (* Reset Counter to Null *)
    LOAD  : BOOL; (* Load Start Value *) 
    PV    : WORD; (* Start Value / Counter Limit *)
END_VAR

Name

Type

Description

CU

BOOL

Counting up

CD

BOOL

Counting down

RESET

BOOL

Reset the counter to 0.

LOAD

BOOL

Load start value.

PV

WORD

Start value/counter limit

CTUD 3: Outputs

VAR_OUTPUT
    QU : BOOL; (* Counter reached Limit *)
    QD : BOOL; (* Counter reached Null *)
    CV : WORD; (* Current Counter Value *)
END_VAR

Name

Type

Description

QU

BOOL

QU returns TRUE if CV has become greater than or equal to PV.

QD

BOOL

QD returns TRUE if CV has become less than or equal to 0.

CV

WORD

If RESET applies, the count variable CV is initialized with 0. If LOAD applies, CV is initialized with PV. If CU has a rising edge from FALSE to TRUE, then CV is increased by 1 as long as CV does not cause an overflow. If CD has a rising edge from FALSE to TRUE, then CV is decremented by 1 as long as CV does not cause an underflow.

Requirements

Development environment

Target platform

PLC library to include

TwinCAT v3.0.0

PC or CX (x86)

Tc2_Standard