CTUD

CTUD 1:

Incrementer and Decrementer

VAR_INPUT

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

VAR_OUTPUT

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

If RESET is valid, the counter variable CV will be initialized with 0. If LOAD is valid, CV will be initialized with PV. If CU has a rising edge from FALSE to TRUE, CV will be raised by 1 pro-vided CV does not cause an overflow. If CD has a rising edge from FALSE to TRUE, CV will be lowered by 1 provided this does not cause the value to fall below 0.QU returns TRUE when CV has become greater than or equal to PV. QD returns TRUE when CV has become less than or equal to 0.

Requirements

Development environment

Target system type

PLC libraries to be linked

TwinCAT v3.0.0

PC or CX (x86)

Tc2_Standard