LabVIEW serial port to WiFi data transmission implementation method

Abstract: In the field of measurement and control, serial communication is usually used between instruments and computers. Serial communication is wired transmission, which has shortcomings such as short transmission distance and poor mobility. This paper adopts the combination of serial port and WiFi, and proposes a method based on software LabVIEW for serial to WiFi data transmission, which makes serial communication get rid of the constraint of cable.

Introduction In the field of measurement and control, instruments often need to establish communication with a computer to transmit measurement information and control the instrument. On the instrument, the commonly used communication interface is serial port, and the transmission medium of serial communication is wired cable. Although wired transmission can adapt to most industrial environments, in some special environments (such as strong corrosiveness, difficult wiring, and instrument crossover) Motion, etc.), wired transmission will not be able to adapt due to its own defects. This paper introduces a method of serial port to WiFi data transmission based on LabVIEW. On the LabVIEW platform, the serial port realizes data transmission through WiFi.

LabVIEW的串口转WiFi数据传输实现方法

1LabVIEW Introduction

LabVIEW is a graphical programming language introduced by National Instruments. It has been rapidly developed since its inception and is now widely used in the field of measurement and control. LabVIEW integrates all the functions of hardware and data acquisition card communication that meet GPIB, VXI, RS232, and RS485 protocols. It also has built-in library functions that facilitate the application of software standards such as TCP/IP and AcTIveX. It can be used to easily build your own virtual instrument, and its graphical interface makes the programming and use process interesting and interesting [1].

LabVIEW's graphical programming language is also known as the "G" language. When programming in this language, there is basically no need to write program code, instead it is a flowchart or block diagram. It uses as much as possible the terms, icons, and concepts familiar to technicians, scientists, and engineers, so LabVIEW is a tool for end users. It enhances the ability to build scientific and engineering systems and provides an easy way to implement instrument programming and data acquisition systems. Using it for principle research, design, testing and implementation of instrument systems can greatly improve work efficiency.

2 serial to WiFi hardware implementation

The RT5350 chip produced by Ralink integrates the MIPS 24KC 360 MHz processor, supports IEEE802.11b/g/n standard and WEP64/124, WPA, WPA2, WAPI encryption, and has USB, GPIB, SPI, UART and other interfaces. The chip is small, powerful, and inexpensive, and requires only a few peripheral devices to work properly, enabling low-cost development of wireless WiFi products. Therefore, RT5350 is selected as the core chip of serial to WiFi hardware system, which can directly convert serial data into WiFi data transmission. The hardware system block diagram of serial to WiFi is shown in Figure 1 [2].

Figure 1 serial port to WiFi hardware block diagram

Figure 1 serial port to WiFi hardware block diagram

Through the design and debugging of the hardware circuit, the serial-to-WiFi module can be realized into three modes: serial port to WiFi server, serial port to WiFi client, serial port to Ethernet. The module can be configured into the corresponding working mode as needed. For example, simple point-to-point communication, as long as one module is configured as a serial port to WiFi server mode, and another module is configured as a serial port to WiFi client mode, the serial port to WiFi point-to-point data transmission can be realized. In the actual test, the master-slave mode is adopted, that is, the host is connected with the wireless WiFi router (the computer with the wireless WiFi function does not need to be connected to the router), and the serial port to WiFi module connected with the instrument is configured into the client mode, and the specific connection is made. The mode is shown in Figure 2 [3-4].

Figure 2 Network connection method

Figure 2 Network connection method

3 software design

3.1 program design idea Serial port to WiFi, when sending data, it is to read the data on the serial port, store it in the buffer, and then assign the data to the network data sender to send the data; when receiving the data, first Read the data received by the network, store it in the buffer area, and send the data to the serial port.

The serial port to WiFi data transmission adopts the TCP communication protocol. Generally, the TCP communication needs to write the upper computer and the lower computer in the software design. For the instrument with the operating system, the data can be realized only by transplanting the programmed program to the instrument. The transmission is not discussed here.

In the field of measurement and control, most instruments do not have an operating system. The communication mode of the upper and lower computers is not applicable. It is necessary to write a program to complete data transmission only on the PC side. The key point of the serial-to-WiFi data transmission is the establishment of the communication link between the modules. After the data transmission system is built, all the modules are connected to the server. When the PC sends the data, the default is to send to all connected modules, that is, send. If you do not specify a module, all connected modules will receive the data sent by the PC at the same time. The module is distinguished according to the IP address, that is, one module corresponds to one IP address. Therefore, when the data is sent, the IP address can be input to send the data to the corresponding module.

3.2 Host Program Design The host uses LabVIEW as a development platform to establish a bridge between the computer serial port, network port and serial port to WiFi module, thus realizing the wireless transmission function of serial data. In the serial port data processing, the VISA of LabVIEW is called to program. It is a standard application programming interface, which integrates the driver function of the serial port. It can realize the initialization, reading, writing and closing of the serial port by calling the serial communication function of VISA. Features. In the network data processing, call the TCP protocol of LabVIEW to program, and realize the functions of opening TCP connection, establishing TCP interception and reading and writing TCP data by calling the function function of TCP protocol. The program can be divided into two modules according to the function: serial data processing module and network data processing module.

The function of the serial port data processing module is to establish a connection between the host serial port and the serial port device to ensure smooth communication between the two. Call "VISA Configuration Serial Port" to configure the serial port number, baud rate, data bit and parity bit to complete the initialization of the serial port; call "VISA Send" to send data to the serial port; call "VISA Read" to read the serial port received by the host. Data and store it in the buffer [5-6].
The function of the network data processing module is to establish a network connection between the host and the serial port to the WiFi module, and call "open TCP connection" to establish a communication link between the host and the designated module, and input the IP address and port of the module; call "write TCP data" to The module sends data; calls "Read TCP Data" to read the received network data. The block diagram of the software is shown in Figure 3.

Figure 3 LabVIEW program flow diagram

Figure 3 LabVIEW program flow diagram

When LabVIEW sends network data, the common method is to call two "write TCP data" functions, the first "write TCP data" specifies the size of the transmitted data, and the second "write TCP data" sends the data (such as Figure 4). Similarly, when reading data, two "read TCP data" functions are called. The first "read TCP data" collects the data size, and the second "read TCP data" reads the data (as shown in Figure 5). Show) [7-8]. This method is only suitable for receiving and receiving LabVIEW program control. It is incompatible with other platform network data transmission software and cannot receive data correctly because it does not send data when sending data. The solution is to receive only one "read TCP data" function for receiving data. If the data size is fixed, enter a fixed value at the "read byte" of the function. Otherwise, add a carriage return at the end when sending the data. LabVIEW serial to WiFi data transmission receiving and reading the rear panel slightly - editor's note.

4 effect verification

In order to test the reliability of data transmission, a pair of virtual serial ports COM2 and COM3 are generated by the virtual serial port software on the host computer, and the serial port debugging assistant software is opened. The serial port is configured as a serial port number of COM2, a baud rate of 115 200, and a data bit of 8 The serial port of the LabVIEW program is configured such that the serial port number is COM3, and the rest are the same, so that the two establish a connection. Then connect the serial port to WiFi module to another PC with a serial cable, configure the module to connect to the host's wireless router, enter the module's IP address and port in the host LabVIEW program, and open the network connection, then the host and the module pass WiFi connection.

Open the serial port debugging assistant on the PC and send the character “module test data” to the serial port. The data will be sent to the host through the module. The network data receiving box of the LabVIEW program on the host displays “module test data”, and the serial port debugging assistant on the host is also the same. display. Similarly, the serial port debugging assistant on the host sends the character "host test data". The serial port data frame of the LabVIEW program and the serial port debugging assistant of the PC will display the "host test data", indicating that the data transmission and reception is normal (as shown in Figure 6).

Figure 6 LabVIEW serial to WiFi front panel display

Figure 6 LabVIEW serial to WiFi front panel display

Conclusion

With the widespread use of wireless technology, traditional wired transmission is gradually replaced by wireless transmission, wireless transmission is not bound by cables, and device location changes do not require rewiring. Through the serial port-to-WiFi data transmission based on LabVIEW, the serial port data can be transmitted wirelessly, making the connection between the serial devices more convenient and quick. The method is low in cost, convenient to use, and has good versatility and scalability.

ZGAR bar 2000 Puffs

ZGAR bar 2000 Puffs


ZGAR electronic cigarette uses high-tech R&D, food grade disposable pod device and high-quality raw material. All package designs are Original IP. Our designer team is from Hong Kong. We have very high requirements for product quality, flavors taste and packaging design. The E-liquid is imported, materials are food grade, and assembly plant is medical-grade dust-free workshops.


Our products include disposable e-cigarettes, rechargeable e-cigarettes, rechargreable disposable vape pen, and various of flavors of cigarette cartridges. From 600puffs to 5000puffs, ZGAR bar Disposable offer high-tech R&D, E-cigarette improves battery capacity, We offer various of flavors and support customization. And printing designs can be customized. We have our own professional team and competitive quotations for any OEM or ODM works.


We supply OEM rechargeable disposable vape pen,OEM disposable electronic cigarette,ODM disposable vape pen,ODM disposable electronic cigarette,OEM/ODM vape pen e-cigarette,OEM/ODM atomizer device.

Disposable Vape, bar 2000puffs, ZGAR bar disposable, Disposable E-cigarette, OEM/ODM disposable vape pen atomizer Device E-cig

ZGAR INTERNATIONAL TRADING CO., LTD. , https://www.oemvape-pen.com

Posted on