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 rising-edge input (CU) and a preset value (PV), and read its .Q output bit when the count reaches PV.

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.

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