Share this

Development of GPIB bus virtual instruments in LabVIEW environment

2026-04-06 04:32:07 · · #1
Abstract: LabVIEW is the most popular virtual instrument development platform today. This paper introduces the entire process of developing a GPIB bus-based virtual instrument using LabVIEW, along with its hardware and software requirements, and provides a development example. The example demonstrates the secondary development of a magnetic measuring instrument with a GPIB interface using the LabVIEW virtual instrument development platform to build a custom virtual instrument. Compared to a desktop instrument, the most prominent advantage of this virtual instrument is that it can complete real-time magnetic field acquisition and measurement without the need for additional data acquisition cards, and save the acquisition results to a file for subsequent analysis, thus greatly expanding the functionality of the original desktop instrument. Keywords: LabVIEW, GPIB, Real-time acquisition Introduction Data acquisition, instrument control, and automated testing are common practical tasks encountered in laboratory research. The emergence of LabVIEW allows ordinary laboratory workers to build their own measurement and control systems in a relatively short time. LabVIEW uses a graphical programming language, abandoning the traditional text-based programming method, making program development simple and intuitive, and greatly reducing development time. Although existing test and measurement instruments can provide a high degree of automation in measurement operations, they sometimes still cannot meet the needs of actual measurements. This is because actual measurement requirements often change depending on the measurement environment and purpose, while the functions of benchtop instruments are generally fixed. For example, some benchtop instruments can measure certain physical quantities in real time, but they cannot record the data of the entire test process; the instrument itself is merely a physical quantity indicator. To achieve real-time measurement analysis and record the measurement results, additional work is required. One method is to use the instrument's own analog output interface, paired with a data acquisition card, to acquire the analog output signal and perform corresponding subsequent analysis and processing. Another method is to use the instrument's own programming interface to achieve this through programming. Compared to the first method, the second method does not require additional hardware, making the test system simpler and more convenient. GPIB (General Purpose Interface Bus) is a standard interface between instruments and various controllers (most commonly computers), and many instruments have this interface. In terms of programming languages, LabVIEW's powerful and flexible instrument control capabilities make it the preferred programming language for developing virtual instruments. Furthermore, virtual instruments developed using LabVIEW have excellent visual effects, with user interfaces comparable to the control panels of actual instruments. This article introduces the general steps for developing a virtual instrument based on the GPIB interface using LabVIEW and provides a practical development example. Hardware Description of GPIB Bus Virtual Instruments : The GPIB interface is an 8-bit digital parallel communication interface with a data transmission speed of 1 Mbyte/s. GPIB devices are divided into listeners, talkers, and controllers. Talkers are responsible for sending messages (data or commands), listeners are responsible for receiving messages (data or commands), and controllers (usually a computer) are responsible for managing messages on the bus, specifying communication connections, and sending GPIB commands to designated devices. Some GPIB devices can play different roles at different times, sometimes acting as talkers, sometimes as listeners, and sometimes as controllers. The advantage of the GPIB interface is that multiple GPIB devices can be connected together through a single interface to simultaneously perform measurements of various physical quantities. GPIB has 31 base addresses. To achieve higher data transfer speeds, more than 15 devices are typically connected, which is sufficient for most measurements. Developing a GPIB-based virtual instrument generally requires the following hardware: a computer, a test instrument with a GPIB interface, a GPIB interface card, and GPIB cables. The type and number of test instruments depend on the specific testing requirements, and each instrument must also have compatible sensors. The GPIB interface card is primarily used to connect the instrument to the computer, and GPIB interfaces are connected via GPIB cables. Software Requirements for GPIB Bus Virtual Instruments Developing a GPIB-based virtual instrument using LabVIEW includes: the LabVIEW development platform, a GPIB interface card driver, and a LabVIEW driver for the instrument (not mandatory). Having a LabVIEW driver for the instrument makes creating a virtual instrument much easier. The LabVIEW driver handles the instrument's communication and control processes, encapsulating complex instrument programming details and providing a simple function interface for users. Users do not need specialized knowledge of the instrument hardware to use these instruments through the driver. Figure 1 shows a schematic diagram of a GPIB-based virtual instrument structure. Figure 1. Schematic diagram of a virtual instrument based on the GPIB bus. Development example. This section introduces the entire process of developing a virtual instrument based on the GPIB bus using LabVIEW, using a development example. The example involves secondary development of an existing magnetic measuring instrument with a GPIB interface, creating a virtual magnetic measuring instrument capable of real-time magnetic field acquisition and measurement, and saving the acquisition results to a file for subsequent analysis. The GPIB interface instrument in the example is a magnetic measuring instrument manufactured by Lake Shore Cryotronics, USA. It can measure DC and AC magnetic fields, with an AC frequency range of 10–400 Hz. The measurement range depends on the Hall probe, reaching a maximum of 30 T. It has one input channel, two analog output channels (one for correction output and one for direct output), and provides two programming interfaces: GPIB and serial. The GPIB interface has a read rate of 18 times per second, and the serial interface has a read rate of 15 times per second. This instrument can easily measure various magnetic fields, but it cannot save the measured data and only has some very basic analysis functions such as maximum value and relative value. The GPIB interface card is the GPIB-PCIIPIIA manufactured by National Instruments. This card only supports Windows 95 or 98 and has two operating modes: GPIB-PCII mode and GPIB-PCIIA mode. The company recommends using GPIB-PCII mode. Furthermore, this card is not a plug-and-play device and requires manual configuration. The remaining hardware in this example consists of a computer and a GPIB connection cable. The computer's operating system is Windows 98. First, install the LabVIEW development platform and the GPIB interface card driver. Then, manually add the GPIB interface card, configuring the jumpers according to the resources allocated by the operating system and the GPIB interface card user manual. In this example, the card operates in GPIB-PCII mode, with I/O address H2B8, interrupt 5, and DMA channel 1. Finally, shut down the computer and insert the GPIB card into the computer's expansion slot. At this point, the hardware setup and software installation in this example are complete. Next, we will use LabVIEW for virtual instrument programming. In LabVIEW, there are two ways to communicate with GPIB instruments: one is to use the GPIB-related functions under the Instrument I/O sub-template in the function template, and the other is to use the VISA-related functions under the Instrument I/O sub-template in the function template. In fact, VISA-related functions can communicate not only with the GPIB bus but also with many other interface types of instruments, such as serial port instruments, PXI interface instruments, and TCPPIP interface instruments. This article uses VISA-related functions. Each VISA function has a VISA resource name parameter, which specifies the hardware device corresponding to the function. In this example, the VISA resource name is GPIB:12, where GPIB specifies the interface type, and 12 is the address of the magnetic measuring instrument on the GPIB bus (factory default value). The first step in communicating with the magnetic measuring instrument is to establish a connection between the computer and the instrument. This task can be accomplished using the VISA OPEN function. Then, using the VISA WRITE function, various commands can be sent to the instrument as needed. The VISA READ function can read any data from the instrument's response. After completing all test tasks, the communication connection between the computer and the magnetic measuring instrument is disconnected using the VISA CLOSE function. It is worth noting that most GPIB interface instruments are based on string format, so even the numbers read back from the instrument are in string format. For subsequent analysis and processing, they must be converted to numeric types. LabVIEW's Function Templates, under the String sub-template and the String/Number Conversion function, provide a dedicated function for scanning numbers from strings. This function can easily convert string-formatted numbers into numeric types. There are two programming styles for instruments: non-modular programming, where specific programs are written to meet specific needs. This method is direct and easy to implement, but its scalability is poor, making it inconvenient for subsequent upgrades and modifications. Modular programming, on the other hand, modularizes the various functions of the instrument, then selects the appropriate modules to achieve specific requirements. This method requires more initial work, but subsequent work is simpler and easier to upgrade and modify. This example adopts the modular programming style. According to NI's slogan "Software is the instrument," a LabVIEW program is a virtual instrument. Typically, a LabVIEW program consists of three parts: the front panel, the block diagram, and the icon. Figure 2 shows the block diagram of the example virtual instrument. Figure 2 shows the block diagram of the example virtual instrument. This block diagram includes three modules: the instrument settings module (CONFIG module), the unit display module (UNITDISPLAY module), and the data acquisition and testing module (TEST module). The settings module is mainly used to set test-related parameters, such as the instrument's GPIB address, unit settings, range mode selection (automatic or manual), range (if the range mode is automatic, there is no need to specify the range; the instrument will automatically adjust to the corresponding range based on the external magnetic field), and magnetic field type (AC or DC). If measuring an AC magnetic field, the PeakPRMS button can be used to select measuring its peak value or average value. The unit display module is mainly used to indicate the unit of the test results. Since there are two units for magnetic fields, Gauss and Tesla, and different units correspond to different ranges, such as T or mT, kG or G, a dedicated unit display module was written. The three unit displays represent the unit of the current reading, as well as the units of the maximum and minimum values. The data acquisition and testing module is the core module of this virtual instrument. It primarily performs magnetic field testing, allowing for arbitrary specification of the magnetic field sampling interval based on actual measurement needs. The module displays the measurement results in real time, and after completion, all test results can be saved as a file for subsequent analysis and processing. This module only provides two basic analysis functions: the maximum and minimum values ​​of the measurement results. For more complex data analysis and processing, such as spectral analysis, other modules can be written using LabVIEW's rich analysis function library, which is not covered in this virtual instrument. Furthermore, as shown in Figure 2, modular programming not only simplifies the program structure but also eliminates the need for programmers to understand the instrument's underlying communication protocol, as the underlying programming for communicating with the instrument is encapsulated within the module, further simplifying the development of the virtual instrument. Figure 3 (omitted) shows the front panel of the example virtual instrument. The left side displays the test results, including the current reading, maximum value, minimum value, and test curve; the right side is the parameter setting area. The "Stop P Start" switch in the lower right corner is used to stop and start the magnetic field test, and the "Save" button is used to save the test results. Compared to a benchtop magnetic measuring instrument, the biggest advantage of this virtual instrument is its ability to perform real-time data acquisition and save the results to a file for subsequent analysis. Strictly speaking, a virtual instrument based on a benchtop instrument can not only perform all the functions of a benchtop instrument, but also functions that benchtop instruments lack, especially in the subsequent analysis and processing of test results, because the analysis and processing of test results does not depend on hardware, but entirely on actual requirements. Furthermore, virtual instruments have advantages such as ease of upgrading and modification. Conclusion This paper introduces the hardware and software requirements for developing a GPIB bus-based virtual instrument using the LabVIEW virtual instrument development platform. Combining a magnetic measurement virtual instrument development example, the entire process of developing a GPIB bus-based virtual instrument is described. Experiments demonstrate that this virtual instrument can effectively complete real-time magnetic field acquisition and measurement, and save the test results for subsequent analysis. This function is not available in benchtop magnetic measuring instruments, thus greatly expanding the functionality of benchtop instruments.
Read next

Using virtual instrumentation technology to address new telecommunications testing challenges

Abstract Mobile phone manufacturers require a repair and testing system at their service centers capable of testing both...

Articles 2026-02-22