Communication Design between LabVIEW and Multiple AI-501 Instruments
2026-04-06 08:17:24··#1
Abstract : This project uses an RS232-RS485 converter to connect a PC to multiple AI-501 instruments and uses LabVIEW programming to monitor the temperature of these instruments in real time. This method can also be used to program other AI series instruments for communication via LabVIEW. Keywords : RS232-RS485 converter, LabVIEW, serial port initialization function (VISA Configure Serial Port), serial port write function (VISA Write), serial port read function (VISA Read), character processing. Introduction : Yudian's AI series instruments have a well-deserved reputation in the domestic market, and their service quality is among the best in China. However, Yudian's website only provides communication code written in VB, while some users are requesting LabVIEW-written communication source code. Recently, my lab purchased 10 AI-501 instruments for temperature display during equipment baking. Taking this opportunity, I wrote communication code for 10 instruments using LabVIEW to obtain the temperature (PV value) of each instrument and display it on the computer. I hope this program can be helpful to everyone, and I welcome any criticism and corrections. This paper is divided into two parts: first, the hardware connection between the computer and multiple AI-501 units; second, the LabVIEW programming. I. Hardware Connection between the Computer and 10 AI-501 Instruments An RS232-RS485 converter can easily connect the computer and 10 AI-501 instruments. The specific scheme is shown in Figure 1. The RS232 end of the RS232-RS485 converter is connected to the computer, and all instruments are connected in parallel to the A and B ends of the RS485 converter, with different addresses set. The addresses I set for the 10 AI-501 instruments are: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10. The data format of the AI series instruments is 1 start bit, 8 data bits, no parity bit, 1 or 2 stop bits, and a baud rate of 4800~19200 bit/s. Considering the number of 10 instruments, for fast communication, I used 19200 bit/s in this project, and the results were excellent after testing. II. LabVIEW Programming LabVIEW is an excellent graphical programming language developed by National Instruments (NI). Unlike text-based programming languages, LabVIEW uses a graphical language (G language), icons, and wires instead of text for program writing. It uses dataflow programming to describe program execution, making it more intuitive and easier to operate. The LabVIEW user interface mainly consists of the front panel and the graphical code window. The front panel resembles a real instrument panel and can hold control and display elements such as knobs, buttons, and text boxes. The graphical code window includes constants, functions, and VI programs represented by icons, and guides data flow through wires, making program writing and debugging very intuitive and convenient. The front panel of this program is shown in Figure 2. [align=center] Figure 3: Program Code Flow[/align] The graphical code window of this program is shown in Figures 4.1 and 4.2. In the graphical code window, to complete the initialization, writing, and reading of the serial port, the serial port initialization function (VISA Configure Serial Port), the serial port write function (VISA Write), and the serial port read function (VISA Read) are used respectively. Additionally, since the obtained data is in hexadecimal, some byte processing functions are used to convert it to decimal and display it on the program's front panel. In the following code description, AI-501 with address 1 is used as an example; other instruments can be directly copied, with only the address changed. 1. Serial Port Initialization: Set the serial port initialization function (VISA Configure Serial Port) as shown in Figure 4.1A. ASRL6::INSTR represents the COM6 port expanded from my computer; Enable Termination is set to False, otherwise reading serial port data will be interrupted when a newline byte is read. 2. Write the command to read the model feature to the serial port: Call the serial port write function (VISA Write function) for 10 AI501 instruments, addresses 1-10. The read command to be sent is shown in the table below. Note that, as shown in Figure 4.1B, the string to be written is Hex Display. Right-click the String Constant connected to the VISA Write function, select Hex Display, and directly enter 8181521500005315 to read the instrument model feature at address 1. Other addresses are listed in the table below. AI-501 Instrument Address Commands (Hexadecimal): 1. 8181521500005315 2. 8282521500005415 3. 8383521500005515 4. 8484521500005615 5. 8585521500005715 6. 8686521500005815 7. 8787521500005915 8. 8888521500005A15 9. 8989521500005B15 10. 8A8A521500005C15 3. Read Serial Port Data: After the command is successfully sent, the serial port read function (VISA Read function) is called to read 10 bytes from the serial port, as shown in Figure 4.2C. Because whether reading or writing, the instrument returns the following 10 bytes of data (see "AIBUS Communication Protocol Description (V7.0)"). 4. Converting hexadecimal data to decimal data: As shown in Figure 4.2D, since the first two bytes of the 10 bytes of data obtained from the serial port represent the PV value information, the String Subset function is called to extract the 1st and 2nd bytes. Then, the String To Byte Array function is called to convert the 1st and 2nd bytes into the 0th and 1st elements of the Byte Array. Finally, the Index Array function is called to extract the two elements into separate decimal numbers. I set the temperature to one decimal place, so the correct temperature in decimal is PV = (first byte + second byte * 256) / 10. After data conversion, the output is shown on the corresponding display on the front panel, as shown in Figure 1. The above is the code for one instrument. Other instruments have the same code except for the different read commands; you can simply copy it. Conclusion : This project demonstrated simple LabVIEW communication programming for the AI-501 instrument, with much room for expansion, such as data storage, temperature curve plotting, and remote monitoring.