Share this

USB-based intelligent photoresistor detection device

2026-04-06 06:47:06 · · #1
Abstract: This paper analyzes the current status of the testing and grading process in the production of photoresistors. Addressing the problems of low accuracy, poor consistency, and low production efficiency caused by the current reliance on manual grading, a novel intelligent photoresistor detection device based on USB bus interface technology is developed. In terms of hardware design, an AT89C52 microcontroller controls a 12-bit high-speed A/D converter AD574 to acquire data on parameters such as the bright resistance and dark resistance of eight tested photoresistors. The sampled data is sent to a host computer via a USB data transmission module composed of a PDIUSBD12 chip. In terms of software design, the Philips USB51S function library is used in the USB interface microcontroller program to interpret the USB data transmission protocol. A driver program was developed using the Windows DDK. The host computer application is designed using the EasyD12 library provided by PHILIPS and Visual Basic 2005. Keywords: photoresistor, testing and grading, light intensity, USB, dynamic link library 1 Introduction Testing and grading is an important process in the later stages of photoresistor production. Because different application areas have different requirements for photoresistor parameters such as light resistance, dark resistance, and gamma value, manufacturers must be able to accurately provide these parameter values ​​for their products to meet specific user requirements. Manufacturers classify their photoresistors according to the user's requirements for light resistance, dark resistance, and gamma value; this is photoresistor testing and grading. Currently, domestic manufacturers primarily rely on manual operation for testing and grading. The drawbacks of this are obvious: the light intensity of the light source cannot be accurately controlled, manual grading is slow, manual readings introduce significant errors, and test data can only be manually recorded and saved, which greatly affects the accuracy of grading and product consistency. This paper utilizes the powerful data processing and storage capabilities of computers and employs the high data transfer rate and ease of use of the USB bus to research and design an intelligent detection device for photoresistor testing and grading. This fundamentally solves a series of problems associated with manual grading, such as controlling the light intensity of the light source, errors introduced by manual readings, and the storage of test results. 2. Hardware Design of the Intelligent Photoresistor Detection Device The development of the intelligent photoresistor detection device involves several major parts, including light source design, automatic measurement of resistance over a wide range, data acquisition and processing, USB serial data transmission between the microcontroller and the computer, and display and control of the graded signals. The overall design block diagram is shown in Figure 1. The AD574 acquisition module, under the control of commands from the PC, acquires parameters such as the bright resistance and dark resistance of eight photoresistors. The acquired data is transmitted to the PC via the USB data transmission interface module. The computer performs subsequent parameter processing, calculates the γ value of the corresponding photoresistor, and then the graded display program determines the grade of the photoresistor based on the bright and dark resistance and the γ value. Finally, the graded display circuit displays the graded information. [align=center]Figure 1 Overall Block Diagram of Intelligent Photoresistor Detection Device[/align] 2.1 Data Acquisition Module The data acquisition module consists of a microcontroller AT89C52, a latch 74LS373, an A/D chip AD574, an 8-channel analog switch CD4051, a photoresistor testing circuit, and an IDC26 interface (CN6) for communication with the USB data transmission interface module. The AD574 is a 12-bit high-speed successive approximation analog-to-digital converter manufactured by Analog Devices (ADI). It has an on-chip clock reference source and can independently complete the A/D conversion function without external components. Its conversion time is 15–35 μs, and its conversion accuracy is 0.05%. It can output 12 bits in parallel or in two separate outputs of 8 bits and 4 bits. Digital values ​​can be directly input using bipolar analog signals. The power supply is ±15V, and the logic power supply is +5V. It is widely used in data acquisition systems. The system hardware design mainly considers the connection of three buses (control bus, address bus, and data bus). Because the AD574 output has a tri-state buffer, it can directly interface with the microcomputer's bus without the need for additional logic interface circuitry. The AD574 has an on-chip clock, so no external clock signal is required. This circuit uses a unipolar input method and can convert 0-10V or 0-20V analog signals; this device uses a 0-10V input. The high 8 bits of the conversion result are output from DB11 to DB4, and the low 4 bits are output from DB3 to DB0, directly connected to the microcontroller's data bus. In the photoresistor testing circuit, the analog switch 4051 corresponds to 8 inputs, allowing for the testing of 8 photoresistors at once. According to the circuit hardware connection, the 8 input addresses are 0xff18, 0xff19, 0xff1a, 0xff1b, 0xff1c, 0xff1d, 0xff1e, and 0xff1f. Calling the sampling function ad574() once tests all 8 photoresistors. The light intensity adjustment in the test system is controlled by P1.1, P1.2 and P1.3 of the microcontroller. P1.1, P1.2 and P1.3 control light sources of 100lx, 10lx and 0lx respectively. P1.4 is connected to the input terminal WDI of the watchdog circuit and continuously outputs pulse signals to feed the watchdog. 2.2 Data acquisition module USB communication between microcontroller and computer This system adopts a USB data transmission interface module based on PDIUSBD12 interface chip [1,2]. The USB data transmission interface module used to connect the data acquisition module and PC computer is extremely important in the whole system and is also the focus and difficulty of the system design. Here, a general USB data transmission interface module is developed. The module mainly consists of three parts. (1) USB bus interface part, including Class B USB connector socket and PDIUSBD12 interface chip. (2) Microprocessor and logic control part, including AT89C52 microcontroller and logic control circuit. (3) Dual-port data storage area, including dual-port RAM chip CY7C136 and an 8-bit parallel data interface socket CN3 packaged in IDC26. The external interrupt INT0 of the AT89C52 microcontroller is used for the interrupt request of the USB interface chip PDIUSBD12, and the external interrupt INT1 is used for the left mailbox interrupt request of the dual-port RAM chip CY7C136, to complete the uploading of the data collected by the microcontroller of the data acquisition module. 3 Software design of intelligent photoresistor detection device 3.1 Development of lower-level program The microcontroller programs of the data acquisition module and the USB interface are both written in C language [3], which increases the portability of the program. After receiving the corresponding command through the USB communication module, the data acquisition module calls the data acquisition program by adjusting the light intensity, and then uploads the acquisition results to the PC computer for further processing through the USB communication module. The lower-level machine can also display the grade information of the photoresistor under test through the keyboard display circuit, thereby realizing the intelligent detection of the photoresistor. The following is a partial code snippet of the data acquisition program: `unint ad574(uchar idata *x) // A/D sampling function in pointer to sampled result { uchar i; uchar xdata *ad_adr; ad_adr=&ADCOM0; adhi=&ADHI0; adlo=&ADLO0; r=0; // Generate CE=1 w=0; for (i=0;i<8;i++) { *ad_adr=0; // Start conversion while (adbusy==1); x[2*i]=adhi>>4; // Store high-order bits of conversion result x[2*i+1]=((adhi<<4)+(adlo&0x0f)); // Store low-order bits of conversion result ad_adr++; adhi++; adlo++; } }` 3.2 Driver Development The structure of a USB device driver is basically the same as other types of device drivers, including initialization, device creation, device unloading and deletion, plug-and-play processing, dispatch routine processing, power management, WMI, etc. The main routines of the driver are as follows: (1) DriverEntry, which performs two tasks: copying registry entries to a global variable; and telling the system which IRPs are handled by which routine. (2) DataClt_AddDevice, the driver initialization routine. (3) DataClt_DispatchPnp, the plug-and-play routine. (4) DataClt_DispatchPower, the power management routine. (5) DataClt_DispatchReadWrite, the data read/write routine. (6) DataClt_CallUSBD, the URB submission routine. 3.3 Development of the Host Application The host application is written in the Microsoft Visual Basic 2005 environment. The host application uses EasyD12.dll API functions. The detection interface in the intelligent photoresistor detection application is shown in Figure 2. The testing interface includes commands for measuring the resistance of photoresistors under 100lx, 10lx, and 0lx illumination, calculating the γ value of the photoresistor, and classifying the photoresistors into different grades. After testing each group of 8 resistors, clicking "Save Results" saves the results to the database; clicking "Send Results to Sorting Circuit" displays the grade the photoresistor should belong to; once the next group of photoresistors is ready, clicking "Test Next Group" continues testing; the testing information for previously tested photoresistors can be viewed at any time by clicking "View Testing Records" in the database. The program classifies photoresistors into 26 grades, including a "Reject" grade. Adjustments can be made as needed in practical applications. In the program, the PC sends commands to the lower-level machine through endpoint 1 of D12. The correctness of the command transmission is ensured by calculating a checksum. Then, the returned detection result data is obtained through read port 2. The length of the read data can be changed by assigning a value to the received data length variable nLen. Since this program only detects 8 photoresistors at a time, and each resistor's sample value is 12 bits (occupying 2 bytes), setting nLen = 16 is sufficient. The program is versatile and can read sample data of arbitrary length. Because the buffer of endpoint 2 of D12 is only 64 bytes, it needs to receive 64 data points per frame and read multiple times (nFrameLen = 64), finally reading a remaining frame less than 64 bytes. The intelligent photoresistor detection database interface is shown in Figure 3. The designed fields include: resistance value at 100 lx, resistance value at 10 lx, resistance value at 0 lx, g-value, classification, and test time. The application connects to the SQL Server database through the aforementioned controls. Each press of the "Save Result" button in the "Detection Interface" appends the detection result to the database, which is then dynamically displayed in the intelligent photoresistor detection database interface. In the database interface, corresponding command buttons allow users to view production indicators for a specific period, such as pass rate, scrap rate, and the quantity of products in a particular grade. [align=center] Figure 2 Detection Interface[/align] 4 Conclusion The hardware of the USB-based intelligent photoresistor detection device includes a data acquisition module responsible for data collection, a USB interface communication module responsible for transmitting sampling data, upper computer commands, and final grade information, and a PC upper computer responsible for processing sampling data and storing detection results. The software includes the upper computer command analysis program, sampling program, and data transmission program with the USB interface module in the data acquisition module; the USB firmware program and data transmission program communicating with the data acquisition module in the USB interface module; and the application software design on the computer side. The entire device adopts advanced USB bus technology, achieving a high data transmission rate and ensuring high reliability. Figure 3 Intelligent photoresistor detection database interface References: [1] Philips Semiconductors Company. PDIUSBD12 Data Sheet Philips Semiconductors[DB/OL]. http://www.semiconductors.philips.com/pip/PDIUSBD12D.html, 2001-08 [2] Wan Lifeng, Xu Xiaojie, Hu Huipu, Zhang Yehui. Design of USB data acquisition system based on PDIUSBD12[J] Microcomputer Information 2006, 22 No. 5-1: 110-112 [3] Ma Zhongmei, Ji Shunxin, Zhang Kai. Single-chip microcomputer C language application design[M]. Beijing: Beijing University of Aeronautics and Astronautics Press, 2003
Read next

CATDOLL CATDOLL 115CM Shota Doll Kiki Male Doll (Customer Photos)

Height: 115cm Male Weight: 19.5kg Shoulder Width: 29cm Bust/Waist/Hip: 57/53/64cm Oral Depth: 3-5cm Vaginal Depth: N/A ...

Articles 2026-02-22