A Data Transmission System for Sewage Treatment in Oil Refinery Based on LoRa

This paper designs a wireless data transmission system based on LoRa technology in view of the safety requirements of the upgrade of the oil refinery sewage treatment system. On the basis of protecting the data flow of the previous system, the measurement data of each sensor is collected and sent to the PLC in a wireless manner. By the reasonable circuit structure design and the wireless transmission mode choice, this system has high explosion-proof performance, high safety, and has the advantages of good real-time performance, high maintainability, and easy expansion.


Design scheme of the data transmission system for sewage treatment
Aiming at the explosion-proof problem, this design adopts circuit design schemes such as power isolation and optocoupler isolation. In addition, safety elements such as fuse, anti-detonator, and bidirectional suppression diode have been added. In this way, it is possible to avoid the occurrence of large current due to abnormal work and the high temperature of the circuit orelectric sparks caused by external environment such as thunder. We choose LoRa wireless technology as the data communication method. This technology has the characteristics of low power consumption, low power, long-distance transmission, etc., to meet the safety requirements of explosion-proof in the three industrial zones. [3] The equipment and PLC of sewage treatment monitoring system form a wireless transmission network. The system architecture of the data transmission system is shown in Figure 1. The device end (end node) can be expanded to 256 at most. Each equipment end corresponds to a sewage treatment tank, and collects the data collected by the sensors in the sewage treatment tank in a wired manner, including multiple 4-20mA analog quantities and RS-485 digital quantities. The data is processed by the STM32 micro-control unit, and then sent to the PLC by the LoRa module wirelessly. The LoRa module on the PLC side receives the data. The STM32 micro-control unit processes the data and restores the data to 4-20mA analog quantity and RS485 data quantity for output.

Hardware design of the data transmission system for sewage treatment
Taking into account the compatibility of the hardware system, the hardware system designed in this article can be used for both the equipment side and the PLC side. The difference lies in the welding differences of some components. Each hardware system is divided into three parts: main board, analog channel board, and digital channel board. The daughter board is connected to the main board by means of pins. Considering the scalability of the data channel, each motherboard can be plugged into up to 8 analog channel boards and 5 digital channel boards.
(1) Analog channel board hardware design The analog channel board is divided into three ends: 4-20mA signal input, 4-20mA signal output and the connection part with the main board, as shown in Figure 2. In order to improve the reliability and safety performance of the circuit, we adopt a three-isolation method for design. That is, the main board is isolated from the signal input and output, and the signal input and output are isolated by optocoupler. Optocoupler isolation selects two 6N137 chips to realize. The partial circuit diagram is shown in Figure 3 (a). Power isolation is achieved by using two DC-DC isolated power supplies, one end is connected to the power supply voltage input by the main board, and the other end is used to supply  (a) Optocoupler isolation circuit (b) Power isolation circuit Figure 3. Three-isolation circuit design. The analog channel board on the device side needs to convert the 4-20mA current signal into a frequency signal and send it to the micro-control chip of the main board. On the other hand, the frequency signal needs to be isolated by an optocoupler and then converted back to a 4-20mA current signal output. This involves a process of mutual conversion between current and frequency. The 4-20mA current is converted into a voltage of 1-5V through a 250Ω resistor at the signal input terminal. At the signal output end, we use the XTR111 chip to achieve voltage to current conversion. XTR111 is a precision voltage-current converter designed for standard 0mA-20mA or 4mA-20mA analog signals. The ratio between input voltage and output current depends on the external resistor R set . The mutual conversion between voltage and frequency is realized by LM331 conversion chip. LM331 is suitable for V-F conversion or F-V conversion. It has the advantages of simple wiring, low cost and high conversion accuracy. The chip has good linearity at 15kHz-75kHz. This design uses its characteristics to achieve mutual conversion between 1-5V voltage and 15kHz-75kHz frequency.
(2) Digital channel board hardware design The digital channel board is mainly composed of AME2587E chip, pins and DIP switches. The DIP switch is used to control the channel enable. The schematic diagram of the digital channel board is shown in Figure 4.

(3) Main board hardware design
The main board contains a central processing unit module, a LoRa wireless module, a power supply module, a signal interaction part and a human-computer interaction part, as shown in Figure 5. The central processing unit of the system adopts the STM32F407ZGT6 micro-control chip with high performance and low power consumption. [4] The LoRa module adopts the E32-TTL-100 (433T20DC) wireless serial port module of EBYTE Company. The E32 series is a wireless serial port module (UART) based on SEMTECH's SX1276/SX1278 radio frequency chip. It has the advantages of longer communication distance, strong anti-interference ability, and strong confidentiality. [5] The signal interaction part is used to connect the main board and the channel board. The human-computer interaction part is used for terminal setting and hardware system information display. Specific functions can be realized through software configuration according to user needs. The hardware circuit is realized by LED lights and dial switches. The power module provides stable and reliable voltage for the entire system. The input terminal is connected to the 24V input voltage commonly used in the industry, and the three output terminals provide 24V, 5V, and 3V power supply voltages respectively. In order to improve the safety performance of the system, in the power supply module, an overcurrent protection circuit and a power reverse protection circuit are designed using fuse, diode and other components. The 3.3V and 5V power supply voltages are converted respectively through two DC/DC isolated power supplies. The material object of the mainboard is shown in Figure 6.

Software design of the data transmission system for sewage treatment
The software layer initialization code is written by STM32CubeMX software. We can get the initialization code based on the HAL library directly by setting the pin information of the chip through the graphical interface. In order to assist users in developing products quickly, a simple transmission protocol is embedded inside, and users can implement network construction quickly without understanding complex transmission protocols. By setting the target channel and target address in the data frame header, we can control which slave device can receive data. The details are shown in Table  1.

Fixed-point transmission
The slave device corresponding to the target channel and address can receive (single receiving) Through analysis, this design uses the same channel and different addresses for each end node LoRa module to communicate with the master station. In this way, mutual interference between signals is reduced.
The LoRa module has four working modes, as shown in Table 2. The M0/M1 state can be controlled through GPIO to determine the working mode. The communication between the sub-station of this system and the master station adopts working mode 0. 6 multiple sub-stations and a master station. Through the design of the communication protocol in the future, the one-to-many network communication of the entire sewage treatment system can be realized.
The material object of the system is shown in Figure 7. Figure 7. The material object of the system.

Conclusions
In this paper, a data wireless transmission system based on LoRa technology is designed for the sewage treatment system of the oil refinery, which realizes the transmission of the data collected by the sensor to the PLC. The article mainly introduces the overall framework of the system, the explosion-proof design of the hardware circuit, and the software setting plan for the LoRa module.
The entire system is low in cost, simple, easy to maintain, has good scalability, and has a high safety factor. It is suitable for wireless data transmission in many industrial sites with high explosion-proof requirements.