Walkthrough: Problem 11: Sorting Station

Difficulty

Target behavior

Identify workpieces on the conveyor with two photoelectric sensors, and push out only the short ones with a cylinder to sort them

What you will learn

  • Identification by combining two sensors
  • Remembering the result as a flag
  • Timers for timing adjustment

Problem

This model identifies workpieces on a belt conveyor with sensors and sorts them with an air cylinder.


There are two heights of workpieces, tall and short. Use the two photoelectric sensors stacked vertically to identify the height, and push the short workpieces (red ones) into the red box with the air cylinder!

Target behavior (video)

Approach

Two photoelectric sensors, upper and lower, identify the height of a workpiece. A tall workpiece blocks both sensors, while a short one blocks only the lower sensor. When a short workpiece reaches the front of the cylinder, stop the conveyor and push it out.

Process table (steps)

StepDescriptionCondition to advanceMain outputs
MR1Waiting to pushT0 0.5 s-
MR2PushingX5 cylinder extended endY1 ON, conveyor stopped
MR3RetractingX6 cylinder retracted endConveyor stopped

Based on this approach, try writing the ladder yourself first.
In the simulator, you can create the wiring and ladder and actually run the 3D equipment model.

Try it in the simulator
Show the sample ladder and explanation(click to open)

Devices used

DeviceComment
Inputs
X0Conveyor start button
X3Photoelectric sensor (upper)
X4Photoelectric sensor (lower)
X5Cylinder extended end
X6Cylinder retracted end
Outputs
Y0Conveyor (contactor)
Y1Cylinder solenoid valve
Internal relays
MR0Tall workpiece
MR1Waiting to push
MR2Pushing
MR3Retracting
MR10Running
Timers
T0Time to push position

Ladder explanation

The row numbers in the figures match the row numbers in the simulator's ladder window.

1Start operationRows 001–002

On the rising edge of X0 (start button), SET MR10 (running).

2Identifying workpiecesRows 003–007

  • Row 004: if the upper sensor X3 is also blocked while the lower sensor X4 is blocked, SET MR0 (tall workpiece)
  • Row 006: at the moment the workpiece leaves the lower sensor (LDF X4), if MR0 is OFF (= short workpiece), SET MR1 (waiting to push)
  • Row 007: at the same timing, RES MR0 to prepare for the next workpiece

Identification is only possible while the workpiece is passing, so the result is remembered in MR0 and judged when it has finished passing.

3Push-out sequenceRows 008–014

  • Row 009: while waiting to push, count 0.5 seconds with T0 (the time the workpiece takes to move from the sensor to the front of the cylinder)
  • Rows 010–011: after 0.5 seconds, go to pushing
  • Rows 012–013: when the cylinder extended end X5 turns ON, go to retracting
  • Row 014: when the cylinder retracted end X6 turns ON, finish

4OutputsRows 015–017

  • Y0 (conveyor): ON while running and not pushing/retracting. The conveyor is stopped while pushing.
  • Y1 (cylinder solenoid valve): ON during the pushing step

The sample wiring and ladder data can be downloaded fromGitHuband loaded with "Load wiring" and "Load ladder" in the simulator.

Key points

  • The 0.5-second wait depends on the conveyor speed and the distance between the sensor and the cylinder. In real equipment, a sensor is often also placed in front of the cylinder to check the position directly.
  • Rows 006 and 007 use the same LDF X4. Because the PLC processes rows from top to bottom, MR0 is evaluated on row 006 before it is RESet on row 007, so the result is used correctly.