Multi-channel wireless A/D acquisition system based on NRF24L01 and LABVIEW

. This paper presents a wireless A/D acquisition system based on NRF24L01 and LABVIEW, which can be used to collect A/D data in the harsh environment of industrial production, but the staff can not easily approach or can not persist in the field for a long time. The system mainly by the wireless transmission module NRF24L01 and A/D data acquisition module, which A/D conversion part of the chip using STM32C8T6 own ADC. The computer uses LABVIEW as the host computer for data display and processing. The wireless A/D acquisition system has stable operation, long transmission distance, accurate data transmission, no loss of data, and can be adapted to various industrial control and measurement situations through measurement in different harsh environments of the factory.


Introduction
At present, some factories with harsh working conditions need to collect the multi-channel analog data volume of the plant in real time [1], but these places are often high-temperature environments or places with more dust. If the staff stays at the scene, it will be very large. s damage. Therefore, the staff must be at a certain distance from the harsh environment. If you use the traditional RS232 or RS485 [2] wiring, you need complicated wiring work, and you must also use a professional adapter, you can not use it anywhere.
In view of the above problems, a wireless A/D acquisition system based on NRF24L01 and LABVIEW is proposed. Two wireless modules are used to realize short-distance communication, which greatly simplifies the circuit, and has low cost and good performance. In addition, the STM32F103 series MCU is smaller than the traditional 51 MCU, and has a small chip size and an ADC with its own anti-interference ability. It has rich internal resources and can adapt to complex industrial environments. In addition, virtual instrument as a milestone in the development of measurement and control instruments [3], the use of Labview instead of the traditional test instrument greatly facilitates the processing of data.
The overall structure of the whole system is shown in Figure 1. It is divided into A/D data acquisition module (including the minimum system of MCU and various sensor modules or data acquisition cards that can output analog signals). The two wireless transmission modules are respectively in the data acquisition module. Connected to the USB to serial port module (both can receive and send data), the computer software module on the computer side, wherein the computer end is connected to the wireless module through the USB to serial port module, and the serial port will collect more in the LABVIEW. The road A/D conversion data is displayed in real time.

Data acquisition module
Since there is not much I/O port resources required, the STM32F103C8T6 chip based on the ARM Cortex-M3 core series is selected as the control chip. Its maximum speed is 72MHz, 37 available I/O ports, 64K FLASH, 10 channels. 12-bit A/D converter, 2 IIC bus, 2 SPI bus, 3 16-bit timers, and a PWM advanced timer for motor control. In addition, the chip's operating voltage is about 3.3v, with sleep and standby modes, which can reduce power consumption to the greatest extent [4]. Since the chip integrates a 10-channel 12-bit ADC, the complexity of the hardware circuit can be reduced. In addition, a USB to serial port module should be installed on the computer to facilitate the data received by the wireless module to be sent to the host computer through the serial port, so that wireless communication can be realized within a short distance.

Wireless communication module
The wireless communication module is an important part of data transmission [5]. In order to ensure the quality of data transmission, the NRF24L01 wireless transceiver module with high cost performance is selected. The operating voltage of this wireless module is between 1.9 and 3.6V, and the power consumption is low and the volume is small. NRF24L01 integrates high-speed signal processing part related to RF protocol RF. For example, the lost data packet can be automatically retransmitted and automatically generate a response signal after receiving the transmission data. The NRF24L01 uses the SPI interface to communicate with the MCU [6]. The high-end MCU can communicate with the wireless module through the built-in hardware SPI port. For the MCU without hardware interface, the I/O port can be used to simulate the timing drive of the SPI.
The schematic diagram of the wireless module is shown in Figure 2. The NRF24L01 has a total of eight pins. The first pin is GND, the second pin is VCC, and the third CE pin is used to configure the working mode of the wireless module. The next four The pins are connected to the SPI1 hardware interface of the SYM32. These four pins are NSS (slave device select pin), SCK (clock signal pin, as master output, slave input), MOSI (master out/slave), and MISO (master/in/ From the out pin). The last pin is an interrupt pin that is used to generate an interrupt request to the STM32. In the entire A/D data acquisition system, the program uses KEIL software as the development environment, based on the STM32 v3.5 firmware library and written in C language.
Because ADC data with multiple channels needs to be sent to the host computer in time, the combination of DMA and ADC is used to collect data. Thanks to the addition of the DMA mode, high-speed data transfer can be automatically performed between the peripheral sensor or the data acquisition card and the memory. And no CPU is required to participate, data can be quickly moved to memory by setting the DMA channel, which saves CPU resources and allows the CPU to handle other events.
Since the STM32's ADCs are all 12-bit, since the number of data bits for serial communication is set to 8 bits, the upper four bits of the collected data are transmitted first when the data is transmitted, and then the lower eight bits are transmitted. The values of the four channels are stored in an array, and the data collected by A/D ranges from 0 to 4096. The entire software work flow chart is shown in Figure 3.

Wireless transceiver module software design
The NRF24L01 uses the SPI interface for communication. SPI is a high-speed, full-duplex, synchronous communication bus that occupies only four lines of the chip and has a simple structure. In point-to-point communication, the SPI interface does not require addressing operations and is full-duplex communication with high transmission efficiency. There are four working modes of SPI. Here, SPI0 mode is adopted, that is, CPOL=0 and CPHA=0. CPOL determines whether the idle state of the clock signal is high or low. CPHA determines the sampling time. In SPI0 mode, the sample will sample the data on the rising edge of each clock cycle. The data acquisition is set from the highest bit. send.
At initialization, the NRF24L01 is configured to both receive and transmit. Set its data receiving address, effective data digits, communication channel, data transmission rate and transmission power [7]. The workflow of sending and receiving data is shown in Figure 4.

Computer-side computer software design
The upper computer uses National Instruments (NI)'s graphical programming software LABVIEW as the development environment. With its powerful visual programming, it can quickly and easily build a virtual instrument test platform. The wireless data receiving module is connected with the USB to serial port module, and then can communicate with the computer host computer through the RS232 serial port protocol [8].
The block diagram of the entire LABVIEW system program running is shown in Figure  5.

Test and analysis
Connect the core board and the sensor or data acquisition card to the analog input port of the STM32 MCU, connect the wireless transmission module to the SPI hardware interface of the STM32, and connect to the wireless receiving module through the USB to serial port on the computer. When you open Labview software, the waveform graph begins to plot the value of the acquired data into a voltage. The data collected by each channel is displayed independently in a graph to avoid interference between different channels. The collected data can also be exported to an Excel file for easy transmission to different engineers for viewing. At the same time, the upper and lower limit indicators are set on each channel. When used, the upper and lower limits of the corresponding channel on the software front panel can be set. Once the set upper limit threshold or the lower limit threshold is exceeded, the indicator light It will light up to remind the technician that there is an abnormality, and multiple channels operate independently without interfering with each other. The experimental phenomenon is shown in Figure 6. The data collected is shown in Figure 7.

Summary
This paper introduces a multi-channel wireless A/D acquisition system based on NRF24L01 and Labview. The system solves the problem of complicated layout and high cost by using the traditional wired connection, and the system has high integration, small volume and good real-time performance, and the system can work well under practical complicated conditions. It can be embedded in various occasions where A/D data collection needs to be performed in real time, and has a high promotion and use value.