Counters (output instruction)

CTU: Count Up

Adds one to its accumulator on every false-to-true transition of the rung, and sets its done bit at the preset.

Also called: up counter, batch counter, production counter.

CTU(counter, preset)

Arguments

NameWhat it isAcceptsDefault
destinationWhat the instruction acts ona counterrequired
presetPreseta whole number4

Arguments are positional and this table is generated from the simulator's own instruction registry, so it always matches what the engine accepts.

What it does

A counter counts edges, not scans. It increments once each time its rung goes from false to true, which is the behaviour you want and also the behaviour that catches people out, because it means the counter is only as good as the edge feeding it.

A photo eye blocked by a passing part produces one clean edge, and CTU handles it correctly on its own. A pushbutton, a bouncing limit switch, or a sensor that flickers as a part settles does not, and there you need a ONS or a debounce timer in front of it.

The accumulator keeps counting past the preset. The done bit turns on at the preset and stays on; the count carries on rising until something resets it. That is useful when you want to know how far past target you went, and surprising if you assumed it stopped.

A rung you can run

Batch of 500 with an automatic reset

[object Object]
XIC(Part_Sensor)ONS(Part_Edge)CTU(Batch_Count,500)
XIC(Batch_Count.DN)OTE(Batch_Complete)
XIC(Batch_Complete)XIC(HMI_Next_Batch)RES(Batch_Count)

The ONS guarantees one count per part. The RES is on its own rung so the batch only clears when an operator starts the next one.

Run this rung in the simulator

What it is called on other controllers

PlatformEquivalent
Rockwell (Studio 5000)CTU
Siemens (TIA Portal)CTU
Mitsubishi (GX Works)OUT C with a K preset
CODESYS and IEC 61131-3CTU

Common mistakes

  • Counting a level instead of an edge. If the rung is true for many scans the counter still adds one, but only if it went false in between; a rung that never goes false never counts again.
  • Forgetting the RES, so the second batch starts wherever the first one finished.
  • Assuming the counter stops at the preset. It does not.

Practise it

Interactive exercises that use CTU. Each one checks your ladder against a real scan.

Related instructions

All ladder logic instructions