Design and Development of Ethernet-based Remote Liquid Level Monitoring System
2026-04-06 09:06:21··#1
Abstract: This paper mainly solves the problem of how to realize network communication in the remote liquid level monitoring system based on Ethernet. On the local embedded system, the ARM microprocessor S3C44B0X and the Ethernet controller RTL8019AS are selected as the hardware platform. The embedded TCP/IP protocol stack LwIP is ported on the real-time operating system μC/OS-Ⅱ. The server program is implemented by programming LwIP. On the remote PC, the client program is implemented by socket programming in the VC++6.0 environment. On this basis, the remote liquid level monitoring system was successfully developed. The experimental results show that it achieved good results. Keywords: Embedded system; Network; μC/OS-Ⅱ; LwIP; Socket 0 Introduction In industrial process control systems, liquid level is a very common object. Monitoring and controlling liquid level is an essential link for the system to realize its function. In the past, most liquid level monitoring devices used microcontrollers to realize point-to-point control and display [1]. The staff had to go to the industrial site to operate these instruments. Moreover, the microcontroller function was very limited and could only complete some relatively simple operations. With the development of network communication technology, Ethernet is increasingly widely used in the field of industrial control. Ethernet-based remote monitoring systems realize the effective integration of remote monitoring, control and management [2]. Using remote monitoring systems, the industrial production process is monitored through the network, and on-site information is understood in a timely manner and decisions are made quickly. The key technology of remote control lies in how to solve the network access problem of industrial field equipment. At present, there are two main methods: one is to use a PC to collect data through PC ports (such as RS232, USB interface) or data acquisition cards and provide network interfaces at the same time [3]. This method utilizes powerful PC software support and can easily realize network communication functions, but PC port resources are limited and dedicated acquisition cards are expensive and difficult to promote; the other is to use embedded systems on-site to realize network access. Embedded systems have the characteristics of low power consumption, small size, low cost, high reliability and strong real-time performance, which are more suitable for use in industrial control field. This paper combines embedded technology and network technology, and uses embedded systems on-site to realize network communication functions to transmit liquid level signals and control signals in real time. On the client PC, remote communication with the on-site embedded system is realized through socket programming, thereby achieving remote liquid level monitoring. 1. Remote Liquid Level Monitoring System Structure The structure of the remote liquid level monitoring system designed in this paper is shown in Figure 1. The processor chip is an ARM microprocessor S3C44B0X. The S3C44B0X has an 8-channel 10-bit ADC for A/D conversion to collect liquid level data, and uses an extended DAC0832 for D/A conversion to output control signals. The S3C44B0X connects to a 10M Ethernet card RTL8019AS, providing a hardware interface for network functions. μC/OS-II is ported to the S3C44B0X, providing operating system support, facilitating application development and system management. The embedded TCP/IP protocol stack LwIP is ported to the μC/OS-II platform to achieve software processing of network data, thus providing network communication functions for the embedded system. A remote PC client logs into the embedded system server, enabling real-time data interaction between the two ends via Ethernet. [align=center]Figure 1. Structure Diagram of Remote Liquid Level Monitoring System[/align] 2. Hardware Introduction and Design Samsung's S3C44B0X microprocessor chip uses an ARM 16/32-bit ARM7TDMI RISC CPU core with a clock speed of 66MHz. It provides rich peripheral functions through a series of general-purpose peripheral components. Its memory system has eight memory banks, each with 32MB of storage space, allocated through eight chip selects: nGCS0-7. In the design scheme used in this paper, nGCS0 is connected to the Flash chip AM29LV160DB, starting at address 0x00000000, with a size of 2MB; nGCS6 is connected to the SDRAM chip HY57V641620ET-7, starting at address 0x0c000000, with a size of 8MB; and nGCS3 is connected to the RTL8019AS, starting at address 0x06000000. The RTL8019AS is a highly integrated full-duplex Ethernet controller capable of simultaneous transmission and reception speeds of up to 10Mbps. It supports 8-bit and 16-bit data buses, with eight selectable interrupt request lines. It supports automatic detection of UTP, AUI, and BNC. It has built-in 16KB of SRAM for data buffering, using a 256B paging structure. The size and location of pages for transmission and reception can be manually allocated; typically, the first 12 pages are used for transmission buffering, and the last 52 pages for reception buffering. Hardware-integrated CRC checks and FIFO logical queues reduce the workload of the main CPU in processing network data. The S3C44B0X's operations on the RTL8019AS primarily focus on reading and writing to the network card registers and processing the network card's internal SRAM. 3 Software Design 3.1 Server-side Programming Based on Embedded Systems 3.1.1 Porting μC/OS-II to S3C44B0X The embedded operating system μC/OS-II can run on various types of microprocessors. Its kernel is small and efficient, and it has high modularity and portability. It supports real-time scheduling of multi-tasks. After expansion, it can support network functions, graphical interfaces, etc., making application development simpler and more feature-rich. Before using μC/OS-Ⅱ, it must be ported to S3C44B0X. The porting work mainly includes three aspects [4]: (1) Set up code related to the processor and compiler, including the definition of a series of data types, the implementation of interrupt macros and interrupt macros, and the definition of the growth direction of the stack; (2) Write 6 operating system related functions in C language: OSTaskStkInit() initializes the stack structure of the task, and 5 hook functions OSTaskDelHook(), OSTaskSwHook(), OSTaskStatHook(), OSTimeHook(), OSTaskCreateHook(); (3) Write 4 processor related functions in assembly language: OSStartHighRdy(), the function to run the highest priority ready task, OS_TASK_SW(), the task-level task switching function, OSIntCtxSw(), the interrupt-level task switching function, and OSTickISR(), the clock tick service function. 3.1.2 Implementation of TCP/IP protocol stack on μC/OS-Ⅱ LwIP (Light-weight IP) is an open-source TCP/IP protocol stack developed by Adam Dunkels et al. of the Swedish Institute of Computer Science [5]. LwIP reduces RAM usage while maintaining the main functions of the TCP/IP protocol, making it suitable for use in low-end embedded systems. The LwIP protocol stack was designed to separate all parts related to hardware, operating system, compiler and other porting and place them in the /src/arch directory. Therefore, the implementation of LwIP on μC/OS-Ⅱ is to modify the files in this directory [6]. (1) The parts related to CPU and compiler are mainly the definitions of data length, word high and low bit order in cc.h, cpu.h and perf.h files. These should be consistent with the parameter definitions when implementing μC/OS-Ⅱ. In addition, in general, the C language structure struct is 4-byte aligned. However, when processing data packets, LwIP uses the length of different data in the structure to read the corresponding data. Therefore, the _packed keyword must be used when defining the struct to make the compiler abandon the byte alignment of the struct. (2) The part related to the operating system LwIP needs to use semaphore communication. Therefore, the semaphore structure sys_sem_t and related semaphore handling functions should be implemented in sys_arch.h and sys_arch.c: including creating a semaphore structure sys_sem_new(), releasing a semaphore structure sys_sem_free(), sending a semaphore sys_sem_signal(), and requesting a semaphore sys_arch_sem_wait(). LwIP uses message queues to buffer and transmit data packets. Therefore, the message queue structure `sys_mbox_t` and its corresponding operation functions must be implemented in `sys_arch.h` and `sys_arch.c`: these include creating a message queue `sys_mbox_new()`, releasing a message queue `sys_mbox_free()`, sending a message to a message queue `sys_mbox_post()`, and retrieving a message from a message queue `sys_arch_mbox_fetch()`. Each thread in LwIP that connects to the external network has its own timeout attribute, i.e., a waiting timeout period. The porting work requires implementing the function `sys_arch_timeouts()`, which returns a pointer to the timeout queue corresponding to the currently running thread. Network data processing in LwIP requires thread operations, so the function to create a new thread, `sys_thread_new()`, needs to be implemented. However, in μC/OS-II, there is no concept of threads, only tasks. Therefore, the function `OSTaskCreate()` for creating new tasks must be encapsulated before `sys_thread_new()` can be implemented. (3) Implementation of related library functions The LwIP protocol stack uses 8 external functions, mainly to complete the high and low byte swapping of 16-bit data, the head-to-tail swapping of 32-bit data, the return string length, string comparison, memory data block copying, and clearing of data blocks of a specified length. These functions are related to the system or compiler and need to be implemented by the user. (4) Network device driver In LwIP, there can be multiple network interfaces. Each network interface corresponds to a netif structure. This netif contains the attributes and send/receive functions of the corresponding network interface. The network device driver mainly implements four network interface functions: network card initialization, network card receiving data, network card sending data, and network card interrupt handling function. 3.2 Design of client program on PC The client program implementation in the VC++6.0 environment includes the following parts: (1) Establishing the client's Socket: The client application first constructs a CAsyncSocket[7] object CltSock, and then calls the CltSock.Create() function to establish the CltSock entity. (2) Make a connection request: The client socket CltSock makes a connection request to the server socket by calling the CltSock.Connect(strAddr, nPort) function. (3) Transmit data: Override the message handling functions OnReceive() and OnSend() in the client application. In OnReceive(), receive data from the server by calling the CltSock.Receive() function; in OnSend(), send data to the server by calling the CltSock.Send() function. (4) Close the connection: The client socket CltSock closes the connection by calling the CltSock.Close() function. 4. Development of a Remote Liquid Level Monitoring Application This paper presents a remote liquid level relay self-tuning PID control system based on Ethernet. The control algorithm is implemented on a remote host (client), with communication between the two ends via TCP protocol. The local embedded system (server) processes network data and acquires and controls the liquid level height. The remote PC processes real-time data from the network and calculates the control input using PID, displaying relevant parameters. The real-time liquid level change is shown in Figure 2. As can be seen from the figure, the actual liquid level (red curve) stabilizes at the setpoint (blue curve). Simultaneously, the user interface displays the liquid level height, PID self-tuning parameters, and allows for changes to the setpoint, thus truly realizing remote monitoring of the liquid level. [align=center]Figure 2. Effect diagram of remote liquid level relay self-tuning PID control[/align] 5. Conclusion This paper addresses the problem of implementing network functionality in embedded systems. A novel design scheme is introduced and implemented, employing a Samsung ARM7 processor S3C44B0X and a Realtek 10M network card RTL8019AS. With the support of the μC/OS-Ⅱ operating system kernel, an embedded TCP/IP protocol stack LwIP is added to achieve network communication functionality, enabling Socket communication with a PC client. Based on this, an Ethernet-based remote liquid level monitoring system was developed, achieving good control results. It can be seen that this type of system has good application prospects in remote monitoring. The author's innovation: This paper introduces embedded network technology into the field of industrial process remote monitoring, proposes its own design scheme, and successfully develops a remote liquid level monitoring system. References [1] Zhang Nianlu, Wang Hong, Li Bingquan, Liquid level monitor using multiple microcontrollers, Microcontroller and Embedded System Application, 2005 No.1: 59-60. [2] Li Jianping, Remote monitoring system based on Ethernet, Journal of Zhengzhou University (Engineering Science), 2002 Vol.23 No.3: 81-83. [3] Liang Xingyan, He Weixing, Remote data acquisition and transmission using LabVIEW, Microcomputer Information, 2004 Vol.20 No.9: 44-45. [4] Jean J. Labrosse, translated by Shao Beibei et al. Embedded real-time operating system μC/OS-Ⅱ. Beijing: Beijing University of Aeronautics and Astronautics Press. 2003. [5] Adam Dunkels. Design and Implementation of the LwIP TCP/IP Stack. Swedish Institute of Computer Science. 2001. [6] Yang Ye, Implementation of TCP/IP protocol stack under real-time operating system μC/OS-Ⅱ, Microcontroller and Embedded System Applications, 2003, No.7: 80-83. [7] Ma Qinmin, Xiong Wenhui, Implementation of TCP/IP communication using MFC Socket class, Communication Technology, 2002, No.1: 37-39.