- Home
- PLC Solution Library
- Simulators
- Conveyor sorting
PLC Solution Library · Conveyor sorting simulator
Sort a picking wave on a conveyor: read each code and send the item to its order
Pickers bring the items of several orders mixed on one belt. The sorter must put each item in the lane of its order and tell the packer when an order is complete. In this simulator, one M-Duino 42+ reads a barcode scanner, follows each item with an encoder, fires four diverters and checks that every item really entered its lane.
Run a scenario or start the belt yourself. Inject a fault: a label that does not read, a code that is not in the wave, a jammed lane or a diverter that does not move.
Choose your scenario
Re-induct stands for an operator who fixes the label and puts the item back on the belt. Items with a code that is not in the wave stay in exceptions.
Your design choices
These are choices you make in your own sorter program. They are explained below.
Example wave
| Order | Lane | Lines (code × quantity) |
|---|---|---|
| 1 | 1 | A-101 × 2 · B-205 × 1 |
| 2 | 2 | C-310 × 1 · A-101 × 1 · D-412 × 2 |
| 3 | 3 | B-205 × 2 · E-518 × 1 |
| 4 | 4 | D-412 × 1 · C-310 × 2 · E-518 × 1 |
Example values for this simulator. The pickers pick by code for the whole wave, so the items arrive grouped by code, not by order. Belt 0.5 m/s, encoder 1 pulse per mm, items 250 to 350 mm long, diverter fired 60 mm before the item, lane sensor checked within 1.2 s. Your codes, lanes and distances come from your warehouse system and your layout.
Sorter record
| n | time | code read | encoder at scan | order | lane | result | reason |
|---|
One row per item that left the belt. Your PLC sends the row to the warehouse system over Ethernet, so the system knows which items reached each order and which ones wait in exceptions.
How does the PLC send each item to its order?
The warehouse system sends the wave to the PLC before it starts: which codes each order needs and which lane holds each order. Then the PLC runs the same six steps on every item.
- Infeed. A short belt at the start releases the items with a gap between them, so the sensors can see where one item ends and the next one starts.
- Scan. A photo sensor at the scanner sees the front of the item and opens a read window. The scanner sends the code on RS-232. The window closes when the back of the item passes.
- Look up. The PLC looks for an open order that still needs this code. That order gives the lane. No code, two codes or a code that no order needs means exceptions.
- Track. The PLC stores the encoder count at the scan. The item moves with the belt, so the count tells where it is at any moment, even if the belt stops and starts again.
- Divert. When the count reaches the diverter of its lane, the PLC opens the valve. The arm swings across the belt and guides the item into the lane, then returns.
- Confirm. A sensor at the entry of the lane must see the item within 1.2 s. Only then does the PLC count the item in its order. When an order has all its items, its lane light turns on for the packer.
Run the Normal wave scenario and watch how the order cards fill up while the items arrive grouped by code.
How does the PLC know where each item is on the belt?
It counts the pulses of an encoder on the belt, and keeps a list of the items between the scanner and the end of the belt. Each entry holds the encoder count at the scan, the length of the item and its lane.
- Encoder: in the example, 1 pulse per mm. At 0.5 m/s that is 500 pulses per second, well inside the 20 kHz of the optoisolated inputs of the M-Duino family. Use an interrupt input, so the program does not miss a pulse while it talks to the scanner or the network.
- Diverter 1 at 2.0 m: the scanner is at 0.8 m, so the item is 1,200 pulses away. The PLC opens the valve 60 pulses earlier, because the arm needs time to cross the belt, and closes it when the back of the item has passed.
- The gap: the photo sensor sees two items that touch as one long item, and the scanner reads two codes in one window. The PLC cannot tell which code belongs to which item, so both go to exceptions. Items that are too close for the arm to swing back also go to exceptions.
A timer instead of an encoder works only while the belt speed never changes. Here the belt stops for faults and for full lanes, so the PLC follows the encoder count, not the time.
Set Infeed gap to Not metered and run the Normal wave again. Some items arrive touching and go to exceptions.
What happens with no-reads, unknown codes and full lanes?
The item goes to the exceptions chute at the end of the belt, and the PLC writes the reason in its record. It never guesses a lane.
- No read: a damaged or folded label. An operator fixes it and puts the item back on the belt. The order waits for it.
- Code not in the wave: a picking error. The item goes back to stock, and the warehouse system finds out which order is short.
- No open order needs it: one item too many of a valid code. Every order with that code is already complete.
- Lane full: a sensor near the top of the lane stays covered. The PLC checks it when the item reaches the diverter. Pushing another item into a full lane jams it.
The read rate on the panel is the share of items with exactly one code in the window. A falling read rate often points to dirty scanner glass, a moved scanner or a new label printer, before it becomes a problem in the orders.
Run the No-reads and extras scenario, then try the Jammed lane scenario with both options of When a lane is full.
Why confirm every divert?
Because a valve output that is on does not prove that the item is in the lane. A diverter can stick, lose air or arrive late. Without a check, the PLC counts the item in its order anyway. The light says the order is complete, and the packer finds an item missing.
With the lane sensor, the PLC counts the item only when it sees it enter. A missed item stays open in its order and goes to exceptions, where the operator can re-induct it. Two misses in a row on the same diverter stop the belt: a single miss can be a badly placed item, two in a row point to the diverter.
Run the Diverter fault scenario with Confirm with the lane sensor, then again with Trust the diverter, and compare order 3 at the end.
The belt, the diverters and the safety of people are separate questions. The emergency stop and the guards go to a safety relay that removes the power of the belt motor and the air of the diverters, without going through the PLC (IEC 60204-1, ISO 13850). The PLC reads the state of the safety circuit on one input and stops the sorting logic. It does not replace it. See how a PLC reads the state of interlocks and the e-stop.
Design choices you make
1. A metered infeed
The infeed belt stops and starts to leave a minimum gap before each item. It costs a little throughput, and it saves most double reads. Without it, the gap depends on how the pickers drop the items.
2. Confirm or trust the diverter
A sensor at each lane entry costs one input per lane. It turns a silent error at the packing table into an exception on the sorter, with the lane and the diverter in the record.
3. A full lane: exceptions or hold
Sending to exceptions keeps the other orders moving, and adds work for the exceptions operator. Holding the infeed sends nothing to exceptions that a free lane could take, and stops every order until the packer empties the lane. Items already on the belt for the full lane still go to exceptions.
4. Which order gets an item
When two open orders need the same code, the PLC must choose. The lowest order number is simple to follow. The order closest to complete finishes orders earlier, so packers can start sooner. Compare the time of each complete order in the log.
5. What lives in the PLC and what lives in the warehouse system
The PLC keeps only the current wave: codes, quantities and lanes. The M-Duino 42+ has 8 KB of RAM, enough for a wave of about a hundred lines with short codes. The catalogue, the stock and the history stay in the warehouse system. If the network stops, the PLC can finish the wave it has, keep the records on its microSD card and send them when the link is back.
The case studies behind this simulator
This simulator puts together patterns from several of our cases: picking and packing online orders, sorting packages by their barcode, storing and shipping boxes, tracing packs on a packaging line, and driving a conveyor belt. Each case describes its own plant. This simulator shows the sorting logic they share.
- E-commerce pick and pack with an ESP32 PLC: orders, presence sensors and two scans for grouped orders
- Logistics automation with a Raspberry PLC: a barcode read at the entry and sorting on the belt
- Automated warehouse with an M-Duino: QR codes, storage by weight and dispatch to the docks
- Packaging line traceability with ESP32 PLCs: a barcode scanner, batches and cases
- Packaging line retrofit with an ESP32 PLC: line, phase and product data from an old line
- Conveyor belt speed control with an M-Duino 42+: the inverter that moves the belt
What you see here is a general pattern. The codes, orders, lanes, distances, times and faults are examples, not data from those cases.
To sort by weight instead of by code, try the weight sorting simulator.
Learn the building blocks
These tutorials and examples cover the parts of this sorter on an Arduino based PLC.
- How to use interrupt inputs with industrial Arduino boards, for the belt encoder
- How to use RS-232 on an industrial Arduino based PLC, for the barcode scanner
- MQTT between an M-Duino PLC and a Raspberry PLC, to receive the wave and send each record
- Modbus RTU speed control of a VFD with an M-Duino PLC (PLC Solution Library), for the belt drive
More examples: PLC Solution Library · all simulators.
M-Duino 42+: the specs that matter here
| Name | M-Duino 42+, reference IS.MDuino.42+ |
|---|---|
| Inputs | 26: 12 analog/digital (0-10 V, 10-bit) and 14 digital optoisolated (5 to 24 Vdc), 4 with interrupt |
| Outputs | 16: 10 digital optoisolated (5 to 24 Vdc, 70 mA) and 6 analog/digital/PWM (0-10 V, 8-bit, 20 mA) |
| Communication | Ethernet W5500 10/100 Mbit (RJ45), RS-485, RS-232, TTL serial, I2C, SPI |
| Built in | Real-time clock, microSD slot, USB 2.0 Type-B |
| Controller | Arduino Mega 2560 (ATmega2560, 16 MHz, 8 KB SRAM) |
| Power supply | 12 to 24 Vdc, with fuse (2.5 A) and polarity protection |
| Environment | 0 to 60 °C, 10 to 90 % humidity without condensation |
| Mounting | DIN rail TS35, IP20, inside a cabinet |
| Programming | Arduino IDE with the Industrial Shields boards package |
Example I/O for this sorter
| Signal | PLC I/O | Count |
|---|---|---|
| Belt encoder, channel A | Digital input with interrupt | 1 |
| Photo sensors: infeed, scanner, end of belt | Digital inputs, optoisolated | 3 |
| Lane entry sensors 1 to 4 | Digital inputs, optoisolated | 4 |
| Lane full sensors 1 to 4 | Digital inputs, optoisolated | 4 |
| Lane done buttons for the packers 1 to 4 | Analog/digital inputs used as digital | 4 |
| Start, stop, operator reset, drive ready, safety circuit OK (status only) | Analog/digital inputs used as digital | 5 |
| Belt run, infeed run, diverter valves 1 to 4 | Digital outputs, optoisolated, through interposing relays | 6 |
| Lane lights 1 to 4 | Digital outputs, optoisolated, through interposing relays | 4 |
| Tower lamp: green, amber, red | Analog/digital outputs used as digital, through interposing relays | 3 |
| Barcode scanner | RS-232 | 1 |
| Warehouse system: the wave in, the records out | Ethernet | 1 |
This example uses 21 of the 26 inputs and 13 of the 16 outputs. The encoder goes to an interrupt input. The digital outputs give up to 70 mA and the analog/digital outputs up to 20 mA, so valve coils, lamps and the run signals go through interposing relays or a valve terminal. For the diverter valves, which switch on every item, prefer solid-state relays or a valve terminal. The datasheet gives 0 to 24 Vdc for the analog/digital inputs in digital mode, so 24 V buttons can connect there. For more lanes, add a second PLC on Ethernet or choose a larger M-Duino. Check your loads and levels against the M-Duino family datasheet. Full specs: M-Duino 42+ · M-Duino family.
FAQ
How does a PLC sort items to orders on a conveyor?
The warehouse system sends the wave to the PLC: which codes each order needs and which lane holds each order. A scanner reads each item, the PLC finds an open order that still needs that code, follows the item with the belt encoder and fires the diverter of its lane at the right count. A sensor at the lane entry confirms the item, and the PLC counts it in its order. When an order has all its items, the PLC turns on the lane light.
How do you connect a barcode scanner to an M-Duino PLC?
Many fixed industrial scanners have an RS-232 output, and the M-Duino 42+ has an RS-232 port. The scanner sends each code as a line of text, and the PLC reads it inside the read window opened by the photo sensor. Some scanners use RS-485 or Ethernet instead. The M-Duino has both, so check the interface of your scanner first.
Why track items with an encoder instead of a timer?
A timer assumes that the belt always runs at the same speed. A belt that stops for a full lane, a fault or an operator, or that slows down with load, moves the items a different distance in the same time. The encoder counts the real movement of the belt, so the PLC knows where each item is even after a stop.
What should the sorter do with an item it cannot read?
Send it to the exceptions chute and write the reason in the record. The PLC never guesses a lane. An operator fixes the label and puts the item back on the belt, and the order waits for it. The same goes for two codes in one read window, a code that is not in the wave, and an item that no open order needs.
Why does a sorter need a sensor at each lane entry?
To know that the item really entered the lane. An output that opens a valve does not prove that the diverter moved or that the item followed it. Without the sensor, a stuck diverter sends items to exceptions while the PLC counts them in their order, and the packer finds the order short. With the sensor, the PLC keeps the item open and stops the belt after two misses in a row on the same diverter.
How many lanes can one M-Duino 42+ handle?
In this example, each lane uses two inputs (entry and full), one button input and two outputs (diverter valve and light). Four lanes use 21 of the 26 inputs and 13 of the 16 outputs, with the encoder, the photo sensors, the operator signals and the tower lamp. For more lanes, drop the buttons to the warehouse system, add a second PLC on Ethernet, or choose a larger M-Duino.
How does the PLC get the orders from the warehouse system?
Over Ethernet, for example with MQTT or HTTP. The warehouse system sends the wave before it starts: the codes, the quantities and the lane of each order. The PLC sends back one record per item and a message when an order is complete. The PLC keeps only the current wave in its memory, and the catalogue and the history stay in the warehouse system.
Send me this architecture
Tell us what you sort, how you read it, how many lanes you need and which system sends your orders. Our team replies with a proposed architecture for your sorter. Your simulator settings go with the request.