Pro
12 min

Lesson 10 — Counter (CTU)

curriculumlessoncounterCTU

Ready to build this?

Sign up free — no credit card required. This scenario requires the Pro plan.

Sign up to play this scenario →

Already have an account? Log in

Lesson 10 — Counter (CTU) scenario preview

Briefing

CTU (Count Up) increments on each rising edge of CU. When the count reaches the preset value PV, the Q output goes true. A CNT_RESET input clears the count back to zero. Used everywhere for batch counting — parts on a conveyor, boxes on a pallet.

Objectives

  • BIN_FULL goes true after 10 PART_SENSOR pulses
  • CNT_RESET clears the count and turns off BIN_FULL

Hints

  • Declare: CNT : CTU; Call it: CNT(CU := PART_SENSOR, R := CNT_RESET, PV := 10);
  • CNT.Q goes true when CNT.CV >= 10.

I/O Table

Inputs

PART_SENSOR

Part-detection photo-eye

BOOL · %I0.0

CNT_RESET

Counter reset input

BOOL · %I0.1

Outputs

BIN_FULL

Bin full indicator

BOOL · %Q0.0

Your program will be tested against:

All test cases run automatically when you submit. Assertions are hidden until you pass.

  1. #110 pulses → BIN_FULL on

    10 rising edges on PART_SENSOR → BIN_FULL true

  2. #2CNT_RESET clears count and BIN_FULL

    After BIN_FULL, pressing CNT_RESET clears everything

Ready to build this?

Sign up free — no credit card required. This scenario requires the Pro plan.

Sign up to play this scenario →

Already have an account? Log in

Runnable simulator field guide

CTU counter curriculum scenario: test checklist

Direct answer

The learner can distinguish a level from a rising event, predict accumulator and done state, test reset priority and explain scan and restart assumptions.

Written for pLC beginners learning how a CTU instruction turns discrete events into a retained count and done condition.

a PLC scan-cycle bench used to correlate physical inputs, program state, timer or counter execution, output indication and repeated timing evidence while studying count-up edge behavior, accumulator, preset and reset evidence
System map / 02

NODE 01observable

Scenario setup

Counted event, input pulse shape, instruction instance, rising-edge rule, accumulator, preset, done state, reset condition, initial value, data limit and retention assumption.

NODE 02observable

I/O and state map

Physical or simulated event through input sampling and edge detection to CTU instance state, done condition, downstream action and displayed count.

NODE 03observable

Normal run

Each deliberate false-to-true event adds exactly one count and the done state changes at the declared preset.

NODE 04observable

Boundary run

Held input, contact bounce, rapid pulses, simultaneous count and reset, zero preset, maximum accumulator, overflow, restart and retained state.

NODE 05observable

Injected fault

An event, input, scan, edge, instance, accumulator, preset, reset, data-limit or restart mismatch.

NODE 06observable

Target check

The same cases recreated using the exact target instruction and controller documentation.

Answer surface / 07

What makes a CTU counter increment?

A count-up instruction normally responds to a defined false-to-true event at its count input, but exact platform behavior must be verified.

Why does a PLC counter miss or add events?

Pulse width, scan or task timing, contact bounce, input filtering, edge handling and duplicate instruction execution can change the observed count.