Basic
8 min

Fix 04 — Counter won’t reset

fix-itfaultcounterCTUresetbatchfundamentals

Ready to build this?

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

Sign up to play this scenario →

Already have an account? Log in

Fix 04 — Counter won’t reset

Briefing

A packing station counts boxes with an eye. When three boxes have passed, BATCH_FULL lights so the operator can swap the crate. Pressing RESET_PB should clear the count for the next batch. The count and the lamp work, but RESET_PB does nothing, so the lamp stays on for ever. Find out why, and fix it.

Objectives

  • The lamp stays off for the first two boxes
  • The third box lights BATCH_FULL
  • RESET_PB clears the lamp
  • The next batch needs three fresh boxes, even after a reset in the middle of a batch

Hints

  • Fill a batch, press RESET_PB, and watch BATCH_FULL. Then look in the program for anything that reads RESET_PB.
  • A counter keeps its value until it is told to clear. Find where this counter is told, and what it is told today.
  • Clearing only the lamp is not enough: the count itself must go back to zero, or the next batch would be full after fewer boxes.
  • Test a reset in the middle of a batch as well as after a full one. After any reset, three more boxes must be needed.

I/O Table

Inputs

BOX_EYE

Box counting eye (TRUE while a box is in the beam)

BOOL · %I0.0

RESET_PB

Batch reset push-button (TRUE = pressed)

BOOL · %I0.1

Outputs

BATCH_FULL

Batch full lamp

BOOL · %Q0.0

Your program will be tested against:

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

  1. #1Two boxes → lamp off

    The batch is three boxes, so two boxes do not fill it

  2. #2Three boxes → lamp on

    The third box fills the batch

  3. #3RESET after a full batch → lamp off

    Pressing RESET clears the full lamp

  4. #4After a reset, three fresh boxes are needed

    The count restarts at zero: two boxes leave the lamp off, the third lights it

  5. #5RESET in the middle of a batch → count restarts

    A reset after two boxes throws that count away

  6. #6A fourth box → lamp stays on

    A full batch stays full until RESET

Ready to build this?

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

Sign up to play this scenario →

Already have an account? Log in