Journal of Fuzzy Systems and Control, Vol. 4, No 1, 2026

Development of an Automated PCB Inspection, Error Statistics, and Classification System

Truong-Nguyen Phan 1, Thi-Ngoc-Tram Tran 2, *, Thanh-Viet Ho 3, Binh-Hau Nguyen 4, Minh-Tri Hoang 5, Hai-Nam Tran 6, Nhat-Nam Nguyen 7, Nguyen-Cong-Anh Tran 8, Le-Huu-Tri Do 9, Thi-Ngoc-Thao Nguyen 10, Nam-Long Tran 11,
Duong-Thuan Nguyen
12, Van-Huy Le 13, Van-Tuan Nguyen 14, Huynh-Anh-Tuan Pham 15

1, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 Ho Chi Minh City University of Technology and Engineering (HCM-UTE),
Ho Chi Minh City (HCMC), Vietnam

2 Gremsy Company, Ho Chi Minh City (HCMC), Vietnam

3 Techtronic Industries Company Limited, Ho Chi Minh City (HCMC), Vietnam

4 Posts and Telecommunications Institute of Technology, Ho Chi Minh City (HCMC), Vietnam

Email: 1 22851016@student.hcmute.edu.vn, 2 Tram.tran@gremsy.com, 3 ThanhViet.Ho@ttigroup.com.vn,

4 haunb@ptit.edu.vn, 5 22151043@student.hcmute.edu.vn, 6 22142029@student.hcmute.edu.vn,

7 21151036@student.hcmute.edu.vn, 8 22145095@student.hcmute.edu.vn, 9 22161198@student.hcmute.edu.vn,

10 thaontn@hcmute.edu.vn, 11 22142160@student.hcmute.edu.vn, 12 22145254@student.hcmute.edu.vn,

13 22142128@student.hcmute.edu.vn, 14 22145280@student.hcmute.edu.vn, 15 19161317@student.hcmute.edu.vn 

*Corresponding Author

Abstract—In the electronics manufacturing industry, Printed Circuit Boards are critical to electronic devices, and their quality directly affects product performance and reliability. Common assembly defects, such as missing components, misalignment, or wrong parts, must be detected promptly to reduce waste and maintain reputation. In Vietnam, PCB inspection is largely manual, limiting speed, accuracy, and consistency. The system integrates a YOLOv5-based machine vision module for detecting missing and misaligned components, a Siemens S7-1200 PLC for controlling an XY gantry and conveyor system, and a web interface for real-time monitoring. The primary contributions include: a fully integrated cyber-physical prototype suitable for educational and small-scale industrial use; a novel method for component misalignment detection using fiducial-based relative positioning; and seamless communication between vision, control, and HMI modules. Experimental results on two common PCB types, L298N and ULN2003, demonstrate a classification and error detection accuracy of up to 93%. The system achieves a throughput suitable for laboratory and small-batch production, with a positioning accuracy of ±0.5 mm. The system aims to achieve high accuracy, fast processing, and practical applicability in production lines.

Keywords—Image Processing; YOLOv5; PCB; Automated Inspection; PLC S7-1200; Defect Statistics

  1. Introduction

The electronics manufacturing sector's critical dependence on Printed Circuit Board (PCB) quality is underscored by the severe consequences of defects - from missing components to misaligned placements - which can trigger catastrophic product failures and substantial financial losses [1], [2]. While sophisticated inspection systems utilizing X-ray and other advanced modalities have demonstrated potential in industrial settings [3], their exorbitant cost and operational complexity render them inaccessible to educational institutions and small-to-medium enterprises (SMEs) [4]. This technological disparity is exacerbated by the persistent reliance on manual inspection in many settings, a process characterized by inherent inconsistencies and low throughput [5].

Recent advances in machine learning, particularly the emergence of efficient deep learning architectures like the You Only Look Once (YOLO), present transformative opportunities for developing rapid, accurate visual inspection systems [6]. Integration of such vision systems with industrial programmable logic controllers (PLCs) enables creation of end - to - end cyber physical systems that close the loop between perception, decision-making, and physical actuation [7], as evidenced by successful implementations in food packaging and other automated domains [8]. While current machine learning approaches to PCB defect detection show promise [9], and automated systems for PCB inspection have been explored [10], [11], a significant gap remains in the development of integrated, cost-effective solutions suitable for educational and small-scale industrial applications. Existing automated inspection systems [12] and smart manufacturing frameworks [13] often rely on specialized hardware like NI Vision Builder and MyRIO [14], or focus primarily on identification and defect detection without comprehensive integration [15].

To ensure comprehensive evaluation, this study investigates the system's performance under various operational conditions, including different lighting scenarios, PCB orientations, and board sizes. However, several limitations should be acknowledged. Current implementation is optimized for laboratory and small-batch production environments, and its scalability to high-speed industrial lines requires further validation. Potential challenges include maintaining robustness under highly variable lighting conditions, handling more complex multi-layer PCB layouts, and ensuring real-time performance with increased conveyor speeds. These aspects represent important directions for future research and system refinement.

Inspired by these developments, this research develops an integrated PCB inspection and classification system that synergizes a YOLOv5-based machine vision framework with Siemens S7-1200 PLC control architecture. The work contributes: a functional, low-cost inspection prototype accessible to academic and SME environments; seamless integration of machine vision, industrial control, and web technologies into a cohesive cyber-physical system; a novel component misalignment detection method using relative positioning from PCB fiducials and comprehensive performance evaluation under varied operational conditions, providing insights into both capabilities and limitations for practical deployment.

  1. Experimental Model

System architecture is shown in Fig. 1, which consists of four main modules:

The system is built around a Siemens S7-1200 PLC, a camera positioned above the conveyor, an XY gantry driven by NEMA 17 stepper motors with TB6600 drivers, a 555 DC motor for conveyor movement, MAL16/TN10 pneumatic cylinders controlled via AirTac valves, and a 24 VDC power supply for all low-voltage components.

IMG_256

  1. System block diagram

  1. 3D model of system design
  1. Control Method

  1. System Control Architecture and PLC Programming

The control system is built around a Siemens S7-1200 PLC (CPU 1214C DC/DC/DC), which acts as the central unit for managing all sequential operations, I/O handling, and motion control. The system follows a structured workflow, as outlined in the main program flowchart (Fig. 3).

IMG_256

  1. Main program flowchart of the PLC

The sequence begins with system initialization, where the XY gantry performs a homing routine to establish a precise reference point. Upon a PCB's arrival at the inspection station, confirmed by sensors, pneumatic clamps secure the board. PLC then triggers the vision system via a TCP/IP signal.

After receiving the inspection result, the PLC executes the sorting command, directing the XY gantry to place the PCB in the corresponding bin.

  1. Stepper Motor Configuration and Motion Control

Precise positioning of the XY gantry is achieved using NEMA 17 stepper motors controlled via PTO (Pulse Train Output) in the TIA Portal environment [16]. The configuration involved several critical steps:

  1. Machine Vision and Image Processing Algorithm

The vision system employs a YOLOv5 model [17] for automated PCB inspection. The overall image processing algorithm, depicted in Fig. 4, consists of the following stages:

IMG_256

  1. Overall flowchart of the image processing algorithm

Frame Acquisition and Preprocessing: The video feed from an iPhone 13 camera is captured. A central Region of Interest (ROI) of 320x320 pixels is extracted to isolate the PCB, which is then resized to 640x640 pixels to comply with the model's input specifications. Image preprocessing utilized the OpenCV library. PCB Stabilization check is a system that waits for the PCB to be stationary within the frame, ensuring image clarity for accurate analysis.

Component Detection and Classification: The pre-trained YOLOv5 model processes the image to detect, classify, and localize all components, outputting bounding boxes and confidence scores. The dataset for training was prepared and augmented using Roboflow. The model was trained on a custom dataset comprising 1,600 annotated images (800 images for each PCB type: L298N and ULN2003), totaling 15 component types and 21 different components including ICs, surface mount devices (LED_smd, Res_smd), and connectors. The dataset was divided into 70% training set, 20% validation set, and 10% test set. Data enhancement techniques were applied using Roboflow, including random rotation (±30°), brightness adjustment (±20%), noise addition, and horizontal flipping to improve robustness.

Object detection was performed using the YOLOv5s architecture, chosen for its optimal balance between inference speed and accuracy in a resource-constrained environment. Input images were resized to 640×640 pixels. The training process was performed over 50 epochs with a batch size of 16, using the SGD optimization algorithm with an initial learning rate of 0.01. Component bias was quantified by calculating the intersection-on-merger coefficient (IoU) between the detected bounding boxes and the reference sample location. Detections with IoU < 0.5 were classified as biased. Missing components were identified when the confidence score fell below 0.25. The model achieved an average accuracy (mAP@0.5) of 93.3% on the validation dataset, confirming reliable detection performance for system integration.

PCB Classification and Defect Analysis: The PCB type (L298N or ULN2003) is identified based on the ensemble of detected components. For defect analysis, a robust method was implemented (Fig. 5). This involves comparing the detected component positions against a pre-defined library of expected positions. This library stores the relative coordinates of each component type in relation to fixed reference holes on a known-good PCB, enabling accurate identification of missing and misaligned components.

Data Output and System Feedback: The final status (OK/NG) and detailed defect information are sent to the PLC for physical sorting and to a web server [18] for real-time monitoring and data logging.

IMG_256

  1. Sub-flowchart for component verification and defect analysis
  1. System Integration and Data Communication

The control architecture successfully integrates the deterministic, real-time operation of the PLC with the high-level processing capabilities of the Python-based vision system. Communication is facilitated through a shared Data Block (DB9) in the PLC, using the TCP/IP protocol and the python-snap7 library. This decoupled design ensures operational stability for critical mechanical functions while providing the flexibility needed for complex image analysis and data handling, resulting in a robust and efficient automated inspection system.

  1. Experimental Results

  1. Real Model

The implemented system comprises an integrated hardware and software architecture designed for automated PCB inspection and classification. In Fig. 6 shows the actual implementation of the complete system, demonstrating the mechanical structure and component integration.

In Fig. 6. we have:

The physical setup features a conveyor system for PCB transportation, a precisely calibrated XY-axis mechanism for board positioning, and pneumatic actuators for defective board rejection. A high-resolution industrial camera, mounted in a fixed position with optimal frontal lighting, captures board images for processing. In Fig. 7 illustrates the electrical connection diagram of the control system.

  1. Actual image of the system

  1. Electrical control system connection diagram

And in Fig. 7 we have:

The electrical cabinet was designed with a DIN rail mounting system to ensure logical component arrangement, safe wiring, and maintainability—a critical consideration for practical industrial applications.

  1. Experiment Results

The system's performance was rigorously evaluated through a series of tests, yielding the following key results:

+ Performance Under Varying Conditions: Following model training, system performance was evaluated under varied lighting conditions and PCB rotation angles to assess detection reliability, bounding box accuracy, and component confusion rates. System performance was assessed under various lighting conditions, with representative detection results illustrated in Fig. 8 to Fig. 9.

  1. No light case

  1. Front light case

Low-light condition (Fig. 8): Detection confidence and bounding box stability decreased noticeably, particularly for small and dark surface-mount components. Frontal illumination (Fig. 9): The system achieved optimal performance, with high confidence scores and accurate localization of components. Model performance was strongly influenced by lighting and board orientation: it achieved the highest accuracy under frontal illumination and moderate rotations (120°–180°), but performance declined under low or uneven lighting and dropped sharply at a 90° rotation due to limited rotational diversity in the training data.

+ Performance on Defective Boards: The system was rigorously tested with various fault scenarios, including ten different defect patterns for each board type (L298N and ULN2003) in Fig. 10. to Fig. 11. The inspection system successfully identified and classified multiple instances of missing and misaligned components with high precision.
Fig. 12 shows the HMI interface displaying alarm state for faulty board detection. This demonstrates the seamless integration between vision analysis and PLC-based decision-making, enabling real-time system response.

+ Defect Detection and Classification Accuracy: The YOLOv5 model demonstrated high efficiency in identifying component defects. In controlled tests with predefined fault scenarios (10 for each board type), the system successfully detected and classified various instances of missing and misaligned components. System's stability was further confirmed by testing with defect-free boards, achieving a correct acceptance rate of 93.3% for L298N (28/30 runs) and 90% for ULN2003 (18/20 runs), as summarized in Table 1.

When the system correctly identifies a defect-free board, the HMI interface displays a "PASS" status, and the conveyor system proceeds to route the board to the appropriate classification area. Fig. 13 shows the HMI interface indicating a successful detection of a good board during operation.

  1. Faulty ULN2003 board detection

  1. Faulty L298N board detection

  1. HMI interface displaying alarm state for faulty board detection
  1. Defect Detection Accuracy for Defect-Free Boards

Type

Total test runs

Correct Passes

False Alarms

Defective components

Accuracy

L298N

30

28

2

Led_smd
Res_smd

93.3%

ULN2003

20

18

2

Res

90%

Không có mô tả.

  1. HMI indicates the circuit is running correctly
  1. System Integration and Operational Efficiency

The complete integration of image processing, PLC control, and monitoring interfaces demonstrated:

The experimental results confirm that the integrated system meets design objectives for automated PCB inspection, providing reliable performance while offering opportunities for further enhancement in environmental robustness and detection accuracy. However, the system currently supports only two PCB types—expansion to more complex boards with diverse component layouts is needed for broader industrial adoption. Compared to manual inspection methods still prevalent in Vietnamese SMEs, the automated system improves inspection speed by 3–5 times and increases consistency by eliminating human fatigue factors.

The system’s accuracy decreases under non-ideal lighting conditions (reduction of 20–25% in low light) and extreme rotations (particularly at 90°). Future improvements will focus on three key areas: Enhanced robustness through data augmentation with synthetic images, implementation of multi-angle cameras, and adaptive lighting control systems; Extended functionality by expanding the component library to include SMD components, BGAs, and connectors; and advanced integration with an IoT-enabled database for long-term analytics, predictive maintenance, and cloud-based remote monitoring. These developments will transform the current prototype into a scalable solution suitable for medium-scale production environments.

  1. Conclusions

This paper presents the successful development of an integrated automated system for PCB inspection, defect analysis, and classification. The proposed solution combines state-of-the-art computer vision using YOLOv5, robust industrial control through a Siemens PLC, and a modern web-based interface to deliver a functional and cost-effective platform. Experimental results demonstrate that a fully integrated cyber-physical approach—combining machine vision, industrial automation, and data communication—can effectively address the quality inspection needs of resource-constrained settings. This work provides a replicable framework for developing cost-effective automation solutions in similar domains.

To further enhance the system's industrial applicability, several key directions are proposed: expanding the detection capabilities to include more PCB types and components; improving algorithmic robustness against varying lighting conditions and board orientations; implementing a database system for long-term data storage and advanced analytics; and integrating IoT capabilities for real-time remote monitoring and cloud-based management.

  1. Acknowledgment

This research was funded by Ho Chi Minh City University of Technology and Engineering (HCM-UTE), Vietnam, under grant No. SV2026-242. We want to give thanks to Ms. Eng. Tan-Doi Nguyen (HCM-UTE) due to his supervision and Ms. Eng. Thi-Thanh-Hoang Le (HCM-UTE) due to her help in editing this paper. We, authors, are grateful for this support. Link of operation of the system is: https://www.youtube.com/watch?si=23rcPtjhDPQaFMEa&v=O_OpxQO4KBY&feature=youtu.be.

References
  1. K. Patel, “AI-driven defect detection in PCB manufacturing: A computer vision approach using convolutional neural networks,” European Journal of Advances in Engineering and Technology, vol. 12, pp. 10–25, 2025, https://www.doi.org/10.5281/zenodo.15968580.
  2. W. LI, “Detecting defects in PCB manufacturing: an exploration using Yolov8 deep learning,” International Journal on Interactive Design and Manufacturing (IJIDeM), vol. 19, no. 5, pp. 3505–3515, 2025, https://www.doi.org/10.1007/s12008-024-01986-w.
  3. A. Roy et al., “Applications and Challenges of AI in PCB X-ray Inspection: A Comprehensive Study,” ACM Journal on Emerging Technologies in Computing Systems, vol. 21, no. 1, pp. 1–28, 2025, https://www.doi.org/10.1145/3703457.
  4. Y. Zhai, L. Wang, Y. Liu, T. Jiang, and H. Jiang, “The design of automatic carton packing system of tobacco based on STM32,” Journal of Physics: Conference Series, vol. 1948, no. 1, p. 012099, 2021, https://www.doi.org/10.1088/1742-6596/1948/1/012099.
  5. N. Hütten, M. Alves Gomes, F. Hölken, K. Andricevic, R. Meyes, and T. Meisen, “Deep Learning for Automated Visual Inspection in Manufacturing and Maintenance: A Survey of Open- Access Papers,” Applied System Innovation, vol. 7, no. 1, p. 11, 2024, https://www.doi.org/10.3390/asi7010011.
  1. J. Redmon, S. Divvala, R. Girshick, and A. Farhadi, “You Only Look Once: Unified, Real-Time Object Detection,” in 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), IEEE, pp. 779–788, 2016, https://www.doi.org/10.1109/CVPR.2016.91.
  2. M. Maślanka, D. Jancarczyk, and J. Rysinski, “Integration of Machine Vision and PLC-Based Control for Scalable Quality Inspection in Industry 4.0,” Sensors, vol. 25, no. 20, p. 6383, 2025, https://www.doi.org/10.3390/s25206383.
  3. S. Vasudevan et al., “Machine vision and robotics for primary food manipulation and packaging: A survey,” IEEE Access, vol. 12, pp. 152579–152613, 2024, https://www.doi.org/10.1109/ACCESS.2024.3479781.
  4. S. S. Zakaria, A. Amir, N. Yaakob, and S. Nazemi, “Automated detection of printed circuit boards (PCB) defects by using machine learning in electronic manufacturing: Current approaches,” in IOP Conference Series: Materials Science and Engineering, p. 12064, 2020, https://www.doi.org/10.1088/1757-899X/767/1/012064.
  5. A. S. Ozer and I. Cinar, “Real-Time and Fully Automated Robotic Stacking System with Deep Learning-Based Visual Perception,” Sensors, vol. 25, no. 22, p. 6960, 2025, https://www.doi.org/10.3390/s25226960.
  1. Z. Shen, S. Wang, J. Dou, and Z. Tu, “Design and implementation of PCB detection and classification system based on machine vision,” in Lecture Notes in Electrical Engineering, pp. 253–261, 2019, https://www.doi.org/10.1007/978-981-13-2375-1_32.
  2. M. B. Kiran, “Automated Inspection of PCB,” AIP Conference Proceedings, vol. 3108, no. 1, p. 30008, 2024, https://www.doi.org/10.1063/5.0208227.
  3. A. Mukhopadhyay, L. R. D. Murthy, M. Arora, A. Chakrabarti, I. Mukherjee, and P. Biswas, “PCB inspection in the context of smart manufacturing,” in Smart Innovation, Systems and Technologies, pp. 655–663, 2019, https://www.doi.org/10.1007/978-981-13-5974-3_57.
  4. Y. P. Wijaya, I. Swinarno, B. Prabowo, H. Subagiyo, A. Huda, and D. Syahbana, “Automated Printed Circuit Board Inspection System using NI Vision Builder and NI MyRio,” Journal of Electronics Technology Exploration, vol. 2, no. 2, pp. 58–64, 2025, https://www.doi.org/10.52465/joetex.v2i2.511.
  5. S. U. Rehman, K. F. Thang, and N. S. Lai, “Automated PCB identification and defect-detection system (APIDS),” International Journal of Electrical and Computer Engineering, vol. 9, no. 1, pp. 297–306, 2019, https://www.doi.org/10.11591/ijece.v9i1.pp297-306.
  1. B. Aranjo, P. K. Soori, and P. Talukder, “Stepper motor drives for robotic applications,” in 2012 IEEE International Power Engineering and Optimization Conference, IEEE, pp. 361–366, 2012, https://www.doi.org/10.1109/PEOCO.2012.6230890.
  2. H. K. Jung and G. S. Choi, “Improved YOLOv5: Efficient Object Detection Using Drone Images under Various Conditions,” Applied Sciences (Switzerland), vol. 12, no. 14, p. 7255, 2022, https://www.doi.org/10.3390/app12147255.
  3. Z. Liang, Z. Liang, Y. Zheng, B. Liang, and L. Zheng, “Data analysis and visualization platform design for batteries using flask-based python web service,” World Electric Vehicle Journal, vol. 12, no. 4, p. 187, 2021, https://www.doi.org/10.3390/wevj12040187.

Truong-Nguyen Phan, Development of an Automated PCB Inspection, Error Statistics, and Classification System