CTUD / CTUDr

PLCopen motion icon

 Function BlockClosed A function block groups an algorithm and a set of private data. It has inputs and outputs. - Up/down counter.

Inputs

Input

Data Type

Range

Unit

Default

Description

CD

BOOL

 

 

 

Enable counting.

Counter is decreased on each call when CD is TRUE.

CU

BOOL

 

 

 

Enable counting.

Counter is increased on each call when CU is TRUE.

LOAD

BOOL

 

 

 

Re-load command.

Counter is set to PV when called with LOAD to TRUE.

PV

DINT

 

 

 

Programmed maximum value.

RESET

BOOL

 

 

 

Reset command.

Counter is reset to 0 when called with RESET to TRUE.

Outputs

Output

Data Type

Range

Unit

Description

CV

DINT

 

 

Current value of the counter.

QD

BOOL

 

 

TRUE when counter is empty (i.e., when CV = 0).

QU

BOOL

 

 

TRUE when counter is full (i.e., when CV = PV).

Remarks

FBD Language

CtudFbd.gif (1604 octets)

FFLD Language

  • In FFLD language, CU is the input rung.
    • The output rung is the QU output.

CtudLd.gif (1724 octets)

IL Language

(* MyCounter is a declared instance of CTUD function block. *)
Op1: CAL    MyCounter (CU, CD, RESET, LOAD, PV)
FFLD     MyCounter.QU
ST     QU
FFLD     MyCounter.QD
ST     QD
FFLD     MyCounter.CV
ST     CV

ST Language

(* MyCounter is a declared instance of CTUD function block. *)
MyCounter (CU, CD, RESET, LOAD, PV);
QU := MyCounter.QU;
QD := MyCounter.QD;
CV := MyCounter.CV;

See Also

CTU / CTUr