Fareed Mohmed← Project library

Engineering · PLC · Project 10 of 15 · Conveyors and doors · Level 2

Part counter with batch stop

Count boxes with a photo-eye. After 5 boxes the belt stops and a lamp lights until RESET.

▶ Run it in the simulator

Virtual machine for Part counter with batch stop: buttons, lamps and the process it controls
Learning model only. This page teaches the program logic. A real machine needs a proper control panel with an isolator, fuses, motor protection and a hard-wired emergency stop. Mains and motor wiring is for qualified electricians. A PLC output never drives a motor directly.

You will learn

A counter (CTU) adds one every time its input turns from OFF to ON. It does not count while the input stays on, so one box counts once. When the count reaches the preset the done bit turns on.

How it works

  • Press START and keep pressing Put a box.
  • Each box passing the photo-eye adds 1 to the counter.
  • At 5 the belt stops and the lamp lights. Press RESET to start a new batch.

In real life

Packing lines, bottling plants and bag counters.

Inputs, outputs and addresses

The same signals on seven PLC brands. Inputs and outputs are numbered in order; check your own hardware and software, because addresses depend on the model and module position.

NameWhat it isTypeSiemens
S7-1200
Allen-Bradley
CompactLogix
Mitsubishi
iQ-F FX5U
Delta
DVP / AS
Omron
CP2E
Schneider
M241
Inovance
H5U
STARTSTART push-buttonInput%I0.0Local:1:I.Data.0X0X00.00%IX0.0X0
STOPSTOP push-button (N.C.)Input%I0.1Local:1:I.Data.1X1X10.01%IX0.1X1
RESETCounter RESET buttonInput%I0.2Local:1:I.Data.2X2X20.02%IX0.2X2
PEPhoto-eye (ON when a box blocks the beam)Input%I0.3Local:1:I.Data.3X3X30.03%IX0.3X3
CONVConveyor contactorOutput%Q0.0Local:2:O.Data.0Y0Y0100.00%QX0.0Y0
FULLBatch full lampOutput%Q0.1Local:2:O.Data.1Y1Y1100.01%QX0.1Y1

Ladder diagram (shown for Siemens, live state)

Green wires carry power in the moment captured below. Switch the brand and the language in the simulator.

Rung 1 Run until the batch is fullSTART%I0.0CONV%Q0.0STOP%I0.1Counter 1 done"C1".QCONV%Q0.0Rung 2 Count each box (rising edge)PE%I0.3"C1"CTUCUPV 5QCVCV = 2RRung 3 Reset counterRESET%I0.2R input of "C1"Rung 4 Batch full lampCounter 1 done"C1".QFULL%Q0.1

Structured text, Siemens SCL

(* Siemens S7-1200, CPU 1214C DC/DC/DC - TIA Portal - SCL *)
(* Rung 1: Run until the batch is full *)
"CONV" := ("START" OR "CONV") AND "STOP" AND NOT "C1".Q;
(* Rung 2: Count each box (rising edge) *)
"C1"(CU := "PE", R := "RESET", PV := 5);
(* Rung 3: Reset counter *)
(* Rung 4: Batch full lamp *)
"FULL" := "C1".Q;

Structured text, Allen-Bradley

(* Allen-Bradley CompactLogix 5069 (L306ER) - Studio 5000 Logix Designer - Structured Text *)
(* Rung 1: Run until the batch is full *)
CONV := (START OR CONV) AND STOP AND NOT Counter1.DN;
(* Rung 2: Count each box (rising edge) *)
Counter1.PRE := 5;
Counter1.CUEnable := PE;
Counter1.Reset := RESET;
CTUD(Counter1);
(* Rung 3: Reset counter *)
(* Rung 4: Batch full lamp *)
FULL := Counter1.DN;

Try this

Parts to buy

The links open a search on each store, so you see what is in stock today. Check the model, voltage and price before you order.

#ItemBuy / compare
1PLCAmazon.in · IndiaMART · Robu.in
2Photo-electric sensorAmazon.in · IndiaMART · Robu.in
3Conveyor motorAmazon.in · IndiaMART · Robu.in
4Reset buttonAmazon.in · IndiaMART · Robu.in
← 9. Flasher (blinking lamp)All projects11. Oven temperature on / off control →

This is a learning tool. It teaches the logic, not the exact keystrokes of each vendor’s software. Check the manual of your own PLC.