# PLC-Controlled Intelligent Conveyor System with AI-Enhanced Vision for Efficient Waste Sorting
## 3 Deep Learning Model and Programming Framework
### PLC Programming and Control Logic  
Programming of the PLC is performed using ladder logic within the RS Logix 5000 v20 software. Several software functions are used, including examining input ports, moving commands, timers and counters, internal registers, subroutines, and output ports. The program includes test switches and physical button ports for maintenance and testing purposes. The system can be reprogrammed to adjust the end positions by modifying the timer values. Additionally, new parts can be seamlessly integrated by duplicating rungs in the subroutine without requiring significant changes to the main routine. Bypasses for diagnostics and testing are also included, allowing the process to be controlled through HMI buttons or physical switches. The primary function of the program is structured around a main routine, illustrated in Figure 10, which performs the following checks and processes:  
1. The start button is pressed;
2. The conveyor moves forward for a predefined duration (_T1_);
3. The camera detects the presence and type of part;
4. The program triggers the appropriate subroutine;
5. The subroutine loads a preset timer according to the detected part;
6. The motor operates once activated, triggered by the _T2_ timer;
7. The part is pushed by the actuator;
8. All timers are reset, and the program repeats the cycle;
9. If no parts are detected, the program is stopped until the operator resets or restarts it.  
The subroutine depicted in Figure 11 plays a crucial role in acquiring the input data from the Ethernet network. Subsequently, it loads one of three predetermined values onto a timer. These preset values dictate the distance the conveyor travels before coming to a halt. To maintain uninterrupted operation as components are introduced into the system, latching logic is used. This approach simultaneously isolates output connected to previously sorted components, thus maintaining precise sorting into the designated bins.  
Paper-based items are allowed to pass directly beyond the actuator and proceed into a designated container specifically designed for paper, located at the end of the conveyor belt system. On the other hand, plastic and metallic items are programmed to pause directly underneath the actuator. Upon achieving the correct placement, the actuator is initiated. The stepper motor responds by rotating clockwise or counterclockwise, depending on whether a metal can or plastic bottle has been identified, thus guiding the item into the appropriate collection bin located on the left or right side of the conveyor system. After the sorting mechanism has completed its operation, all associated timers are set back to their initial state, and any latched outputs are subsequently unlatched.  
The program is designed with built-in test switches and physical button ports to facilitate maintenance and testing operations. The system can be easily reprogrammed to modify the end positions by adjusting the timer values. Additionally, new parts can be seamlessly integrated by duplicating a rung in the subroutine, without requiring significant modifications to the main routine. This flexibility allows for efficient scalability and adaptability in the sorting process.  
The program also includes bypasses for diagnostic purposes and algorithm testing, controlled via switches and buttons. As shown in Figure 12a, the process can be operated through the main HMI screen or physical buttons, depending on the user's preference. The configuration settings of the HMI panel, shown in Figure 12b, allow easy control  
Figure 10: Ladder diagram of the main routine illustrating conveyor movement, part detection, and actuator control within the automated sorting system.  
and adjustment of the system parameters, ensuring smooth operation and maintenance. The counters integrated into the input rungs track the number of processed parts and display this information on numeric displays, as configured in the HMI panel settings shown in Figure 12a.