CTU Up counter (CTU)

Also called: count up, CTU counter, incrementing counter

Counts rising edges of CU; Q / DN turns 1 when CV / ACC ≥ PV / PRE.Counts rising edges of CU; Q turns 1 when CV ≥ PV.Counts rising edges of CU; DN turns 1 when ACC ≥ PRE.

What it does

The CTU counter adds 1 to CV / ACC each time power reaches the instruction (0 to 1). When CV / ACC reaches the preset (CV / ACC ≥ PV / PRE), Q / DN turns 1. Reset: the R input in the European style, the RES instruction in the American style.The CTU counter adds 1 to CV each time power reaches the instruction (0 to 1). When CV reaches the preset (CV ≥ PV), Q turns 1. Reset: the R input in the European style, the RES instruction in the American style.The CTU counter adds 1 to ACC each time power reaches the instruction (0 to 1). When ACC reaches the preset (ACC ≥ PRE), DN turns 1. Reset: the R input in the European style, the RES instruction in the American style.

When to use it

To count parts, cycles or presses; trigger an action after N events.

Operands

European mnemonicAmerican mnemonicNameData typeDirectionRequiredAccessMeaning
InstanceInstanceInstance (the counter’s memory)IEC_COUNTER / COUNTERInputYes—Instance (C1…): the counter's memory.
CUCUCount upBOOLInputYesRead (C1.CU)The bit to count: it says the instruction is active. Each time power reaches the instruction (0 to 1), CV / ACC goes up by 1.
R—ResetBOOLInputNoRead (C1.R)Reset (European style): CV / ACC goes back to 0, before counting. In the American style, the RES instruction is used.
PVPREPresetDINTInputYesRead and write (C1.PV / C1.PRE)Preset: the value to reach. The program can change it with a MOVE / MOV.
QDNDoneBOOLOutputNoRead (C1.Q / C1.DN)When CV / ACC reaches the preset (CV / ACC ≥ PV / PRE), Q / DN turns 1.
CVACCAccumulator: current valueDINTOutputNoRead and write (C1.CV / C1.ACC)Accumulator: the current value (DINT, from −2,147,483,648 to 2,147,483,647). The program can change it with a MOVE / MOV.
—OVOverflowBOOLOutputNoRead (C1.OV)Overflow: 1 when counting goes past 2,147,483,647 (the value stops there). Cleared by the reset or the load.
—UNUnderflowBOOLOutputNoRead (C1.UN)Underflow: 1 when counting down goes below −2,147,483,648. Cleared by the reset or the load.
MnemonicNameData typeDirectionRequiredAccessMeaning
InstanceInstance (the counter’s memory)IEC_COUNTERInputYes—Instance (C1…): the counter's memory.
CUCount upBOOLInputYesRead (C1.CU)The bit to count: it says the instruction is active. Each time power reaches the instruction (0 to 1), CV goes up by 1.
RResetBOOLInputNoRead (C1.R)Reset (European style): CV goes back to 0, before counting. In the American style, the RES instruction is used.
PVPresetDINTInputYesRead and write (C1.PV)Preset: the value to reach. The program can change it with a MOVE.
QDoneBOOLOutputNoRead (C1.Q)When CV reaches the preset (CV ≥ PV), Q turns 1.
CVAccumulator: current valueDINTOutputNoRead and write (C1.CV)Accumulator: the current value (DINT, from −2,147,483,648 to 2,147,483,647). The program can change it with a MOVE.
MnemonicNameData typeDirectionRequiredAccessMeaning
InstanceInstance (the counter’s memory)COUNTERInputYes—Instance (C1…): the counter's memory.
CUCount upBOOLInputYesRead (C1.CU)The bit to count: it says the instruction is active. Each time power reaches the instruction (0 to 1), ACC goes up by 1.
PREPresetDINTInputYesRead and write (C1.PRE)Preset: the value to reach. The program can change it with a MOV.
DNDoneBOOLOutputNoRead (C1.DN)When ACC reaches the preset (ACC ≥ PRE), DN turns 1.
ACCAccumulator: current valueDINTOutputNoRead and write (C1.ACC)Accumulator: the current value (DINT, from −2,147,483,648 to 2,147,483,647). The program can change it with a MOV.
OVOverflowBOOLOutputNoRead (C1.OV)Overflow: 1 when counting goes past 2,147,483,647 (the value stops there). Cleared by the reset or the load.
UNUnderflowBOOLOutputNoRead (C1.UN)Underflow: 1 when counting down goes below −2,147,483,648. Cleared by the reset or the load.

Readable anywhere in the program, for example C1.Q / C1.DN. Writable members can be changed by the program (MOVE).Readable anywhere in the program, for example C1.Q. Writable members can be changed by the program (MOVE).Readable anywhere in the program, for example C1.DN. Writable members can be changed by the program (MOVE).

Timing diagram

European style
CURCV012340Q01234567891011121314scans
American style
CURESACC012340DN01234567891011121314scans

Timing diagram checked against the simulator (the same engine as the editor).

Example

European style
American style

S1 counts; after 5 pulses, H1 turns on. S2 resets the counter (R input in European, RES in American).

Try it in the simulatorThe example opens in the free simulator; your own program stays as it was.

Behaviour in detail

European (IEC) and American styles

European: CTU with an R input and a Q output.

American: CTU with PRE, ACC (DINT) and the DN, OV, UN bits, reset by a RES instruction (the R input remains available here).

See also