08Level 3
Conveyor belt with box counter
A sensor counts the passing boxes. When a batch of 6 boxes is complete, the belt stops and a light turns on until the operator starts a new batch.
Open in the simulator
The simulator is designed for computers (screens 1024 px or wider).
Virtual plant
Boxes delivered: 0
Shown at rest. In the simulator the plant moves according to your program's outputs.
Inputs and outputs
| Address | Name | Description |
|---|---|---|
| I0.0 | START | Start push button (NO) |
| I0.1 | STOP | Stop push button (NC: 1 at rest) |
| I0.2 | BOX_SENSOR | Photocell that detects the boxes (plant) |
| I0.3 | NEW_BATCH | Push button to start a new batch (NO) |
| Q0.0 | BELT | Belt motor |
| Q0.1 | BATCH_READY | Batch complete light |
| C0 | BOXES | Box counter of the batch |
Program
Ladder diagram (LD)
Rung 1 — Counts the boxes; NEW_BATCH resets the count. The output means batch complete.
Rung 2 — Belt with seal-in; it stops when the batch is complete.
Function block diagram (FBD)
Network 1 — Counts the boxes; NEW_BATCH resets the count. The output means batch complete.
Network 2 — Belt with seal-in; it stops when the batch is complete.
Structured text (ST)
(* Conveyor belt with box counter — converted from Ladder *)
VAR
BOXES : CTU;
END_VAR
(* Rung 1: Counts the boxes; NEW_BATCH resets the count. The output means batch complete. *)
BOXES(CU := BOX_SENSOR, R := NEW_BATCH, PV := 6);
BATCH_READY := BOXES.Q;
(* Rung 2: Belt with seal-in; it stops when the batch is complete. *)
BELT := (START OR BELT) AND STOP AND NOT BOXES;Instruction list (IL)
(* Conveyor belt with box counter — converted from Ladder *) VAR BOXES : CTU; END_VAR (* Rung 1: Counts the boxes; NEW_BATCH resets the count. The output means batch complete. *) CAL BOXES(CU := BOX_SENSOR, R := NEW_BATCH, PV := 6) LD BOXES.Q ST BATCH_READY (* Rung 2: Belt with seal-in; it stops when the batch is complete. *) LD START OR BELT AND STOP ANDN BOXES ST BELT
Step by step
- 1Press ▶ Run (F5) and press START: the belt moves and the BOXES counter adds one for each box that passes the sensor.
- 2Watch the counter's CV value in rung 1. The counter counts edges: a box adds only once, even if it takes a while to pass.
- 3At 6 boxes, the counter output turns on BATCH_READY and its NC contact in rung 2 stops the belt.
- 4Press NEW_BATCH to set the count to zero and then START to begin another batch.