Design of a multi-tank liquid level monitoring system based on ultrasonic sensing technology
2026-04-06 03:49:43··#1
Abstract: This paper utilizes ultrasonic sensing technology combined with corresponding testing algorithms to monitor and centrally manage the liquid level in a group of tanks. This non-contact measurement significantly increases the system's continuous operating time, simplifies and facilitates sensor maintenance, and enables maintenance without interrupting production, thus improving productivity and management efficiency. This paper briefly describes the system's working principle, structure, and design method, and discusses the selection of sensors and microcontrollers. A microcontroller is used to control the transmission and reception of ultrasonic waves and calculate the liquid level, giving the testing instrument greater intelligence. Keywords: ultrasonic sensor, liquid level monitoring, liquid level measurement, temperature compensation, MSP430 Abstract: Utilizing the technology of Ultrasonic wave, relevant test arithmetic and the PC to carry on monitoring, controlling and centralized management of the liquid-level in the liquid container, can prevent from keeping in touch with the examined liquid, not only has increased the continuous working time of the system greatly, simplifying maintenance of the sensor conveniently, can also realize overhauling in producing and boost the productivity and management level. The working principle, hardware structure of the instrument and the design method are presented, the selection of sensor and MCU is discussed in detail. The more intelligent can be obtained when using the MCU to control the emission and receive and to calculate the liquid-level. Key words: Ultrasonic Sensor, Liquid-level Monitoring, Liquid-level measure, Temperature compensation, MSP430 1 Introduction Currently, commonly used tank level measurement methods can be divided into two types based on the measurement method: contact and non-contact. Contact measurement refers to a measurement method where the sensor directly contacts the liquid medium inside the tank. Because the sensor is in contact with the liquid, issues such as leakage resistance and corrosion resistance must be considered during sensor design and installation. This design employs non-contact ultrasonic measurement technology to detect the tank level. Since the sensor does not directly contact the measured liquid, with minimal protective measures, this method offers advantages such as high reliability, easy maintenance, long maintenance cycles, and the ability to perform maintenance without interrupting production. Furthermore, engineering wiring and other factors can significantly complicate the maintenance and repair of the circuit. In testing sites with corrosive liquids, the presence and damage of corrosive gases in the environment can frequently lead to production stoppages due to signal transmission line failures or damage. With the continuous improvement in the performance and decrease in the price of wireless communication modules, the adoption of wireless data transmission will undoubtedly bring great convenience to the system's signal transmission. On the one hand, it can eliminate the need for engineering wiring; on the other hand, it can greatly simplify line maintenance and repair work. This also eliminates the significant inconvenience caused by line inspection and maintenance. 2 System Hardware Design 2.1 System Hardware Composition and Working Principle This design mainly consists of an ultrasonic sensor, a flow sensor, a solenoid valve, a microcontroller (MCU), a wireless transceiver module, an LCD display, and a keyboard. The system hardware structure is shown in Figure 1. The liquid level sensor in this system is an ultrasonic sensor. It uses the ultrasonic sensor to collect signals and combines them with corresponding testing algorithms to test the liquid level in the tank. The high-performance microcontroller MSP430 is used to collect, process, analyze, display, store, and communicate with the host computer. The ultrasonic transmitting circuit emits ultrasonic waves under the control of the microcontroller. After receiving the signal, the receiving circuit sends it to the microcontroller for processing. Then, it calculates the distance from the bottom of the tank to the liquid surface, i.e., the current liquid level. The test results are displayed on the on-site monitor and can also be wirelessly transmitted to the host computer for further analysis or database management. The overall system structure is shown in Figure 1. [align=center] Figure 1 Overall Composition Structure Diagram of the System[/align] 2.2 Ultrasonic Sensor Testing Principle and Interface Design 2.2.1 Ultrasonic Sensor and Liquid Level Testing Principle The basic principle of ultrasonic liquid level measurement is: the ultrasonic pulse signal emitted by the ultrasonic probe propagates in the gas, is reflected after encountering the interface between air and liquid, and the echo signal is received. The round-trip propagation time of the ultrasonic wave is calculated, and the distance or liquid level height can be calculated. Ultrasonic measurement method has many advantages that other methods cannot match: (1) There are no mechanical transmission parts, and it does not contact the liquid being measured. It is a non-contact measurement, and it is not afraid of electromagnetic interference, strong corrosive liquids such as acids and alkalis. Therefore, it has stable performance, high reliability, and long life. (2) Its response time is short, which can easily realize real-time measurement without lag. The ultrasonic sensor used in this system operates at a frequency of about 40kHz. The ultrasonic pulse emitted by the transmitting sensor is transmitted to the liquid surface and reflected back to the receiving sensor. The time required for the ultrasonic pulse to be received from emission to reception is measured. Based on the speed of sound in the medium, the distance between the sensor and the liquid surface can be obtained, thereby determining the liquid level [1]. Considering the influence of ambient temperature on the propagation speed of ultrasonic waves, the propagation speed is corrected by temperature compensation to improve the measurement accuracy. The calculation formula is: V=331.5+0.607T (1) Where: V is the propagation speed of ultrasonic waves in air; T is the ambient temperature. S= V ×t/2= V×(t1-t0)/2 (2) Where: S is the distance to be measured; t is the time difference between transmitting the ultrasonic pulse and receiving its echo; t1 is the time of receiving the ultrasonic echo; t0 is the time of transmitting the ultrasonic pulse. The capture function of the MCU can be used to easily measure the time t0 and t1. According to the above formula, the distance to be measured S can be obtained by software programming [2]. Since the MCU of this system is a mixed signal processor with SOC characteristics, and its internal temperature sensor is integrated, the temperature compensation of the sensor can be easily realized by software. 2.2.2 Interface between Ultrasonic Sensor and MSP430 This system uses the SCS-401 series ultrasonic sensor with a resonant frequency of approximately 40kHz. Its signal processing circuit consists of two parts: an ultrasonic transmitting circuit and an ultrasonic receiving circuit. For ease of debugging, the ultrasonic oscillator adopts a hardware circuit design, using an MCU for transmission control. Since the measurement range of the tank liquid level is generally no more than 5 meters, the sensitivity of the ultrasonic receiving circuit does not need to be too high. To simplify the design, this system uses a two-stage amplification and comparison circuit. The ultrasonic transmitting and receiving circuits and their interface with the MCU are shown in Figure 2 (signal is transmitted from P25 and received from P24). 2.2.3 Connection between Flow Sensor Signal and MSP430 To simplify system maintenance and repair, the flow sensor in this system is a vortex flow sensor without mechanical transmission components. Since this sensor can directly output equivalent pulse signals, its signal processing circuit design is relatively simple. It only needs to be shaped using a Schmitt trigger and sent as an interrupt request signal to the MCU for processing. See Figure 2; the flow sensor is connected from JIN1 in the figure. [align=center]Figure 2 Schematic diagram of the lower-level machine[/align] 2.2.4 Wireless data transmission module and its connection to the system The wireless data transmission module used in this system is SRWF-108 (or SRWF-1). This module uses FSK modulation and operates at a frequency of 429MHz~433.3MHz. Its communication channel is half-duplex, which is suitable for point-to-multipoint communication transmission systems. It can directly support RS-232 standard serial communication. However, since the output signal of this module is TTL, a TTL-to-EIA level conversion circuit must be designed for the module connected to the upper-level machine. The MAX232 is used in this system. See Figure 2. The wireless data transmission module is connected to P34 and P35 of the lower-level machine. 2.3 Selection of microcontroller MCU To simplify and facilitate system design as much as possible and reduce the power consumption of the lower-level machine, this design uses the MSP430 series MCU with SOC characteristics from TI. This is an ultra-low power 16-bit mixed-signal controller that integrates a large number of peripheral modules and temperature sensors. The MSP430 microcontroller adopts the latest low-power technology, with a working voltage range of 1.8 to 3.6V. It has a normal working mode (AM) and a variety of low-power working modes. When the power supply voltage is 3V, its power consumption in the lowest power mode is only 0.1μA. Its ultra-low power consumption is particularly prominent in practical applications, especially in battery-powered portable devices. The MSP430F1232 microcontroller used in this design has a very high degree of integration. It integrates a 10-channel 10-bit A/D converter, a timer with PWM function, a temperature sensor, an on-chip USART, a watchdog timer, an on-chip digitally controlled oscillator (DCO), a large number of I/O ports with interrupt function, a large capacity on-chip Flash and RAM, and information Flash memory [3]. The Flash memory can realize power-down protection and software upgrade. Based on the above features, it can be seen that using the MSP430 microcontroller as the processor of the test instrument can simplify the system circuit design, shorten the development cycle, reduce system power consumption, and improve system performance. 3 System Software Design This design uses an ultrasonic sensor as the main detection device. It measures the liquid level in the tank using the ultrasonic pulse reflection reception method, and then calculates the current liquid level based on a corresponding test algorithm. The test results can also be transmitted to a computer via a wireless data transmission module for further analysis and processing. The software design of the microcontroller-based liquid level monitoring system mainly consists of two parts: the lower-level control program is written in assembly language, and the upper-level processing program is mainly written in C#.net. 3.1 Lower-level Processing Program The measurement process is jointly completed by the microcontroller and the ultrasonic circuit. The interval between each ultrasonic wave transmission can be set to 0.5 seconds. During transmission, the microcontroller sends a transmission enable control signal from P2.5, and the transmitting circuit emits an ultrasonic wave of approximately 40kHz from the ultrasonic transmitter. To eliminate transmission interference, a certain delay is allowed before the timer in the microcontroller is activated to start timing, with the initial time recorded as t0. After the ultrasonic wave hits the liquid surface, it reflects back and is received by the receiver. At this time, the microcontroller receives the signal via an interrupt through port P2.4. If a signal is detected, the time is recorded as t1, and the timer stops timing. The timer duration t = t1 - t0 is the time from transmission to reception of the ultrasonic wave. The MCU calculates the liquid level and sends it to the LCD for local display and processing. The calculated data is then transmitted to the host computer via a serial communication port. If the microcontroller system does not receive the ultrasonic echo signal, the above process is repeated after 0.5 seconds to start the next cycle. The main program flowchart is shown in Figure 3. 3.2 Host computer processing program The host computer processing program is mainly written in C#.net[4], which transmits the test data to the PC through the wireless data transmission module to realize real-time monitoring of the liquid level in the tank; at the same time, the test data is stored in the database and further processed. Its monitoring interface is shown in Figure 4. [align=center] Figure 4 Liquid level monitoring system interface[/align] 3.3 Implementation of point-to-multipoint wireless communication of the system The master station remotely monitors each distributed tank or slave station through the master control computer. In this system, wireless communication is the main means of realizing the exchange of data between the two devices. The use of wireless data transmission can save engineering wiring and greatly simplify line maintenance and repair work, thereby avoiding the great inconvenience brought by line maintenance and repair. In order to avoid conflicts, this system uses address bit method to realize the master station to address multiple slave stations. The slave station is connected to the master station in the form of a bus. Each time the master station calls with a certain address, only the slave station with the same address can recognize the call and respond. In order to avoid line congestion, when monitoring multiple slave stations, the master station sends query requests to each of the monitored slave stations in a loop, and each slave station responds to the relevant requests in turn. For example, to monitor 16 slave stations, the addresses of the 16 slave stations should be encoded first. For example, slave station 1 corresponds to address F0, slave station 2 corresponds to F1, and so on (increasing the number of slave stations only requires increasing the address code). This system defines a frame format for point-to-multipoint communication, as shown in Table 1. The frame header consists of address codes, and the frame data consists of control codes, data, and end codes. Table 1 Communication frame format The communication protocol stipulates that any receiver responds to the sender with the same control code when receiving data. For example, when a slave station sends an alarm, it corresponds to the master station receiving an alarm; when the master station sends a real-time query, it corresponds to the slave station sending information such as liquid flow rate and liquid velocity. 3.4 System test and experimental data analysis [5] This experiment was conducted in the laboratory. When the temperature was about 25℃, the test data was measured by comparing the steel tape measure with the ultrasonic liquid level tester. The test data is shown in Table 2. Table 2 shows the experimental data. The measurement distance is displayed as a 3-digit number with a resolution of centimeters. As shown in Table 2, most experimental data meet a measurement accuracy of ±1 cm (around 25℃), and the error of a small portion of the data is within the range of 2-3 cm, achieving the required testing accuracy for this liquid level testing instrument. However, the influence of ambient temperature on the propagation speed of ultrasonic waves increases the testing error. Therefore, temperature compensation is needed to correct the propagation speed and improve measurement accuracy. 4. Conclusion The innovation of this paper lies in using an ultrasonic sensor to achieve non-contact liquid level measurement, solving the problems of easy leakage, corrosion, and inconvenience in inspection and maintenance associated with contact liquid level sensors. This improves the system's reliability. Furthermore, the integrated temperature sensor within the MCU effectively compensates for and corrects the ultrasonic sensor's temperature, significantly improving the system's measurement accuracy. The hardware circuit design has high integration and reliability; the testing device is compact, convenient, easy to install and maintain, and highly functional. Due to its low cost, this instrument has good social and economic benefits and broad application prospects in the industrial field. References [1] Zhao Guangtao, Cheng Yinhang. Design of ranging system based on ultrasonic sensor [J]. Microcomputer Information, 2006, 22(1): 129-131 [2] Miao Huijing, Tang Shi, Tan Boxue. Design of ultrasonic car reversing alarm [J]. Journal of Shandong University of Technology, 2005, 19(4): 6-9. [3] Wei Xiaolong. Interface technology and system design examples of MSP430 series single-chip microcomputer [M]. Beijing University of Aeronautics and Astronautics Press, 2003.6 [4] Julia Case Bradley, Anita C. Millspaugh. C#.NET Programming [M]. Beijing-Tsinghua University Press, 2005 [5] Zhao Wenlong, Yuan Hongji, Xiong Liyun. Research on signal processing technology in car reversing rangefinder [J]. Journal of Xiamen University, 2001, 40(1): 106-110.