Automatic monitoring program for pointer instruments based on LabVIEW and Matlab
2026-04-06 05:47:01··#1
Abstract: The image processing function of a point-like meter is analyzed using a camera and the Matlab image manipulation module. The point value is calculated and transferred in LabVIEW virtual instrument programming software using DLL technology. The program achieves the auto-surveillance function of the point-like meter and greatly increases the steadiness and robustness of the whole system. Key Words:Data Acquisition; LabVIEW; Matlab; image manipulation I. Introduction With the advancement of technology, instruments are becoming more and more advanced. General data acquisition instruments or acquisition cards generally come with interfaces to computers, such as the GPIB interface of network analyzers and spectrum analyzers, the RS232 port of general acquisition cards, and USB interfaces, etc. However, some older devices, especially pointer-type instruments, lack interfaces and therefore cannot communicate with computers, requiring manual reading of meter values, which severely impacts the efficiency of the entire system. Camera monitoring technology is widely used and can also be applied to experimental monitoring systems. Many image processing methods exist, generally employing the powerful image processing software Matlab to effectively remove interference data and then analyze the pointer data to obtain the current pointer reading. The virtual instrument display uses LabVIEW software, employing a table or display instrument corresponding to the pointer instrument to display the current pointer value. II. Program Design and Flow First, utilizing the dynamic link library file in the camera's built-in driver, such as AVICAP32.dll, along with the WIN API, or after correctly installing the camera driver, calling its control in LabVIEW allows for correct camera usage. To store images, a SendMessage command is first sent to the control, and then Clipboard's getdata method is used to read the image. Secondly, after obtaining the current image, preprocessing is performed using image processing functions in Matlab. Because instrument structures and environments differ, the processing methods and function parameters also vary. Generally, experimental testing is used to obtain a black and white image with minimal error. Commonly used image processing functions in Matlab include imread, imwrite, im2bw, and RGB2GRAY. The imread function reads the image into a three-dimensional array; the first two data points represent coordinates, and the last set represents the color of the current point. im2bw converts the image data to black and white, turning it into a two-dimensional array. The input parameter is Level, which represents the sensitivity to the image; different values of Level result in different black and white images. The most crucial aspect of data processing is determining the pointer's position. The function below finds the pointer line and automatically adds any missing data points during image data conversion. for m=1:FindLineNumber-1 Linesize=size(find(FindLine(m,:,1)>0)); if Linesize(2)>=Ly-j % No data before tempi=FindLine(m,Ly-j,1); tempj=FindLine(m,Ly-j,2); if tempi>1 & tempi if BW(tempi,j)==0% Data found FindLine(m,Ly-j+1,1)=tempi; FindLine(m,Ly-j+1,2)=j; InLine=1; end % Similarly, check other points around it if InLine==0 % Indicates no data found, check the next point NextL=find(BW(tempi-2:tempi+2,j-1)==0); if isempty(NextL)==0 %Addressing the shortcomings FindLine(m,Ly-j+1,1)=tempi-2+NextL(1); FindLine(m,Ly-j+1,2)=j; end end end end [align=center] Figure 1. Original graphic and converted graphics after taking Level 0.71, 0.72, 0.73, 0.74, 0.75, 0.76, 0.77, 0.78, 0.79[/align] For each pointer instrument, if the scale is uneven or the image is taken at a certain angle, the data must be calibrated before processing so that the pointer data read can be correctly converted into numerical values. The processing of instrument images is generally divided into three steps: first, preprocessing and putting the image into the image data array; second, calibrating the scale value, solving the similarity to obtain the instrument digital scale value, and connecting it with the coordinate point and storing it in the calibration array; third, analyzing and obtaining the pointer position to get the coordinate value of the current pointer. IV. Obtain the current measurement value from the pointer coordinates and the previously calibrated scale values. Due to lighting or other reasons, the pointer position may not be within the calibrated coordinate range. In this case, the pointer needs to be extended to obtain the intersection points with each calibrated scale to determine the measurement value. Alternatively, the pointer coordinates can be fitted with a polynomial to obtain a univariate polynomial equation, the simplest being a linear equation. This equation is then combined with the equations for each scale coordinate interval to solve. When there is an intersection point within the scale coordinate range, it indicates that the measurement value is within this range. The instrument's measurement value is then obtained through linear interpolation or polynomial fitting. After obtaining the measurement value, it can be displayed using the virtual instrument header in the LabVIEW panel, maintaining synchronization with other measuring instruments and using the measurement value to determine the overall system's operating status. III. System Testing and Results The experimental instrument used was a barometer from a vacuum device, as instruments constitute a significant part of these systems. A camera was clipped next to the instrument and connected to the computer via USB to capture images. Figure 2 shows the actual instrument image. Image processing was performed using a dynamic link library file generated by Matlab, as shown in Figure 1. Find the current pointer position and determine the measured value from the coordinates. Input the measured value into the virtual instrument in the LabVIEW control panel, as shown in Figure 3. The actual human reading value is 6.5, and the calculated value is 6.5429. [align=center] Figure 2. Original Instrument Graphics Figure 3. Virtual Instrument and Calculated Value in the Measurement System[/align] Finally, save the measurement data from the instrument or other instruments. In LabVIEW, data can be easily stored in text documents or various databases. Real-time data collected during the experiment can also be published to websites, servers, or clients via protocols such as TCP or controls such as DataSocket. IV. Conclusion The innovation of this paper is that it utilizes an inexpensive camera and its driver, performs image processing and analysis using Matlab, and then re-displays the measured data in the virtual instrument programming software LabVIEW. Finally, the data can be published or stored in a database via LabVIEW's DataSocket or TCP/IP protocols. The paper employs a hybrid programming technology of LabVIEW and Matlab, enabling joint acquisition and control with other instruments in LabVIEW while leveraging Matlab's powerful image processing capabilities to ensure the effectiveness of the program. This system not only monitors older instruments but also collaborates with other instruments to collect data, automatically records instrument data values during measurement, and judges the system status in real time, issuing alarms when necessary. This ensures the stability and reliability of the entire testing system. References: Bi Hu, Lü Fangcheng, Li Yanqing, Li Heming. Several different methods for accessing databases in LabVIEW. Microcomputer Information, 2006, 1-1: 131-134. Wu Miao, Xu Jiangning, Miao Xiuhua, Ji Bing. Research on device driver development technology based on LabVIEW. Microcomputer Information, 2006, 2-1: 153-155. Mao Jiandong. Design of a single-chip microcomputer data acquisition system based on LabVIEW. Microcomputer Information, 2006, 3-2: 41-42. Zhou Weilin, Li Qingfeng, Yang Huayong. Driver for AC1077 data acquisition card based on LabVIEW. Microcomputer Information, 2006, 1-1: 121-123.