Design of TD3000 Instrument Control System Based on GPIB Interface
2026-04-06 07:36:56··#1
Abstract: This paper introduces the method of connecting a computer to a TD3000 optical time domain reflectometer using the GPIB interface and HP standard instrument control library, realizing the measurement control of the TD3000 programmable instrument by the computer. It also introduces the functions in the HP standard instrument control library and the commands of the TD3000 programmable instrument used in the system, and designs a method and program flow for reading the raw data of a single measurement process controlled by the computer. Keywords: GPIB interface; optical time domain reflectometer; standard instrument control library; programmable instrument 1 Introduction The development and popularization of computer technology and modern microelectronics technology have promoted the rapid development of electronic measuring instruments. Early testing work using independent benchtop measuring instruments can no longer meet the requirements of modern measurement tasks. Therefore, automatic testing systems have been widely developed and applied in enterprise production, scientific research, and engineering. An automatic testing system is a computer control system with computer hardware and software as its core, including measuring instruments and test objects. The GPIB interface, specifically designed for instrument control applications, was thus born and has been widely used in automatic testing systems for instruments, becoming the standard interface for intelligent instruments. Although emerging interface and bus technologies are increasingly being used in automated test systems, GPIB remains a crucial component due to its powerful functionality, mature technical support, and wide user base. Implementing GPIB control of instruments is a fundamental and essential aspect of system construction. This paper analyzes and designs a method for controlling a TD3000 OTDR instrument via a computer through the GPIB interface, enabling programmed measurement and data reading. The TD3000 OTDR, or Optical Time Domain Reflectometer, is widely used in fiber optic cable production and engineering industries to measure important parameters such as fiber length and attenuation, as well as to locate fiber breaks. Conventional operation involves using various switches and knobs on the instrument's control panel, which is cumbersome, provides limited data display, and makes it difficult to save and further analyze measurement results. This instrument has a standard GPIB interface, allowing it to connect to a computer to form an automated test system, completing measurement tasks that are difficult or impossible to perform manually. 2 Application System Composition and GPIB Interface Introduction 2.1 Application System Composition As shown in Figure 1, a typical GPIB automatic test system is composed of a main control computer with a GPIB interface card and multiple test instruments with GPIB interfaces connected through a GPIB bus. The connection method can be a bus or star connection, or a combination of the two. The test software runs on the main control computer and performs automatic operation and remote control of the test instruments through the GPIB interface card. [align=center] Figure 1 Block diagram of instrument control system based on GPIB bus[/align] In this design system, the GPIB instrument is a TD3000 OTDR programmable instrument. The GPIB interface card adopts the PCI-GPIB 82350A interface card from Agilent Technologies, USA. The computer platform adopts a desktop microcomputer and installs the interface card driver and HP SICL instrument control I/O function library [1]. 2.2 GPIB Interface Introduction The GPIB interface, also known as the IEEE-488 standard, is a universal instrument standard interface. Its data transmission is constrained by three signal lines and is an asynchronous data transmission in the "three-wire hook" response mode. The communication bus consists of 24 lines: 8 bidirectional data lines (DIO1-DIO2), 3 signal exchange lines (DAV, NRFD, NDAC), 5 general-purpose control lines (ATN, IFC, SRQ, REN, EOI), and 8 ground lines. Up to 15 instruments or devices, collectively referred to as "devices," can be connected to the bus. Devices sending data to the bus are called "speakers," devices receiving data from the bus are called "listeners," and devices controlling the bus are called "controllers." During GPIB data transmission, the three signal exchange lines are used by the speaker (DAV line is valid for data transmission), and by the listeners (NRFD (not ready to receive data) and NDAC (not received data)). This enables broadcast transmission, i.e., a one-to-many transmission method. The data transmission process is as follows: DAV=0 indicates that there is no data on the data line or the data is not yet valid. The speaker will only set DAV=1 when all listeners are ready to receive data, i.e., NRFD=0. When the listener learns that the data is valid (DAV=1), it sets NRFD=1 to prepare for the next data transmission. Simultaneously, after receiving the data, it immediately informs the speaker by setting NRFD=0. The speaker cancels the original data by setting DAV=0. After the speaker cancels the data, the listener responds with NRFD=1, ending one data transmission. If there is more data to transmit, the above process is repeated. From the data transmission process of this three-wire hook method of GPIB, it can be seen that it is a bidirectional, fully interlocked asynchronous transmission process. Its characteristics not only ensure automatic adaptation to devices with different transmission rates but also guarantee the reliability of data transmission. In this system, the device acting as the "controller" is the microcomputer system, while the TD3000 OTDR programmable instrument can operate in both "listener" and "speaker" modes. 2.3 Introduction to HP SICL HP SICL is the HP standard instrument control library provided with the GPIB interface card along with its driver. It is a standard modular instrument communication library that can be installed on various computer architectures, I/O interfaces, and operating systems. Applications written using this standard instrument communication library in C/C++ or VB can be ported from one system to another with little or no modification. SICL standard functions are applicable to communication applications with multiple interfaces. Since the library function commands are independent of specific communication interfaces, the communication program written for one instrument on one interface can be applied to the same instrument on other interfaces. At the same time, SICL also provides programmers with function commands based on different I/O interfaces. The installation of the driver and SICL can be completed using the system default method. After installation, the RUN IO CONFIG program needs to be run, and the default interface name and bus address need to be set or used. In this design, the interface name is hpib7 and the bus address is 21[2]. 3 Software design of the control system 3.1 TD3000 instrument commands The TD3000 instrument has 25 programmable commands, including commands for starting, setting measurement parameters, reading measurement results and measurement raw data. The computer sends these commands through the GPIB interface to realize remote control of the instrument. It can complete almost all the functions of the instrument panel in routine operation. The specific format of the commands is explained in detail in the TD3000 instrument operation manual. Using these commands, the computer can not only read the instrument's measurement results, such as fiber optic length and attenuation, but also directly read the raw data measured by the instrument. Then, leveraging the computer's powerful data processing capabilities, it can perform various algorithms, display, save, or print the data, effectively expanding the instrument's functionality, greatly simplifying manual operation, and improving efficiency. This design adopts this method, primarily using the OT command, which is the output curve trajectory array command. This command is one of the most important commands of the TD3000. Its return information differs from other commands. The OT command returns two types of information: first, the header data of an ASCII string, in the format <ndata>, <nscans>, <delta>, and <endm>, representing the number of data points for the entire curve, the scan time, the distance between data points, and the terminator, respectively. Second, the curve data packet conforming to the ANSI/IEEE Std 728-1982 binary data block transmission standard. The data in the packet is prefixed with "#" and "B", followed by two bytes indicating the number of bytes in the packet, then the curve data points, with each data point consisting of two bytes, and finally ending with a one-byte checksum. The maximum number of bytes in a data packet is 1024 bytes, so the data of a trajectory curve generally needs to be composed of multiple data packets [3]. 3.2 Software Design Based on the above design analysis, the most important and basic task in the system design is for the computer to control the instrument to complete a measurement and read the original measurement data from the instrument. This design uses C language programming and calls the SICL function to control the TD3000 instrument. Figure 2 shows the program flow for completing a measurement control and reading the original measurement data [4]. In this flow, INST is the device identifier data type defined in the SICL header file. The identifier of the communication instrument or device is obtained by opening the function iopen(“hpib7,21”), where “hpib7,21” is the interface name and bus address generated by running the IO CONFIG program after installing SICL. Variables and parameters are defined according to the variables used in the program design, such as defining an array char buf[1024] to store a data packet and an array int dPoint[ndata] to store curve data points. Next is the handling of interface errors and timeouts. The instrument parameter settings are determined according to the actual requirements of the measurement process. Here, multiple TD3000 instrument control commands need to be sent to enable the instrument to complete the required measurement tasks. This is achieved using the library function iprinf(id, format[, arg1][, arg2][, ...]). For example, the scan command "SS 12" is used to start the scan. The numerical parameter after the command "SS" is the average scan time, which is determined according to the test fiber length and the TD3000 test manual. Its application function format is iprinf(id, "SS 12\n"). This function can send multiple commands simultaneously as needed. Whether the scan is complete can be checked by reading the instrument status. To determine if the scan averaging is finished, send `iprinf(id, "OS\n")`. The returned information format is [format missing]. Use the library function `iscanf(id, format[, arg1][, arg2][, ...])` to read the status. The specific application function is `iscanf(id, "%c, %c", &err, &tstat)`. Check if `tstat` equals 2 and `err` = 0, indicating that the scan averaging curve data is ready. At this point, you can directly read the instrument measurement and calculate the result according to the instrument's fixed method, or read the raw data measured by the instrument and have the computer perform the calculation and processing on this data. This design adopts the latter method, therefore, an OT command is sent. As analyzed above, the OT command returns two types of information: ASCII information similar to other commands and binary data information conforming to the ANSI/IEEE Std 728-1982 standard. Different library functions are used to read the data for these two types of information. Specifically, the function iscanf(id, "%d, %d, %f", &ndata, &nscan, &delta) is used to read the header record of the curve data. The number of curve data points ndata is used to calculate how many data packets to read, nscan is the actual average scanning time in milliseconds, and delta is the length between adjacent data points used to calculate the fiber optic cable length. The curve data packet is read using the function iread(id, buf, bufsize, reason, actualcnt). According to the data packet format analysis, four bytes are read first, and the function is iread(id, buf1, 4, NULL, NULL). buf1[0] and buf1[1] should be ASCII data "#" and "B". buf1[2] and buf1[3] are the number of data bytes in the data packet. Therefore, another byte needs to be read, which is bytect = buf1[2] * 256 + buf1[3] + 1. Here, a checksum of one byte is added, and the function is iread(id, buf2, bytect, NULL, NULL). Thus, the data of one data packet is read. The data points of the read data packet are calculated as two bytes per curve data point. They are compared with the data points in the header record. If they are equal, the reading procedure of the original measurement data is completed. If they are not equal, they are read again until all data points are read. The entire curve data points are stored in the dPoint[ndata] array, with a maximum of 16384 data points and data values ranging from -2720 to 8160. The computer can use this array to programmatically perform various calculations and processing of the data to meet users' diverse requirements for instrument measurement results. 4. Conclusion This paper mainly discusses the methods, procedures, and program flow used by a computer to control the TD3000 instrument to complete a measurement process. This design realizes the computer's measurement control of the TD3000 OTDR instrument in a practical application system and has achieved good results in actual production testing. It not only improves testing efficiency but also realizes testing tasks that are difficult to complete manually. Its design ideas and methods are also applicable to computer control systems of other types of programmable instruments, providing a transformation method for building automatic testing systems using some older instruments. The author's innovation: The instrument control system design introduced in this paper does not directly read the instrument's measurement and calculation results, but rather reads the raw measurement data of the instrument, which is then processed by the computer. Therefore, it can fully utilize the computer's data processing capabilities, greatly expand the original instrument's functions, and meet users' new demands for instrument measurement results. References [1] Zhang Huanlin, Mu Jiancheng. Design of automatic test system based on GPIB technology [J]. Microcomputer Information, 2005, (5): 165-166. [2] HP Standard Instrument Control Library Guide [Z]. USA: Hewlett-Packard Company. 1998. [3] TD-3000 OTDR Operating Instructions [Z]. USA: Laser Precision Corp. 1994. [4] Tan Haoqiang. C Programming [M]. Beijing: Tsinghua University Press, 1991.