Beginner 10 — Count to five (CTU)
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
Not ready to sign up? Run a live lab now — no signup →
Briefing
A photo-eye watches boxes drop into a carton. Pulse BOX_EYE once per box. After five boxes the carton is full and the CARTON_FULL lamp turns on. Tap CNT_RESET to clear the count so the next carton starts from zero. That is the whole job: no motor and no START button yet. A CTU ("Count Up") is a counter block, added from More instructions just like the TON timer. BOX_EYE feeds its count input (CU), CNT_RESET feeds its reset input (R), its preset (PV) is 5, and its Q (done) output turns on when the count reaches 5. The CTU counts each false-to-true change at CU by itself, so BOX_EYE connects straight in.
Objectives
- Fewer than five BOX_EYE pulses → CARTON_FULL stays off
- The fifth BOX_EYE pulse → CARTON_FULL turns on
- Tap CNT_RESET → count clears, CARTON_FULL off, the next five boxes fill a new carton
Hints
- Add the counter: More instructions → Count up (CTU), named BOX_CNT, on a rung that starts with a BOX_EYE contact so each box counts once.
- Connect CNT_RESET to the counter's reset input (R) and set its preset (PV) to 5.
- The counter's done output, BOX_CNT.Q, turns on at the fifth box. Put a BOX_CNT.Q contact in front of a CARTON_FULL coil.
- Any wiring that behaves the same is accepted: CARTON_FULL can be a normal output coil on BOX_CNT.Q, or you can Set it from BOX_CNT.Q and Reset it with CNT_RESET, as long as the lamp clears and a new carton counts from zero.
I/O Table
Inputs
CNT_RESETCounter reset push-button (NO)
BOOL · %I0.1
BOX_EYEPhoto-eye — pulses once per box
BOOL · %I0.2
Outputs
CARTON_FULLCarton-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.
- #1Five BOX_EYE pulses → CARTON_FULL on
Five rising edges on BOX_EYE bring the CTU to its preset, so Q lights the lamp
- #2Four BOX_EYE pulses → CARTON_FULL still off
One short of the preset: the counter is not done, so the lamp stays off
- #3CNT_RESET after a full carton → lamp off, next carton counts from zero
Reset clears the counter: four more boxes keep the lamp off and the fifth lights it again
Related scenarios
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
Not ready to sign up? Run a live lab now — no signup →