Share this

LabVIEW-based Virtual Instrument Interface Control for Electricity Meter Calibration

2026-04-06 04:46:40 · · #1
Abstract: This paper describes the development of ammeter visual instrument software using the LabVIEW virtual instrument design tool. Through practical application examples of signal measurement sampling control and database management, it specifically discusses the technology and methods of connecting and controlling the self-designed microcomputer hardware and software interfaces. Keywords: LabVIEW, Visual Instrument, Ammeter Test 1. Introduction Visual Instrument (VI, Virtual Instrument) is a system of instruments that uses the powerful hardware and software resources of a computer as support, employs high-performance modular hardware, and combines efficient and flexible software to perform various tests, measurements, and automation applications. Traditional electronic instruments are self-contained systems, belonging to dedicated equipment, which is inconvenient for users to change or expand the instrument's functions as needed. However, the functions of VI can be defined by the user and can be quickly upgraded according to user needs. Traditional electricity meter calibration instruments are dedicated, expensive, and bulky equipment, while this system is built on a small PXI industrial control computer platform, resulting in a compact structure. The software design of this calibration system is implemented under Windows, mainly comprising three layers: the low-level hardware driver, which, based on the hardware characteristics and the device management features of the Windows operating system, uses DLL files to directly drive the hardware; the middle layer, which uses DLL files to create the interface between the application program and the driver program, allowing the application program to control and operate the hardware; and the high-level user application, which performs human-computer interaction, calls function subroutines, passes parameters, and completes relevant data processing. Using LabVIEW (Laborary Virtual Instrument Engineering Workbench) to design the virtual instrument's user application is currently the preferred method. In the electricity meter calibration system designed using virtual instrument technology, due to the special requirements of the measurement function, the microcomputer's electricity measuring instrument card is custom-designed, and the database is also designed according to user requirements. Therefore, developing a virtual instrument using LabVIEW presents the challenge of how to use LabVIEW to control the hardware and manage the database, which are the primary issues that must be addressed in the design. 2. LabVIEW Hardware Control of the Power Measurement Card 2.1 Basic Structure of LabVIEW Hardware Control LabVIEW's hardware control of the self-designed power measurement card is mainly achieved by calling dynamic link libraries (DLLs). For various data acquisition cards manufactured and sold by NI, corresponding device drivers are provided. After installation, these drivers can be directly called by LabVIEW's VI functions, facilitating user use and control of the data acquisition card. For the self-designed power measurement card in this system, a driver program must be designed and created as a DLL file. The functions in the DLL are then called using LabVIEW's Call Library Function Node to control the hardware. The basic structure of the LabVIEW hardware control driver program for the measurement card is shown in Figure 1. [align=center] Figure 1 LabVIEW Hardware Control Structure[/align] In the figure, the underlying hardware interface driver is a dedicated driver program for the hardware interface, which can be called by the application layer driver to directly control the hardware. The application layer driver is the control interface for the user application program, and is a dynamic link library file that can be called using LabVIEW's Call Library Function Node. The node is in the Advanced sub-template, and its configuration is relatively simple. Just open the corresponding dynamic link library file, select the function to be called, and add appropriate parameters. For details, please refer to reference [1]. 2.2 LabVIEW Power Measurement Control Flow The power measurement card can measure the three-phase AC voltage and current. The measurement process is controlled by the DSP on the card. The measured data is stored in the dual-port RAM on the card. The user program written in LabVIEW on the microcomputer exchanges information with the power measurement card through the dual-port RAM, transmits control signals, and reads the measurement data. The system has different requirements for the processing and analysis of measurement signals. Here, we only use the LabVIEW control program flow of phase A voltage measurement in Figure 2 to explain the measurement control. [align=center] Phase A Voltage Measurement Control Program[/align] As can be seen from the code block diagram of the program, as long as the LabVIEW program obtains different data from the dual-port RAM, it can use the various controls and functions provided by LabVIEW to perform different analyses, calculations, processing and displays on the data. The different data is determined by the starting address position and the number of data stored in the dual-port RAM. When the system operates in measurement and control mode, the Call Library Function Node is executed in the loop program. This node, based on the program-defined "starting position" and "number of acquisition points," calls the READRAM function in the application-layer driver DLL to read a continuous number of measurement data points from a specified location in the dual-port RAM (determined by the starting position). This data, combined with the acquisition time interval, forms the actual acquired waveform, which is then provided to subsequent programs for analysis and processing. Taking the measurement and display of phase A voltage waveform as an example, the measurement card, according to the system design, places the amplitude, frequency, and phase values ​​of the measured voltage in a continuous cell of the dual-port RAM. The user only needs to select phase A voltage measurement in the program, and the LabVIEW program, through the Call Library Function Node, reads the amplitude, frequency, and phase data measured in real time from the corresponding cell of the dual-port RAM. Using these three basic data points, and by calling the powerful functions provided by LabVIEW, the measured signal can be easily displayed, analyzed, and processed. Of course, this example only uses data reading to illustrate LabVIEW's control over hardware. In practical applications, DLLs are also needed to handle hardware reset, initialization, and other functions such as gear selection, function selection, and data acquisition startup. Furthermore, the entire program structure is not only related to the data acquisition card's operation but also closely tied to the data acquisition control process required by the measured signal, necessitating specific handling. 3. LabVIEW Implementation of Meter Verification Database Management LabVIEW interfaces with databases in several ways: first, by purchasing the LabVIEW SQL Toolkit database interface module from NI; second, by using a third-party database interface module, LabSQL; third, by accessing the database through a Dynamic Link Library (DLL), first writing the DLL in another programming language such as Visual C++, and then using LabVIEW's Calling Library Function Node (CLFN) to call the relevant functions in this DLL to access the database; and fourth, by using Dynamic Data Exchange (DDE) to implement database access operations. This system uses the free third-party LabSQL to implement various database operations, which is lower in cost than method one and simpler and easier to use than methods three and four. 3.1 Basic Structure of LabVIEW Database Management The basic structure of LabVIEW database management is shown in Figure 3. LabSQL1.1A is a multi-database, cross-platform LabVIEW database access toolkit (free download website: http://jeffreytravis.com). It supports any ODBC-based database in the Windows operating system, uses ADO and SQL language to complete database access, and provides a series of LabSQL VIs for database access. By calling the sub-functions of different functions and supplementing with simple SQL programming, various operations such as accessing, querying, modifying, and statistically analyzing the database can be performed. Before use, LabSQL must be installed and configured correctly. The method can be found in the references of this article [1]. [align=center]Figure 3 Basic Structure of LabVIEW Database Management[/align] LabSQL VIs can be divided into four categories according to their functions: Command VIs are used to complete a series of basic ADO operations; Connection VIs manage the connection between LabVIEW and the database; Recordset VIs are used to perform various operations on records in the database; Top Level VIs belong to the top-level LabSQL application and encapsulate some functions of the first three types of LabSQL VIs. For example, SQL Execute.VIs can be used to directly execute SQL commands. The meter calibration database is used to store relevant data for meter calibration. It is stored independently so that the system can manage historical data and expand its management functions. The system uses ACCESS to establish the meter calibration database. According to the needs of data management, the database mainly includes the calibrator table (stores calibrator information), the meter being calibrated table (stores the conclusion data of the calibrated meter), the amplitude table (stores the amplitude measurement record of the calibrated meter), the frequency table (stores the frequency measurement record of the calibrated meter), the power factor table (stores the power factor measurement record of the calibrated meter), and the harmonic analysis table (stores the harmonic analysis result data table). 3.2 Basic Steps for Database Operations Using LabSQL LabSQL enables data transfer between the application and the database during database operations. The general operation steps are shown in Figure 4. First, create an empty connection object using ADO Connection Create.vi, then open the specified database using ADO Connection Open.vi; next, create an empty recordset object using ADO Recordset Create.vi, and then open the dataset object in the specified table using ADO Recordset Open.vi. Following this, call the vi for adding, modifying, and deleting data to perform the specified operations on the dataset. After completing the operations, disconnect the recordset using ADO Recordset Close.vi, and finally close the database using ADO Connection Close.vi. The various vis for database operations in LabSQL are obtained from Functions Palette → ALL Function → User Libraries → LabSQL → LabSQL ADO Function. [align=center] Figure 4 Basic Steps for Database Operations[/align] 3.3 Meter Verification Database Management Program The program code flowchart for the system database management is shown in Figure 5. In the program, users select the data table to be operated on using the "Tab Control" tab on the front panel. In the main loop, the program waits for user input. When the user presses operation buttons such as "Query," "Delete," "Add," or "Update," the program executes the corresponding operation on the selected data table. In the CASE structure on the right, the content of the code block diagram and the objects being operated on change according to the selected data table and the "operation button," thus realizing the data management function for different data tables. These functions are all completed by calling the corresponding VIs in LabSQL 1.1A. The basic operation process is shown in Figure 4 above. The operation shown in Figure 5 indicates that a query operation is currently being performed on the checker table, and the queried records will be displayed on the front panel screen for the user to browse. 4. Conclusion The virtual instrument developed using LabVIEW has a user-friendly and aesthetically pleasing interface, and its code structure is clear and easy to read. Properly managing the hardware and software interfaces of LabVIEW for virtual instruments is crucial for fully leveraging LabVIEW's capabilities. Based on this, it's possible to flexibly and fully utilize the numerous practical software tools and powerful signal processing capabilities of general-purpose computers, as well as various plug-in "instruments," to achieve signal measurement, calculation, analysis, processing, graphical or digital display, data management, and output control. This overcomes the limitations of traditional instruments in data processing, display, transmission, and storage, and combines measurement control with information management. As a product of the integration of computer technology and instrument measurement technology, Virtual Instruments (VIs) will undoubtedly play an increasingly important role in many industries in the future. The innovation of this paper lies in applying virtual instrument technology to electricity meter testing equipment. It details the LabVIEW control methods for self-designed hardware interfaces and database access operations. This method is practical and has certain reference value. References [1] Yang Leping, Li Haitao, et al. Advanced LabVIEW Programming. Beijing: Tsinghua University Press. 2004 [2] Yang Leping, Li Haitao, et al. LabVIEW Programming and Application. Beijing: University of Electronic Industry Press. 2001 [3] Wang Minsheng, et al. LabVIEW Basic Tutorial. Beijing: Electronic Industry Press. 2002 [4] Gary W Johnson, Richard Jennings. Translated by Wu Jia and Lu Jinkun. LabVIEW Graphical Programming. Beijing: Peking University Press. 2002 [5] Song Zhijun. Automatic Testing System for Welding Machine Based on LabVIEW and PXI Platform. Industrial Control. 2004.9 [6] Bi Hu, Lü Fangcheng, Li Yanqing, Li Heming. Several Different Methods of Accessing Databases in LabVIEW. Microcomputer Information, 2006, 1-1:131-134
Read next

CATDOLL Maria Hard Silicone Head

The head made from hard silicone does not have a usable oral cavity. You can choose the skin tone, eye color, and wig, ...

Articles 2026-02-22