CTUD (count up down)
The CTUD instruction counts integers from 0 up to a given value, one by one, or from a given value down to 0, one by one.
Languages supported: Function block diagram, ladder diagram, structured text.
This instruction applies to the Micro810, L20E, L50E, and L70E controllers.
CTUD

Parameter | Parameter Type | Data Type | Description |
---|---|---|---|
CU | Input | BOOL | TRUE: Rising Edge detected, count up. |
CD | Input | BOOL | TRUE: Rising Edge detected, count down. |
RESET | Input | BOOL | Reset dominant (highest priority when determining instruction behavior) command. (CV = 0 when RESET is TRUE). |
LOAD | Input | BOOL | Load command. TRUE: Set CV = PV. |
PV | Input | DINT | Programmed maximum value. |
QU | Output | BOOL | Overflow. TRUE: When CV >= PV. |
QD | Output | BOOL | Underflow. TRUE: When CV <= 0. |
CV | Output | DINT | Counter result. |
CTUD examples
CTUD function block diagram example

CTUD ladder diagram example

CTUD structured text example

(* ST Equivalence: We suppose CTUD1 is an instance of block*) CTUD1(trigger1, trigger2, reset_cmd, load_cmd,100); full := CTUD1.QU; empty := CTUD1.QD; nb_elt := CTUD1.CV;
Results

Provide Feedback