Share this

USB-based AOI vision inspection system for printed circuit boards

2026-04-06 07:24:42 · · #1
Abstract: This paper designs the hardware circuit and software program for an AOI system for printed circuit boards (PCBs), and completes the acquisition of PCB images. The designed system has been successfully applied to a PCB AOI visual inspection system. Keywords: Automatic optical inspection; PCB; USB; WMD driver Introduction With the increasing fineness of the conductor patterns on printed circuit boards (PCBs) used in surface mount technology (SMT), the miniaturization of SMT components, and the trend towards high-density and rapid assembly of SMT components, visual inspection or manual optical inspection is no longer adequate for detecting SMT assembly quality. Therefore, automatic optical inspection (AOI) technology, as the main technical means for SMT assembly quality inspection, is increasingly widely used in SMT. AOI, also known as automatic visual inspection, is based on optical principles and integrates image analysis, computer technology, and automatic control to detect and process defects encountered in production. It is a relatively new method for confirming manufacturing defects. The AOI system is technically divided into four main parts: precision mechanics, electrical control, vision system, and software system. Its core is a CMOS or CCD-based image acquisition system, an AC servo-controlled x and y stage, and an image processing software system. Figure 1 shows the block diagram of the designed PCB board AOI inspection system. [align=center] Figure 1 Block diagram of the PCB board AOI inspection system[/align] Hardware Design of the Vision Inspection System The AOI system is essentially a surface defect detection system based on machine vision technology. How to acquire high-quality PCB surface image information is the primary challenge and focus in PCB optical inspection, which is key to PCB surface defect detection. Due to the special characteristics of PCB defects, the AOI system places high demands on the vision acquisition system: high resolution, high speed, and real-time detection. Vision Acquisition System To meet the requirements of the AOI system, a DSP+CPLD-based image acquisition and processing mode is selected. Figure 2 shows the block diagram of the vision acquisition system. The system sends an acquisition command to the CPLD via the DSP. The CPLD controls the CMOS image sensor to write image data to the FIFO. Simultaneously, the DSP transfers the image to SDRAM via DMA and performs image processing. After processing, the result is transmitted to the microcomputer or other devices via the DSP's built-in USB interface. The I/O interface is expanded to pass control trigger signals to the workbench and electrical control system, completing the system's acquisition control purpose. [align=center] Figure 2 Visual Acquisition System Block Diagram[/align] USB Communication Interface Circuit The DSP chip TMS320VC5509A used in this design integrates a USB control module (USB 2.0 full speed), which can perform read and write operations with the USB host system. It has advantages such as requiring no external logic circuits and ease of use. Using the on-chip USB module of the TMS320VC5509A, the communication hardware circuit design between the DSP front-end image acquisition system and the back-end PC is completed, simplifying the hardware control software of the image acquisition system and the driver program of the back-end PC. [align=center]Figure 3 USB Interface Circuit of TMS320VC5509A[/align] Figure 3 shows the hardware interface circuit for data communication between the DSP's on-chip USB module and a PC. The three pins on the left, PU, ​​DP, and DN, are on-chip pins of the TMS320VC5509A. The six pins on the right form a Mini USB interface, allowing connection to a PC via a USB cable. The resistor-capacitor circuit in the middle enhances input/output reliability. Software Programming [align=center]Figure 4 USB Communication Data Flow in the Vision System[/align] As shown in Figure 4, the USB communication software program in this system mainly consists of four parts. On the device side: the device driver, also known as firmware; and the device application, which mainly handles data transfer and interaction with other hardware devices. On the host side: the host driver; and the host application. Because USB has a layered structure, the host driver and device driver enumerate and configure the USB device; while data communication is achieved between the host application and the device application. In this system, the DSP acts as the USB transmission device. Since USB operates on a strict master-slave architecture, all configuration, enumeration, and data transfer commands must be issued by the host. Therefore, the firmware on the device side is designed as a complex interrupt service routine to respond to the host's configuration and enumeration of the DSP as a USB device. The DSP acquisition main program, originally running in the CCS, must also be rewritten as an interrupt routine to integrate the DSP firmware and acquisition program into a single `main()` function. During program execution, the DSP is initialized, the clock is configured, and the USB module is initialized. When the host issues an image acquisition command, the DSP program enters the acquisition interrupt routine and executes the real-time acquisition interrupt routine. When the host issues a USB module configuration and enumeration command, the USB interrupt service routine responds to the host. When the host issues an image transfer command, the DSP program enters the data transfer interrupt routine. The structure of the DSP-side firmware and the USB firmware is generally based on interrupt handling. After completing the necessary initialization, the main program waits for a USB interrupt. Upon receiving a USB interrupt, it enters different interrupt service routines depending on the interrupt type. The master-slave mode of the USB protocol determines that the initiation and termination of transmission on the USB bus are controlled by the host. Therefore, as long as the host's requirements are met in firmware programming, or in other words, the host's requests are responded to in a timely manner, then the firmware programming is complete. Example of USB firmware application main function: void main() { EnableAPLL(); // Enable the analog phase-locked loop of the USB module CSL_init(); // DSP's CSL library initialization function INT_DisableGlobal(); // Disable global interrupts INT_SetVec(0x03ff00); // Set the address of the interrupt vector table in RAM PLL_Init(48); // Adjust the clock of the USB module to 48MHz Collect_main(); // CMOS image acquisition program USBTest_Init(); // Initialize the USB module, and enable global interrupts after initialization while(1); // Loop wait state} The control transmission of endpoint 0 is the default transmission port of USB enumeration, and its interrupt service routine is the difficulty and key point of USB firmware program design. The design of PC-side drivers and host computer applications is relatively simple. The USB driver is developed using the Driver Studio development tool. Driver Studio encapsulates the operations in the device driver development tool DDK, reducing development time and improving efficiency. The driver generated by the Driver wizard tool in Driver Studio provides a basic framework for developers. Users only need to modify a small amount of code or hardly any code to achieve the corresponding functions. In Windows XP, host computer programs cannot directly access the underlying hardware and need to perform operations (read, write, interrupt, etc.) through the driver. The device driver is managed and invoked by the I/O manager. In user mode, the host computer program calls Win32 API functions through the Win32 subsystem. The Win32 API functions pass IRPs to the driver in kernel mode through the I/O manager. The driver completes the interaction between the application and hardware program information by processing the IRPs. Win32 API functions for accessing USB device drivers: (1) The CreatFile function creates or opens a file and returns a handle that can be used to access the file. (2) The DeviceIoControl function directly sends control codes to the specified device driver, causing the corresponding device to perform the specified operation. If the function succeeds, it returns a non-zero value; otherwise, it returns 0. (3) The ReadFile function reads data from the file starting at the position indicated by the file pointer. After the read operation is completed, the file pointer is adjusted to the number of bytes actually read. If the function succeeds, it returns a non-zero value; otherwise, it returns 0. (4) The CloseHandle function closes the opened file handle. If the function succeeds, it returns a non-zero value; otherwise, it returns 0. Experiment and Conclusion The author designed and implemented a printed circuit board AOI visual inspection system, including hardware circuits and software programs. The hardware structure is simple, and it can achieve a high degree of integration of communication transmission. The transmission rate meets the real-time requirements of the AOI inspection system. Figure 5 shows the PCB board image acquired in the experiment. [align=center]Figure 5. PCB board image acquired in the experiment[/align] References: 1. Jia Jianlu et al., Embedded Vision Sensor Based on Ethernet, Electronic Products World, 2008.3 2. Moti Yanuka, Yossi Pinhassi, AOI vs. AFI in PCB Defect Detection, Circuitree, July 2001 3. TMS320VC5509 DSP Universal Serial Bus (USB) Module Reference Guide, Texas Instruments Incorporated 4. TMS320C55x CSL USB Programmer's Reference Guide, Texas Instruments Incorporated 5. Wu Anhe, Tai Ming, Yu Hongtao, Windows 2000/XP WDM Device Driver Development, Electronic Industry Press, 2004
Read next

CATDOLL 133CM Ya Shota Doll (Customer Photos)

Height: 133cm Male Weight: 28kg Shoulder Width: 31cm Bust/Waist/Hip: 64/59/73cm Oral Depth: 3-5cm Vaginal Depth: N/A An...

Articles 2026-02-22