Free
7 min

Beginner 10 — Count five boxes (CTU)

beginnerfundamentalscountersctuconveyor
Beginner 10 — Count five boxes (CTU) scenario preview

Ready to build this?

Sign up free — no credit card required. This scenario is included in the free tier.

Sign up to play this scenario →

Already have an account? Log in

Briefing

A conveyor fills a carton with boxes. Tap START — the MOTOR runs. Each time a box trips the BOX_EYE photo-eye, the counter adds one. After five boxes the carton is full: MOTOR stops and the CARTON_FULL lamp turns on. Tap CNT_RESET to clear the count and lamp so the next carton can begin. A CTU ("Count Up") is a function block just like the TON timer. You declare an instance in VAR, call it with a CU input and preset value (PV), and read its .Q output bit when the count reaches PV. IEC CTU counts the false-to-true transition at CU internally, so BOX_EYE may connect directly here; R_TRIG is also available in the function-block menu when another circuit needs an explicit one-scan pulse.

Objectives

  • Tap START → MOTOR runs, CARTON_FULL off
  • Five BOX_EYE pulses → MOTOR stops and CARTON_FULL turns on
  • Tap CNT_RESET → count clears, CARTON_FULL off, conveyor can restart

Hints

  • Declare a counter instance in VAR: BOX_CNT : CTU;
  • Call it once each scan: BOX_CNT(CU := BOX_EYE, R := CNT_RESET, PV := 5);
  • Use BOX_CNT.Q (counter done) to stop MOTOR and drive CARTON_FULL.
  • Equivalent logic is accepted: an NC /BOX_CNT.Q contact in a normal MOTOR seal-in rung is as valid as resetting a SET coil when BOX_CNT.Q turns on.

I/O Table

Inputs

START

Momentary start push-button (NO)

BOOL · %I0.0

CNT_RESET

Counter reset push-button (NO)

BOOL · %I0.1

BOX_EYE

Photo-eye — pulses once per box

BOOL · %I0.2

Outputs

MOTOR

Conveyor motor contactor

BOOL · %Q0.0

CARTON_FULL

Carton-full indicator lamp

BOOL · %Q0.1

Your program will be tested against:

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

  1. #1Tap START → MOTOR on, CARTON_FULL off

    A momentary START latches MOTOR on before any boxes are counted

  2. #2Five BOX_EYE pulses → CARTON_FULL on, MOTOR off

    Five rising edges on BOX_EYE triggers CTU.Q which stops motor and lights lamp

  3. #3Three BOX_EYE pulses → MOTOR still on, CARTON_FULL off

    Fewer than five pulses: counter has not reached PV so conveyor keeps running

  4. #4CNT_RESET after full carton → lamp off, conveyor can restart

    After CARTON_FULL, CNT_RESET clears the counter so START latches the motor again

Ready to build this?

Sign up free — no credit card required. This scenario is included in the free tier.

Sign up to play this scenario →

Already have an account? Log in

Runnable simulator field guide

Beginner PLC counter scenario: implementation, evidence and troubleshooting

Direct answer

Beginner PLC counter scenario becomes useful when it connects counted object, sensor active state, pulse duration, scan assumption, edge event, counter instance, accumulator, preset, done use, reset, initial state and data limit with part movement through sensor and sampled input to edge detection, accumulator change, done state, downstream action and displayed batch count, then proves each representative part adds exactly one count and the declared preset produces one intended completion result under normal, boundary, fault and recovery conditions. The objective is a repeatable engineering or learning result, not merely activity inside a page or tool.

This guide is written for pLC beginners counting simulated parts and learning the difference between sensor state, edge event, accumulator and batch completion. The intended result is specific: the learner can predict every count, prevent repeated counts from a held sensor and test completion and reset from known initial values.

a PLC scan-cycle bench used to correlate physical inputs, program state, timer or counter execution, output indication and repeated timing evidence while studying part-count events, preset, done state and reset behavior
The field scene connects part-count events, preset, done state and reset behavior to declared initial conditions, observable boundaries, safe limits and repeatable acceptance evidence.

System map / 02

Six concepts that control the result

Treat these as connected checkpoints. Each checkpoint has an expected state, an observable state and a boundary to the next part of the system. That structure prevents a software indication from being mistaken for physical proof.

NODE 01observable

Define the operating contract

counted object, sensor active state, pulse duration, scan assumption, edge event, counter instance, accumulator, preset, done use, reset, initial state and data limit. For part-count events, preset, done state and reset behavior, record the initial condition, actor, requested change, observable result and stopping condition before selecting a tool or implementation.

NODE 02observable

Map the evidence path

part movement through sensor and sampled input to edge detection, accumulator change, done state, downstream action and displayed batch count. Separate request, internal state, output or service, physical or user-visible result and independent feedback so each boundary can be inspected.

NODE 03observable

Prove normal operation

each representative part adds exactly one count and the declared preset produces one intended completion result. Run more than one cycle from a known state and retain the values, timings or artifacts that demonstrate repeatability.

NODE 04observable

Exercise a boundary case

held sensor, bounce, two close parts, missed short pulse, simultaneous count and reset, zero preset, maximum count, reset and power return. Choose minimum, maximum, simultaneous, delayed or restart conditions that reveal assumptions hidden by the happy path.

NODE 05observable

Diagnose a controlled fault

a material, sensor, input, pulse, scan, edge, instance, accumulator, preset, reset or output mismatch. Preserve the first symptom, divide the system at a measurable boundary and change one condition only after predicting the result.

NODE 06observable

Transfer and hand over

the behavior recreated using target input hardware and exact counter instruction semantics. Restore normal state, remove temporary changes, repeat affected checks and document which claims remain limited to the learning environment.

Procedure / 03

A six-step practice and commissioning workflow

Run the steps in order the first time. Later, the same structure becomes a diagnostic loop: define the expected condition, observe the boundary, interpret the difference and choose one proving action.

  1. 01

    Write the acceptance case

    Convert counted object, sensor active state, pulse duration, scan assumption, edge event, counter instance, accumulator, preset, done use, reset, initial state and data limit into initial conditions, one stimulus and observable pass criteria.

    Evidence: Another person can repeat the case without guessing the intended result.

    Avoid: Using page completion or an animation as the acceptance criterion.

  2. 02

    Build the map

    Document part movement through sensor and sampled input to edge detection, accumulator change, done state, downstream action and displayed batch count and name who owns each state or decision.

    Evidence: Every request and result has a source, destination and useful inspection point.

    Avoid: Using the same value as command, status and independent feedback.

  3. 03

    Run the baseline

    Apply each representative part adds exactly one count and the declared preset produces one intended completion result from a clean start and record the expected evidence.

    Evidence: Repeated runs produce the same bounded result.

    Avoid: Changing several parameters before a baseline exists.

  4. 04

    Challenge assumptions

    Test held sensor, bounce, two close parts, missed short pulse, simultaneous count and reset, zero preset, maximum count, reset and power return without changing the acceptance contract.

    Evidence: Limits, timing and restart behavior reach defined states.

    Avoid: Testing only one ideal sequence.

  5. 05

    Isolate one failure

    Introduce or analyse a material, sensor, input, pulse, scan, edge, instance, accumulator, preset, reset or output mismatch and locate the first disagreement.

    Evidence: The proving action distinguishes the leading hypotheses.

    Avoid: Resetting, forcing or replacing before evidence is retained.

  6. 06

    Close the evidence loop

    Complete the behavior recreated using target input hardware and exact counter instruction semantics and repeat the affected regression cases.

    Evidence: A run is complete only when the requested behavior, stop behavior, fault response and recovery are observable from a fresh initial condition.

    Avoid: Treating an acknowledged message or one successful rerun as handover.

Diagnostic matrix / 04

Symptoms, proving points and next actions

The table is a reasoning aid, not a parts-replacement chart. Preserve the initial symptom, inspect the named boundary and use the interpretation to choose the next controlled test. Site safety procedures and equipment manuals remain authoritative.

Diagnostic symptoms, inspection points, interpretations and next actions for Beginner PLC counter scenario: implementation, evidence and troubleshooting
Observed symptomInspectInterpretationNext proving action
The expected result is unclearRequirement, initial state, actor, stimulus, units and pass conditionThe operator, programmer and reviewer may be solving different versions of the task.Rewrite one observable acceptance case before continuing.
Internal state changes but the outcome does notRequest, final owner, output or service boundary and independent feedbackA software or interface indication proves intent at one layer, not the complete outcome.Trace the first boundary after the changing state.
Normal case passes but an edge case failsLimits, timing, simultaneous events, reset and restart assumptionsThe implementation contains a hidden assumption exposed by the changed condition.Add the failed boundary as a permanent regression case.
The failure disappears after resetOriginal symptom, histories, diagnostics, timestamps and active causeReset changed evidence or state without proving the initiating cause.Reproduce under a controlled condition and preserve pre/post-event data.
Simulator and target disagreeModel boundary, software version, task timing, I/O behavior, data types and configurationA learning model and the intended target do not share one of the recorded assumptions.Reduce the case and verify against current target documentation.
The result cannot be explainedPrediction, observation, proving action, alternative hypotheses and limitationsActivity occurred but the evidence is not yet transferable or reviewable.Have the learner defend the signal path and repeat a changed case.

Product evidence / 05

What the browser practice can actually demonstrate

The browser runtime joins editable control state to visible I/O and machine or process behavior, allowing the same initial conditions and stimuli to be replayed.

Where simulation stops

The scenario teaches a generic counter model and cannot guarantee target instruction, high-speed input, overflow, retention or restart behavior.

Commissioning notebook / 06

Six cases that turn the concepts into evidence

Use these as written briefs rather than click-through instructions. For every case, state the expected condition before acting, retain the first useful observation and explain why the final result proves the requirement. A different program or component choice can still be correct when it produces the same bounded behavior and evidence.

Case 01

predict → observe → prove

Prove define the operating contract

Engineering context. counted object, sensor active state, pulse duration, scan assumption, edge event, counter instance, accumulator, preset, done use, reset, initial state and data limit. For part-count events, preset, done state and reset behavior, record the initial condition, actor, requested change, observable result and stopping condition before selecting a tool or implementation. Begin with a written normal condition and identify which request, state, physical result or communication value will provide independent confirmation. Do not begin by changing the configuration; the initial state is part of the evidence and should remain reproducible.

Controlled setup. Use the “Write the acceptance case” stage of the workflow: convert counted object, sensor active state, pulse duration, scan assumption, edge event, counter instance, accumulator, preset, done use, reset, initial state and data limit into initial conditions, one stimulus and observable pass criteria. The acceptance record should show this result: another person can repeat the case without guessing the intended result. Record initial conditions, the exact stimulus and the observation point so another learner can repeat the case without relying on your memory.

Fault challenge. Introduce or analyse “The expected result is unclear” as one bounded deviation. Inspect requirement, initial state, actor, stimulus, units and pass condition The working interpretation is that the operator, programmer and reviewer may be solving different versions of the task. The next proving action is to rewrite one observable acceptance case before continuing. Change only one condition before observing the result, and preserve timestamps or measurements where timing matters.

Review and recovery. The most common trap here is using page completion or an animation as the acceptance criterion. After restoring the cause, repeat the normal case and at least one stop, timeout, disconnect or restart boundary relevant to this topic. Remove temporary forces and bypasses, return the model to a known state and retain the evidence that both operation and recovery are deliberate.

Explain it aloud: How do you count products with a PLC? A defensible short answer is: Detect one reliable event per product, feed it into a dedicated counter instance and verify accumulator, preset, reset and downstream use.

Case 02

predict → observe → prove

Prove map the evidence path

Engineering context. part movement through sensor and sampled input to edge detection, accumulator change, done state, downstream action and displayed batch count. Separate request, internal state, output or service, physical or user-visible result and independent feedback so each boundary can be inspected. Begin with a written normal condition and identify which request, state, physical result or communication value will provide independent confirmation. Do not begin by changing the configuration; the initial state is part of the evidence and should remain reproducible.

Controlled setup. Use the “Build the map” stage of the workflow: document part movement through sensor and sampled input to edge detection, accumulator change, done state, downstream action and displayed batch count and name who owns each state or decision. The acceptance record should show this result: every request and result has a source, destination and useful inspection point. Record initial conditions, the exact stimulus and the observation point so another learner can repeat the case without relying on your memory.

Fault challenge. Introduce or analyse “Internal state changes but the outcome does not” as one bounded deviation. Inspect request, final owner, output or service boundary and independent feedback The working interpretation is that a software or interface indication proves intent at one layer, not the complete outcome. The next proving action is to trace the first boundary after the changing state. Change only one condition before observing the result, and preserve timestamps or measurements where timing matters.

Review and recovery. The most common trap here is using the same value as command, status and independent feedback. After restoring the cause, repeat the normal case and at least one stop, timeout, disconnect or restart boundary relevant to this topic. Remove temporary forces and bypasses, return the model to a known state and retain the evidence that both operation and recovery are deliberate.

Explain it aloud: Why does a counter add more than one count for one product? A defensible short answer is: The sensor may chatter or remain true while the program applies level logic repeatedly; use documented edge behavior and test the physical pulse.

Case 03

predict → observe → prove

Prove prove normal operation

Engineering context. each representative part adds exactly one count and the declared preset produces one intended completion result. Run more than one cycle from a known state and retain the values, timings or artifacts that demonstrate repeatability. Begin with a written normal condition and identify which request, state, physical result or communication value will provide independent confirmation. Do not begin by changing the configuration; the initial state is part of the evidence and should remain reproducible.

Controlled setup. Use the “Run the baseline” stage of the workflow: apply each representative part adds exactly one count and the declared preset produces one intended completion result from a clean start and record the expected evidence. The acceptance record should show this result: repeated runs produce the same bounded result. Record initial conditions, the exact stimulus and the observation point so another learner can repeat the case without relying on your memory.

Fault challenge. Introduce or analyse “Normal case passes but an edge case fails” as one bounded deviation. Inspect limits, timing, simultaneous events, reset and restart assumptions The working interpretation is that the implementation contains a hidden assumption exposed by the changed condition. The next proving action is to add the failed boundary as a permanent regression case. Change only one condition before observing the result, and preserve timestamps or measurements where timing matters.

Review and recovery. The most common trap here is changing several parameters before a baseline exists. After restoring the cause, repeat the normal case and at least one stop, timeout, disconnect or restart boundary relevant to this topic. Remove temporary forces and bypasses, return the model to a known state and retain the evidence that both operation and recovery are deliberate.

Explain it aloud: What should I learn first about part-count events, preset, done state and reset behavior? A defensible short answer is: Start with the operating contract and evidence path: counted object, sensor active state, pulse duration, scan assumption, edge event, counter instance, accumulator, preset, done use, reset, initial state and data limit, followed by part movement through sensor and sampled input to edge detection, accumulator change, done state, downstream action and displayed batch count. Add advanced features only after the baseline is predictable.

Case 04

predict → observe → prove

Prove exercise a boundary case

Engineering context. held sensor, bounce, two close parts, missed short pulse, simultaneous count and reset, zero preset, maximum count, reset and power return. Choose minimum, maximum, simultaneous, delayed or restart conditions that reveal assumptions hidden by the happy path. Begin with a written normal condition and identify which request, state, physical result or communication value will provide independent confirmation. Do not begin by changing the configuration; the initial state is part of the evidence and should remain reproducible.

Controlled setup. Use the “Challenge assumptions” stage of the workflow: test held sensor, bounce, two close parts, missed short pulse, simultaneous count and reset, zero preset, maximum count, reset and power return without changing the acceptance contract. The acceptance record should show this result: limits, timing and restart behavior reach defined states. Record initial conditions, the exact stimulus and the observation point so another learner can repeat the case without relying on your memory.

Fault challenge. Introduce or analyse “The failure disappears after reset” as one bounded deviation. Inspect original symptom, histories, diagnostics, timestamps and active cause The working interpretation is that reset changed evidence or state without proving the initiating cause. The next proving action is to reproduce under a controlled condition and preserve pre/post-event data. Change only one condition before observing the result, and preserve timestamps or measurements where timing matters.

Review and recovery. The most common trap here is testing only one ideal sequence. After restoring the cause, repeat the normal case and at least one stop, timeout, disconnect or restart boundary relevant to this topic. Remove temporary forces and bypasses, return the model to a known state and retain the evidence that both operation and recovery are deliberate.

Explain it aloud: How do I practise part-count events, preset, done state and reset behavior effectively? A defensible short answer is: Use short cases with known initial conditions, a written prediction, one action and an observable result. Then alter a boundary or fault and explain why the evidence changed.

Case 05

predict → observe → prove

Prove diagnose a controlled fault

Engineering context. a material, sensor, input, pulse, scan, edge, instance, accumulator, preset, reset or output mismatch. Preserve the first symptom, divide the system at a measurable boundary and change one condition only after predicting the result. Begin with a written normal condition and identify which request, state, physical result or communication value will provide independent confirmation. Do not begin by changing the configuration; the initial state is part of the evidence and should remain reproducible.

Controlled setup. Use the “Isolate one failure” stage of the workflow: introduce or analyse a material, sensor, input, pulse, scan, edge, instance, accumulator, preset, reset or output mismatch and locate the first disagreement. The acceptance record should show this result: the proving action distinguishes the leading hypotheses. Record initial conditions, the exact stimulus and the observation point so another learner can repeat the case without relying on your memory.

Fault challenge. Introduce or analyse “Simulator and target disagree” as one bounded deviation. Inspect model boundary, software version, task timing, I/O behavior, data types and configuration The working interpretation is that a learning model and the intended target do not share one of the recorded assumptions. The next proving action is to reduce the case and verify against current target documentation. Change only one condition before observing the result, and preserve timestamps or measurements where timing matters.

Review and recovery. The most common trap here is resetting, forcing or replacing before evidence is retained. After restoring the cause, repeat the normal case and at least one stop, timeout, disconnect or restart boundary relevant to this topic. Remove temporary forces and bypasses, return the model to a known state and retain the evidence that both operation and recovery are deliberate.

Explain it aloud: What counts as proof of competence? A defensible short answer is: A repeatable artifact or system result plus an explanation of the signal path is stronger than time spent, screenshots or a copied answer. Physical competence requires separate supervised evidence.

Case 06

predict → observe → prove

Prove transfer and hand over

Engineering context. the behavior recreated using target input hardware and exact counter instruction semantics. Restore normal state, remove temporary changes, repeat affected checks and document which claims remain limited to the learning environment. Begin with a written normal condition and identify which request, state, physical result or communication value will provide independent confirmation. Do not begin by changing the configuration; the initial state is part of the evidence and should remain reproducible.

Controlled setup. Use the “Close the evidence loop” stage of the workflow: complete the behavior recreated using target input hardware and exact counter instruction semantics and repeat the affected regression cases. The acceptance record should show this result: a run is complete only when the requested behavior, stop behavior, fault response and recovery are observable from a fresh initial condition. Record initial conditions, the exact stimulus and the observation point so another learner can repeat the case without relying on your memory.

Fault challenge. Introduce or analyse “The result cannot be explained” as one bounded deviation. Inspect prediction, observation, proving action, alternative hypotheses and limitations The working interpretation is that activity occurred but the evidence is not yet transferable or reviewable. The next proving action is to have the learner defend the signal path and repeat a changed case. Change only one condition before observing the result, and preserve timestamps or measurements where timing matters.

Review and recovery. The most common trap here is treating an acknowledged message or one successful rerun as handover. After restoring the cause, repeat the normal case and at least one stop, timeout, disconnect or restart boundary relevant to this topic. Remove temporary forces and bypasses, return the model to a known state and retain the evidence that both operation and recovery are deliberate.

Explain it aloud: Why test faults and restart behavior? A defensible short answer is: Because a material, sensor, input, pulse, scan, edge, instance, accumulator, preset, reset or output mismatch or held sensor, bounce, two close parts, missed short pulse, simultaneous count and reset, zero preset, maximum count, reset and power return can expose assumptions that never appear during ideal startup and steady operation.

Answer surface / 07

Questions people ask about Beginner PLC counter scenario

These concise answers define the operating, training and product boundaries most often missed in broad summaries. The full workflow and diagnostic table above provide the evidence behind them.

How do you count products with a PLC?

Detect one reliable event per product, feed it into a dedicated counter instance and verify accumulator, preset, reset and downstream use.

Why does a counter add more than one count for one product?

The sensor may chatter or remain true while the program applies level logic repeatedly; use documented edge behavior and test the physical pulse.

What should I learn first about part-count events, preset, done state and reset behavior?

Start with the operating contract and evidence path: counted object, sensor active state, pulse duration, scan assumption, edge event, counter instance, accumulator, preset, done use, reset, initial state and data limit, followed by part movement through sensor and sampled input to edge detection, accumulator change, done state, downstream action and displayed batch count. Add advanced features only after the baseline is predictable.

How do I practise part-count events, preset, done state and reset behavior effectively?

Use short cases with known initial conditions, a written prediction, one action and an observable result. Then alter a boundary or fault and explain why the evidence changed.

What counts as proof of competence?

A repeatable artifact or system result plus an explanation of the signal path is stronger than time spent, screenshots or a copied answer. Physical competence requires separate supervised evidence.

Why test faults and restart behavior?

Because a material, sensor, input, pulse, scan, edge, instance, accumulator, preset, reset or output mismatch or held sensor, bounce, two close parts, missed short pulse, simultaneous count and reset, zero preset, maximum count, reset and power return can expose assumptions that never appear during ideal startup and steady operation.

Can browser practice replace official software or hardware?

No. It can build concepts and diagnostic reasoning. Exact firmware, I/O electrical behavior, networking, safety and commissioning require current official tools, documentation and target equipment.

How should progress be documented?

Keep the requirement, initial state, program or configuration, observed values, fault hypothesis, proving action, recovery result and a concise limitations statement.