CTU / CTUrPLCopen motion icon

FunctionClosedA function calculates a result according to the current value of its inputs. A function has no internal data and is not linked to declared instances. Block - Up counter.

Inputs

CU : BOOL     Enable counting. Counter is increased on each call when CU is TRUE
RESET : BOOL  Reset command. Counter is reset to 0 when called with RESET to TRUE
PV : DINT     Programmed maximum value

Outputs

Q : BOOL      TRUE when counter is full, i.e. when CV = PV
CV : DINT     Current value of the counter

Remarks

The counter is empty (CV = 0) when the application starts. The counter does not include a pulse detection for CU input. Use R_TRIG or F_TRIG function block for counting pulses of CU input signal. In FFLD language, CU is the input rung. The output rung is the Q output.

CTUr, CTDr, CTUDr function blocks operate exactly as other counters, except that all Boolean inputs (CU, CD, RESET, LOAD) have an implicit rising edgeClosedA rising edge is the transition of a digital signal from low to high. It is also called positive edge detection included.

ST Language

(* MyCounter is a declared instance of CTU function block *)
MyCounter (CU, RESET, PV);
Q := MyCounter.Q;
CV := MyCounter.CV;

FBD Language

CtuFbd.gif (1380 octets)

FFLD Language

CtuLd.gif (1486 octets)

IL Language:

(* MyCounter is a declared instance of CTU function block *)
Op1: CAL    MyCounter (CU, RESET, PV)
FFLD     MyCounter.Q
ST     Q
FFLD     MyCounter.CV
ST     CV

See also

CTD   CTUD