How to Program a Sorting Station – Click PLC

The sorting station box selection (camera management and distribution) is just one of many machines in the EasyPLC Machine Simulator (MS). This sorting station will read barcodes from the boxes and send them to different exit ramps. The Click programming software will be used to program this Click PLUS PLC.
How to Program a Sorting Station - Click PLC
Modbus TCP (Ethernet) will connect the Click to the EasyPLC Simulator. Discrete inputs, outputs, and registers will be controlled from the EasyPLC Simulator (Client) to the Click PLC (Server). Using the five steps for program development, we will show how this sorting station is programmed. Let’s get started.

Learn PLC programming the easy way. See below for a 10% discount on this cost-effective learning tool. Invest in yourself today.
The entire series can be found here.
Here are some previous posts we have done:
Easy PLC Installing the SoftwareVideo
EasyPLC Software Suite – Quick StartVideo
Click PLC – Easy Transfer Line ProgrammingVideo
Productivity PLC Simulator – Chain Conveyor MSVideo
Do-More PLC – EasyPLC Box Selection ProgramVideo
Click PLC EasyPLC Gantry SimulatorVideo
Click PLC Simple Conveyor EasyPLCVideo
EasyPLC Paint Line Bit Shift – BRX Do-More PLCVideo
Click PLC – EasyPLC PLC Mixer ProgrammingVideo
Click PLC EasyPLC Warehouse Stacker ExampleVideo
–  Operation Video
EasyPLC Machine Simulator Productivity PLC Robotic CellVideo
EasyPLC Simulator Robotic Cell Click PLCVideo
EasyPLC Simulator Robotic Cell BRX Do-More PLCVideo
EasyPLC Factory Editor Robotic Cell Additions Video
4 Way Traffic Light PLC Program EasyPLCVideo
Rock Crusher Plant EasyPLC BRX Do-MoreVideo
Freight Carrier Weighing and Distribution EasyPLCVideo
EasyPLC Machining Center Loading RobotsVideo
EasyPLC Palletizing Robot Programming Click PLCVideo
EasyPLC Machine Editor – Design a SimulationVideo
PLC Programming Mixing Tank – EasyPLC / Do-MoreVideo
EasyPLC Solder Robot PLC ProgrammingVideo
PLC Programming – A Tutorial for BeginnersVideo
Automated Parking Demo Video
Parking Cars Simulator PLC Programming Part 1Video
Parking Cars Simulator PLC Programming Part 2Video
PLC Programming with Pneumatic SynchronizationVideo
The Ultimate Guide to PLC Programming for Sorting OperationsVideo
Optimizing Batch Processing with PLC SystemsVideo
PLC Multi Conveyor Feed Control Demystified!Video
PLC Program Sequence for Efficient Robot LoadingVideo
Streamline Programming Do-More EasyPLC TransferVideo
Programming Chain Conveyor Transfer with Do-MoreVideo

Define the task: (Step 1 – Click PLC Sorting Station)

Start the EasyPLC Machine Simulator software. Select the start button on the main screen or select machines from the main menu. All sample programs you can practice your PLC program will be listed.
How to Program a Sorting Station - Click PLC
Click on the “03 Box Selection” machine.

There is also a written version of the sequence on the left-hand side of the machine.
Camera management and distribution (box selection sorting station) will use photocells and cameras. These are located in each selection station and will read the barcodes of the boxes. The box will be sent down the corresponding exit ramp. Box ID 1 will be sent to the first Exit, ID 2 to the second Exit, and ID 3 to the third Exit. The number of boxes sent down each Exit will be displayed on the control panel.
How to Program a Sorting Station - Click PLC
The machine simulator has a demo mode for the built-in machines. Select the demo mode. This will allow you to watch the operation of the box sorting station. This will help you see what has to be done.
Move around the 3D virtual environment. The icons on the top of the window will allow you to move around this 3D environment.
Testing / Troubleshooting the ladder logic
The first icon is the default selection. This will enable you to move around without bumping into the components. The first-person mode will mimic a person in your 3D learning world.
How to Program a Sorting Station - Click PLC
The third person is used to show the operator’s relationship to the machine. The last icon will automatically show you around this virtual environment. Once we understand what must be done, we can move on to the next step in our PLC program development.
Watch the sequence of operation video below.

Define the Inputs and Outputs: (Step 2 – Click PLC Sorting Station)

While still in the demo mode of the machine simulator, we can select the View IO on the bottom menu.
How to Program a Sorting Station - Click PLC
This will now show the digital outputs on the left-hand side of the screen and the digital inputs on the right-hand side of the screen. We can watch how the IO relates to the demo program. Select the exit button to stop the demo mode of the machine simulator.

Start the box selection sorting station in start mode.
How to Program a Sorting Station - Click PLC
Select the View IO to display the inputs and outputs required for this machine.
How to Program a Sorting Station - Click PLC
Select the Analog inputs and outputs to view them.
How to Program a Sorting Station - Click PLC
The EasyPLC sorting station box selection machine simulator will require ten digital outputs and 15 digital inputs. It will also need three analogs in and out. The analog outputs are for the exit ramp counts. Analog inputs are for each camera on the exit ramps to read the box barcode.
Clicking on the digital outputs will activate it. Spend some time understanding the IO (inputs and outputs) functions fully.
How to Program a Sorting Station - Click PLC
You can move around in the 3D environment and see the IO and items from different angles.
How to Program a Sorting Station - Click PLC
The machine simulator will be communicating to a Click PLC. Communication will be done with Modbus.

We can look at the address picker using the Click PLC Software to determine the Modbus Addresses we require for the program.
How to Program a Sorting Station - Click PLC
The following table will define the inputs and outputs (IO) and Modbus addresses in the Click PLC we will use for this program.

Digital Type Description Click PLC Modbus Address Machine Simulator Modbus Address
PLC Output – MS Input Conveyor Belt Start 3 16485 – C101 16484
PLC Output – MS Input Select Arm 3 Turn 16486 – C102 16485
PLC Output – MS Input Select Arm 2 Turn 16487 – C103 16486
PLC Output – MS Input Select Arm1 Turn 16488 – C104 16487
PLC Output – MS Input Camera 1 Start 16489 – C105 16488
PLC Output – MS Input Camera 2 Start 16490 – C106 16489
PLC Output – MS Input Camera 3 Start 16491 – C107 16490
PLC Output – MS Input Start Button Light 16492 – C108 16491
PLC Output – MS Input Stop Button Light 16493 – C109 16492
PLC Output – MS Input Reset Button Light 16494 – C110 16493
Analog PLC Output – MS Input Exit 1 Conveyor Count 40001 – DS1 0
Analog PLC Output – MS Input Exit 2 Conveyor Count 40003 – DS2 1
Analog PLC Output – MS Input Exit 3 Conveyor Count 40004 – DS3 2
PLC Input – MS Output PhotoCell 1 Signal 16585 – C201 16584
PLC Input – MS Output PhotoCell 2 Signal 16586 – C202 16585
PLC Input – MS Output PhotoCell 3 Signal 16587 – C203 16586
PLC Input – MS Output Camera 1 End 16589 – C205 16588
PLC Input – MS Output Camera 2 End 16590 – C206 16589
PLC Input – MS Output Camera 3 End 16591 – C207 16590
PLC Input – MS Output Machine Door Open 16592 – C208 16591
PLC Input – MS Output PhotoCell 1 Exit 16593 – C209 16592
PLC Input – MS Output PhotoCell 2 Exit 16594 – C210 16593
PLC Input – MS Output PhotoCell 3 Exit 16595 – C211 16594
PLC Input – MS Output Emergency Button 16596 – C212 16595
PLC Input – MS Output Stop Button 165897- C213 16596
PLC Input – MS Output Reset Button 16598 – C214 16597
PLC Input – MS Output Start Button 165899- C215 16598
Analog PLC Input – MS Output Camera 1 Result 40101 – DS101 100
Analog PLC Input – MS Output Camera 2 Result 40102 – DS102 101
Analog PLC Input – MS Output Camera 3 Result 40103 – DS103 102

Note: The machine simulator will be offset by one on the Modbus Addresses.

Develop a logical sequence of operation: (Step 3 – Click PLC Sorting Station)

A flow chart or sequence table is used to understand the process that needs to be controlled thoroughly. It must also answer questions like the following:

What happens when electrical power and pneumatic air is lost? What happens when the input/output devices fail? Do we need redundancy?

This step is where you can save yourself a lot of work by understanding everything about the operation. It will help prevent you from continuously re-writing the PLC program logic. Knowing all of these answers upfront is vital in developing the PLC program.

How to Program a Sorting Station - Click PLC
The control panel of the EasyPLC Box Selection Sorting Station program will show the operator information. If the gate is opened, the red LED will flash. In the stop mode, the green LED will be on, indicating this is how to start the line. When the line runs, the red LED will tell you how to stop the machine. An emergency stop will turn all of the LEDs off. The exit conveyor counts will show how many boxes have been diverted to it. When the machine stops, and the box counts are greater than 0, the reset LED will be on. Pressing the reset will zero the counts and turn off the LED.

How to Program a Sorting Station - Click PLC
Our EasyPLC Box Sorting Station program can be seen as three independent exit conveyor operations. A box will pass, and the camera and photocell will read the barcode. If the barcode is for this conveyor, the arm will be activated, diverting the box. When the exit photocell is on, this will reset the arm.

A PLC programmer must know how everything about the sequence and operation of the machine before programming.

Ask questions or view existing documentation to ensure you know the logical steps to the machine’s operation.

Develop the PLC program: (Step 4 – Click PLC Sorting Station)

Writing the ladder logic code for our Click PLC sorting station example will be the next step in our program development.
We will use the Click PLC programming software and a Click PLUS CPU. Detailed information on the Click PLC can be found in our Click PLC Series. Our program will be written in ladder logic. (Ladder Diagram)
Ladder logic sample code
The first rungs of code will set the conveyor belts running for our box selection program. This is done with the set and reset instructions. The conveyor reset will happen when a stop, machine door, or emergency button is selected.
Ladder logic sample code
The start light will be on when the machine is ready.
Ladder logic sample code
The stoplight will be on when the machine is running. A flashing stoplight will indicate that the machine is stopped and the door is opened.
Ladder logic sample code
The reset button will be lit when the machine is stopped, and any exit conveyors have a count greater than 0. The reset button will reset the counts for each exit conveyor for the box selection program.
Ladder logic sample code
Exit 1 Conveyor
If the conveyors are running, the camera is turned on. The result is compared to the exit number when the camera end is seen. If this matches, then set the selection arm for the Exit. Once the photocell on the Exit is seen, reset the selection arm and increment the exit count by 1 for our box selection.
Ladder logic sample code
Exit 2 Conveyor
If the conveyors are running, the camera is turned on. The result is compared to the exit number when the camera end is seen. If this matches, then set the selection arm for the Exit. Once the photocell on the Exit is seen, reset the selection arm and increment the exit count by 1 for our box selection.
Ladder logic sample code
Exit 3 Conveyor
If the conveyors are running, the camera is turned on. The result is compared to the exit number when the camera end is seen. If this matches, then set the selection arm for the Exit. Once the photocell on the Exit is seen, reset the selection arm and increment the exit count by 1 for our box selection.
This is our complete program. See below to download the program and machine simulator scene.

We communicate to the EasyPLC machine simulator using Modbus TCP (Ethernet or Wireless). The ports will be set up with a fixed IP address so the machine simulator (Modbus Client) can find the Modbus Server.
Modbus TCP Settings
Select Modbus TCP from the communication port on the Function tab of the navigation window. You can also use the main menu | Setup | Com Port…
Modbus TCP Settings
The COM port setup window will now be displayed. Click on the Setup Button for Port 1.
Modbus TCP Settings
You can now set the static IP address on the Com Port Setup Details window.
Modbus TCP Settings
Select Modbus TCP Setup from the main menu | Setup. Ensure the “Enable Modbus TCP Server” is checked for our port.

How to Program a Sorting Station - Click PLC
Save and transfer the sorting station program to the Click PLUS PLC. Ensure that the PLC is in run mode. Select “Status” to see the active status of the inputs and outputs on the ladder logic.

Test the program: (Step 5 – Click PLC Sorting Station)

We will use Modbus TCP on our Click PLUS PLC  to communicate with the machine simulator. Call up the “03 Box Selection” in start mode.
Testing the ladder logic
The status of the machine simulator will be at the bottom of the screen. Currently, we have no PLC connected. Select IO on the bottom middle of the screen.
Testing the ladder logic
The EasyPLC driver window will now be displayed. This will show you the machine simulator IO number. Ensure you have enough digital and analog numbers for our Click PLC Sorting Station. If not, change the values and select the Update IO Number button.
Testing the ladder logic
Under the driver name pull-down menu, select “ModBusDriver.”

This driver will communicate Modbus TCP (Ethernet) and Modbus RTU (Serial). Select the configure button.
Testing the ladder logic
We can now enter the information for our Modbus driver. Select TCP/IP. This means the computer’s Ethernet port will communicate with the PLC. The digital inputs from MS to the Click PLC will start at C101. This will start at address 16484 due to the offset of 1. Digital outputs from MS to the Click PLC will start at C201. This will begin at address 16584 due to the offset of 1. Analog inputs DS1 will start at address 0, and outputs DS101 will begin at address 100. This is due to the offset of 1. The address picker in the Click programming software will help determine the Modbus Addresses.
The analog scale factor is 1. This is used to divide and multiply so that the Modbus analog value can be read/written within the simulator. The analog subtract factor is 0. This is used with the analog to obtain negative numbers within the Modbus analog registers.
Select the OK button.
Testing the ladder logic
You will now see the inputs and outputs specified for the Modbus driver. We can now manually assign the driver outputs to the PLC inputs and driver inputs to the PLC outputs. However, an automatic assignment will do this if the I/O is in the same order in the PLC and EasyPLC machine simulator.
Testing the ladder logic
Select Automatic Assignment from the driver option in the main menu.
Testing the ladder logic
This will automatically assign the PLC IO to the Machine Simulator IO.
Testing the ladder logic
Select “Start Driver and Exit” from the main menu under Exit.
Testing the ladder logic
You will see that the driver is operating on the bottom left side of the window. Select view IO to know the input and output status of the machine simulator. Move around to the control panel.
Testing the ladder logic
Ensure that the PLC is in run mode. We can now operate the machine simulator through the control panel.
Testing the ladder logic
Using the Data View window of the Click programming software, we can also watch the inputs and output operations.
Run and monitor to ensure that your program works as expected.
Testing / Troubleshooting the ladder logic
Using Machine Simulator (MS) to test the program will ensure that our program works. Troubleshooting is quickly done without damage to any physical hardware.
The machine simulator has a time frame that you can speed up or slow down the process to help you troubleshoot. Watch the video below to see this operation.
Testing / Troubleshooting the ladder logic

Download the Click PLC sample program for the Click Sorting Station.

Watch the video below to see the five steps of program development applied to the Click PLC Sorting Station Box Selection. The machine simulator is the best application to help you learn PLC programming.

EasyPLC Software Suite is a complete PLC, HMI, and Machine Simulator package. This PLC learning package includes the following:
Easy PLC – PLC Simulation allows programming in Ladder, Grafcet, Logic Blocks, or Script.
HMI System – Easily create a visual human-machine interface (HMI)
Machine Simulator – A virtual 3D world with real-time graphics and physical properties. PLC programs can be tested using EasyPLC or through other interfaces. (Modbus RTU, TCP, etc.)
Machine Simulator Lite – Designed to run on Android Devices.
Machine Simulator VR – Virtual Reality comes to life so you can test, train or practice your PLC programming.

Purchase your copy of this learning package for less than USD 75 for a single computer install or less than USD 100 to allow different computers.
Receive 10% off the price by typing in ACC in the comment section when you order. http://www.nirtec.com/index.php/purchase-price/
Learn PLC programming the easy way. Invest in yourself today.

Watch on YouTube: How to Program a Sorting Station – Click PLC

If you have any questions or need further information, please contact me.
Thank you,
Garry


If you’re like most of my readers, you’re committed to learning about technology. Numbering systems used in PLCs are not challenging to learn and understand. We will walk through the numbering systems used in PLCs. This includes Bits, decimals, Hexadecimal, ASCII, and Floating points.

To get this free article, subscribe to my free email newsletter.


Use the information to inform other people how numbering systems work. Sign up now.

The ‘Robust Data Logging for Free’ eBook is also available for free download. The link is included when you subscribe to ACC Automation.

Leave a Comment