ceo@instrumentationblog.in
PLC · How It Works

How a PLC Up Counter Works

Set the preset value PV and how many parts per minute pass the sensor. Watch each pulse add one to the current value CV, see the output Q turn on at the preset and the reset input clear the count for the next batch.

Live animationAdjustable slidersFormula and example

Quick answer: An up counter (CTU) adds one to its current value CV every time its count input CU changes from off to on. When CV reaches the preset value PV the output Q turns on, and a separate reset input R sets CV back to zero.

What Is a PLC Up Counter (CTU)?

The up counter is the standard way to count parts, bottles, strokes or cycles in a PLC program. It is defined in the IEC 61131 standard as the CTU function block, with a down counter CTD and an up down counter CTUD alongside it.

A CTU has a count input CU, a reset input R, a preset value PV, an output Q and a current value CV. It counts edges, not time, so a sensor that stays on gives only one count.

Typical uses are batch counts on packaging lines, stroke counts for maintenance and counting machine cycles. Knowing how the counter handles reset, overflow and fast pulses avoids most counting faults on site.

Advertisement

How a PLC Up Counter Works: Interactive Animation

Numbered markers match the parts list below.
Time to collect PV parts = PV × 60 ÷ rate…
Current value CV now…
Output Q…
Batches completed in the demo…
  1. 1Part sensor wired to input I0.1 (CU)
  2. 2CTU counter block
  3. 3Preset value PV
  4. 4Current value CV
  5. 5Output Q driving coil Q0.0
  6. 6Reset input R from I0.2
  7. 7Timing diagram of CU, CV and Q

PLC Up Counter (CTU) Working Principle Step by Step

  1. The part sensor turns input I0.1 on each time a part passes, and this input drives the count input CU of the counter.
  2. On every off to on change of CU the counter adds one to its current value CV; holding CU on does not add more counts.
  3. When CV becomes equal to or greater than PV, the output Q turns on, for example to stop the conveyor or index a new box.
  4. CV keeps counting above PV if more parts arrive, until the counter is reset.
  5. A pulse on the reset input R sets CV back to zero and turns Q off, ready for the next batch.

PLC Up Counter (CTU) Labelled Diagram

Labelled diagram showing how a plc up counter works
Numbered parts: 1 part sensor wired to input i0.1 (cu); 2 ctu counter block; 3 preset value pv; 4 current value cv; 5 output q driving coil q0.0; 6 reset input r from i0.2; 7 timing diagram of cu, cv and q.
Advertisement

PLC Up Counter (CTU) Formula

Q = (CV ≥ PV)
CV = CV + 1 on each off to on change of CU; R sets CV to 0
Time to collect PV parts = PV × 60 ÷ parts per minute
CV keeps counting above PV until reset, up to the limit of its data type, for example 32767 for a 16 bit INT
Example: PV 5 and 30 parts per minute: time = 5 × 60 ÷ 30 = 10 s, so a batch of 5 parts takes about 10 s and Q turns on at the fifth part

Main Parts of a PLC Up Counter (CTU)

PartWhat it does
CU count inputRung condition whose rising edge adds one to the count; usually a sensor contact
R reset inputSets the current value to zero and turns the output off while it is on
PV preset valueThe target count, entered as a constant or moved in from an HMI or recipe
CV current valueThe running count, which can be shown on an HMI or compared in other rungs
Q outputCounter done bit that turns on when CV reaches PV

Where a PLC Up Counter (CTU) Is Used

Batch packingCounts bottles or cartons into a case and signals when the case is full.
Maintenance countersCounts machine strokes or valve cycles so service is planned by use, not by date.
Production totalsKeeps shift totals of good and rejected parts for display on the HMI.
Sequence stepsCounts repeats of a step, such as the number of rinse cycles in a cleaning sequence.

Advantages

  • Simple and the same behaviour on almost every PLC
  • Counts edges, so a part that stops under the sensor counts only once
  • CV is easy to show on an HMI and to compare in other logic

Limitations

  • Pulses shorter than the scan time plus input filter can be missed
  • A bouncing contact can add extra counts
  • Counts can be lost on power failure unless the counter is retentive

PLC Up Counter (CTU) Field Tips and Common Problems

  • Make sure each pulse stays on and off for longer than one scan plus the input filter time; for fast pulses use a high speed counter input.
  • Use a reset that is a single pulse, otherwise a held reset blocks all new counts.
  • Check whether the counter is retentive if the count must survive a power cycle or a PLC restart.
  • Debounce mechanical limit switches with a short on delay timer, or use a non contact sensor, to avoid double counts.
Advertisement

Related Calculators and Tools

Frequently Asked Questions

What is the difference between CTU and CTD?

A CTU counts up from zero towards the preset and sets Q when CV reaches PV. A CTD counts down from the preset and sets Q when CV reaches zero.

Does a PLC counter stop counting at the preset?

No, in most PLCs CV keeps counting above PV until it is reset or reaches the limit of its data type. Q simply stays on while CV is at or above PV.

Why does my PLC counter miss counts?

Usually the pulse is shorter than the scan time plus the input filter, so the PLC never sees it. Use a high speed counter input or slow the pulses down.

What happens when CU and R are on at the same time?

The reset has priority in the IEC 61131 CTU, so CV stays at zero. Counting starts again once R turns off.

You May Also Like

Learn more on the blog

PLC counter instructions CTU and CTD

A practical guide on instrumentationblog.in that goes deeper into this topic with field examples.

Read Full Article

More How It Works

All How It Works animations · Instrumentation glossary · Comparisons

Advertisement