Share this

Design and Implementation of a Microcontroller-Based Embedded Network Access Module

2026-04-06 06:06:42 · · #1

Abstract: This paper proposes a design scheme for a network access module based on a common microcontroller. The network access module is a low-cost solution for measurement and control network access. It can easily and directly connect measurement and control equipment with interfaces such as RS-232 to a local area network (LAN). Utilizing abundant and readily available LAN resources, a series of distributed measurement and control systems can be formed, serving as a new and practical method for distributed control of measurement and control networks.

Keywords: network access module, TCP, IP, UDP, ARP

I. Introduction

Building a distributed measurement and control system using existing LAN resources is a low-cost, highly reliable, and fast technical solution. There are three main ways to construct a LAN measurement and control system. Solution 1 uses a PC, network card, and data acquisition card to form a LAN measurement and control gateway. This gateway performs protocol conversion, connecting the distributed measurement and control system (composed of measurement and control equipment connected by fieldbus) to the LAN. The management PC is placed within the LAN, forming a larger automated control system. This method is very expensive and only suitable for large control systems. Solution 2 uses an embedded system, LAN card, and data acquisition card to form the LAN measurement and control gateway. An embedded system is essentially a microcomputer whose hardware and software can be configured according to user needs. Therefore, it is a simplification and miniaturization of the first solution. Its cost is lower than the first solution, but the price is still relatively high. Solution 3, due to recent network development trends, utilizes a microcontroller and a LAN interface chip to form a network access module. It replaces the PC with a microcontroller and the LAN card with a LAN interface chip, requiring only one network computer for monitoring, significantly reducing the price of the measurement and control solution. This enables measurement and control equipment to connect to the local area network (LAN) at a low cost and in a simple manner, making network-connected home appliances and IC card network control a reality, and allowing LAN-based distributed measurement and control systems to develop rapidly.

II. Basic Principles of TCP/IP Networks and the Composition and Structure of Network Access Modules

1. Basic principles of TCP/IP networks and the specific connection process of TCP/IP.

The TCP/IP protocol suite is a set of protocols that interconnect various systems on the Internet, ensuring accurate and fast data transmission over the Internet. Referring to the Open Systems Interconnection (OSI) model, TCP/IP typically adopts a simplified four-layer model: Application Layer, Transport Layer, Internet Layer, and Network Interface Layer. The Network Interface Layer consists of lower-level protocols that control data transmission between different machines on the same physical network, such as the Ethernet protocol, serving as the lower physical and electrical layer interface of the TCP/IP protocol suite. The Internet Layer allows information to be sent to hosts on adjacent TCP/IP networks; the IP protocol is the mechanism for data transmission at this layer and defines the format of IP data frames. Simultaneously, to establish interconnection between networks, the ARP address resolution protocol is provided to map IP addresses to network physical addresses, and the RARP reverse address resolution protocol is used to map physical addresses to IP addresses. The Transport Layer allows network programs to obtain data through defined channels and ports, such as defining the port number of the network connection, and implements the Transmission Control Protocol (TCP) and User Data Protocol (UDP) at this layer. The network application layer needs to define the session process for the application, such as HTTP, FTP, Telnet, etc.

2. Composition and Structure of Network Access Module

The network access module is a local area network (LAN) network protocol converter. It primarily performs the conversion between the LAN TCP/IP protocol and the RS-232 protocol of the fieldbus for measurement and control equipment at the network layer, enabling interconnection between the LAN, measurement and control equipment, and fieldbus networks, and facilitating data exchange between devices on different LANs and fieldbus networks.

Because network access modules have a wide range of interfaces and are inexpensive, they can directly connect measurement and control equipment with RS-232 and RS-485 interfaces (which require adapters) to a local area network (LAN) to form a distributed LAN measurement and control system, without the need to set up a fieldbus.

The network access module is shown in Figure 1. It mainly consists of a microcontroller and a local area network interface chip.


Figure 1. Composition principle and structure diagram of the network access module



The LAN interface chip can be a general-purpose interface chip conforming to the IEEE 802.3 protocol, such as the RTL8019AS. These chips complete the communication tasks with the LAN at the physical layer, use an RJ-45 connector, and can be directly connected to the LAN.

The microcontroller in the network access module can be a common microcontroller, such as the AT89C52 from the AT series. The microcontroller's flash memory (or external EEPROM) is programmed with the TCP/IP communication protocol and field serial bus communication protocols such as RS-232 and RS-485, written in assembly language. It is responsible for completing the protocol conversion and data exchange tasks at the Internet layer and network interface layer. It unpacks UDP packets received from the local area network, extracts the data, and then reassembles them into frames according to the RS-232, RS-485, and other field serial bus communication protocols before sending them to the measurement and control equipment; or it reassembles data frames sent by the measurement and control equipment into IP packets and sends them to the local area network server.

III. Hardware Design and Working Principle of Network Access Module

1. Hardware Schematic Diagram

The system provides an RJ45 interface for connecting to the local area network (LAN) and an RS-232 bus serial port for controlling measurement and control equipment. The network access module can unpack UDP datagrams from the LAN and send them to the corresponding serial port, or encapsulate data from the serial port into UDP packets and send them to the LAN. The microcontroller uses a 62256 external RAM chip to temporarily store data, save intermediate processing results, and serve as a buffer for data communication with the UDP server. For example, if a UDP data transmission error occurs and retransmission is needed, the data is retrieved from RAM and sent to the network again. Only after the data is correctly received is the frame deleted from the memory unit. An EEPROM chip is used, which can be used as a watchdog timer (for automatic reset in case of microcontroller program failure) or to store IP addresses, network card physical addresses, and other parameters. Specifically, the hardware block diagram of the network interface module is shown in Figure 2.


Figure 2. Hardware structure principle block diagram of the network access module



The AT89C52 microcontroller connects to the RTL8019AS network card chip's data ports SD0-SD7 via ports P0.0-P0.7, and to the network card chip's address ports SA0-SA4 via ports P2.0-P2.4. Ports P3.7 and P3.6 correspond to the network card chip's IORB and IOWB ports, respectively, enabling data exchange and TCP/IP communication. Ports P2.5 and P2.6 correspond to the AT24C512's serial EEPROM's SCL and SDA ports, respectively. The AT24C512 stores device parameters such as IP addresses and network card physical addresses. The data interface between the microcontroller and the 62256 RAM chip uses time-division multiplexing chip select mode, exchanging data between ports P0.0-P0.7 and the 62256's D0-D7 ports. Ports P1.0-P1.7 control the physical addresses of the 62256 memory units for data storage control. The microcontroller communicates with the MAX232 chip (which converts TTL to RS-232 levels) via ports P3.0 to P3.3, controlling the chip select signal for serial communication. Data is then transmitted via the corresponding serial port lines. When receiving data, the MAX232 chip is selected via the CTS control signal. The MAX232 chip then outputs an interrupt signal to facilitate serial data exchange with the microcontroller and implement a custom communication protocol.

2. Working principle and process of network access module

After the network access module is powered on and reset, it first performs system initialization, and then accepts data network transmission preprocessing (data packing and unpacking), network data transmission, and data processing of custom communication protocols.

Depending on the microcontroller program, TCP/IP data communication can be implemented in two ways: using TCP and UDP for data transmission. However, while TCP uses reliable connections, resulting in high system reliability, the overhead of establishing reliable connections is significant, making it unsuitable for applications with small data volumes. Therefore, UDP is used for data transmission, employing upper-layer error retransmission protocols for error control. The microcontroller algorithm flow using UDP is as follows:


Figure 3. Algorithm flow of UDP communication for microcontrollers



Write the corresponding UDP control processing program into the microcontroller's memory to perform UDP data packing, unpacking, verification, ARP address resolution, and custom communication protocol handshake connection to ensure the correct transmission of measurement and control data.

IV. Implementation of Network PC Communication Software Corresponding to the Network Access Module

The network computer uses the Winsock mechanism of Windows TCP/IP programming to control and communicate with the network access module. A TCP/IP port monitoring program is set up on a server computer to monitor UDP datagrams sent to the local area network by the network access module in real time. For UDP datagram transmission, the upper-layer server first establishes a socket, then binds it to a local interface. UDP data is read from this bound socket interface, and after the UDP data is unpacked, it undergoes processing according to a user-defined communication protocol (including security verification, error retransmission, and user-defined frame format processing). The specific UDP data transmission and reception process between the microcontroller and the computer is shown in the following diagram:


Figure 4. UDP Data Communication Winsock Mode Workflow



V. Several Key Technical Issues in the Application of Network Access Modules

In the actual process of building a local area network (LAN) monitoring and control system using network access modules, the following issues should be noted according to the actual application requirements:

1. Network access module processing and transmission speed

In a local area network (LAN) monitoring and control system utilizing network access modules, the data exchange speed between the host PC and the lower-level monitoring and control equipment depends on the processing and transmission speed of the network access module. The processing speed of the network access module primarily depends on the actual amount of data computation required and the processing speed of the microcontroller. The transmission speed depends on the speed of the LAN interface chip, the processing speed of the microcontroller, and the method of data exchange between the network access module and the monitoring and control equipment. In typical monitoring and control systems, only control commands and measurement feedback data are transmitted; the data volume and the computational load required by the microcontroller are relatively small. The network access module connects to the monitoring and control equipment via an RS-232 serial port, with a communication rate of only tens to hundreds of kb/s. In this case, the speed of the LAN interface chip (10 Mb/s) and the speed of the microprocessor are far greater than the serial communication speed. Therefore, the transmission rate of the network access module depends on the communication rate of the serial port.

The speed of the local area network interface chip has reached 10 Mb/s, which is much faster than the speed of the microprocessor, much faster than the data exchange speed between the network and the measurement and control equipment, and much faster than the requirements of the measurement and control work, thus meeting the application requirements.

2. IP address of the network access module

In a local area network (LAN) monitoring and control system, monitoring and control equipment must determine its IP address before entering the LAN through a network access module. There are two methods for obtaining the IP address of a network access module: active IP and static IP. Upon power-up, the network access module software automatically searches the system for a proxy server. If a proxy server exists, it requests and is assigned an active IP address as the network access module's IP address. If no proxy server exists, a static IP address set up in hardware by the microcontroller is used as the network access module's IP address. Typically, when the number of network access modules to be controlled within the LAN is small, such as no more than 255 workstations within the same LAN, independent IP addresses can be assigned to each network access module to simplify processing and facilitate microcontroller implementation. Otherwise, a proxy server must be used to dynamically allocate IP addresses.

3. Safety Control

In small, closed local area networks (LANs), security is not a major concern. However, to ensure system security, the microcontroller in the network access module uses 48- to 128-bit user passwords to protect the monitoring and control equipment, and some critical command codes are encrypted. Authorized users can modify and set their own passwords. Even if an unauthorized user steals the IP address of the network access module, without the password, they cannot operate the monitoring and control equipment through the network access module.

4. Real-time issues

Real-time performance is crucial for measurement and control systems in many situations, but local area networks (LANs) are not real-time systems. Due to their Carrier Sense Collision Detection (CSMA/CD) communication method, IP packet transmission in LANs is inherently delayed and prone to loss. This is the biggest drawback of using LANs to form distributed measurement and control systems. However, with the increasing speed of modern LANs—hundred-megabit or even gigabit networks—or in small, enclosed LANs where network congestion is significantly reduced, IP packet collisions are almost nonexistent. This greatly reduces transmission delays and packet loss, preventing disruption to the normal operation of the measurement and control system. Furthermore, by adding an acknowledgment protocol above the network layer and, depending on the application, adding a buffer of a certain size to temporarily store unacknowledged data packets until an acknowledgment is received, the packet loss problem can be largely overcome. Additionally, network cables directly connecting to the network access module can be routed through a switch to ensure switching speed.

VI. Application Prospects of Network Access Modules

Microcontroller-based network access modules can meet the requirements of general measurement and control systems. Moreover, their low cost and small size make them easy to implement in projects such as smart buildings and campus card systems. They can be directly embedded into measurement and control equipment as a module, enabling the production of next-generation network measurement and control equipment, information appliances, and other embedded application systems. This will undoubtedly greatly promote the development of local area network measurement and control systems, information appliances, and other automatic control equipment.

References

[1] Mou Yingfeng, Xu Dianguo, Zhang Donglai, Single-chip solution for connecting home appliances to the Internet based on embedded TCP/IP protocol stack, Electronic Technology Application, Vol. 28, No. 6, 2002

[2] Behrouz Forouzan, Catherine Coombs, Sophia Chung Fegan (eds.), Pan Yi and Zhu Danyu (translators), Wu Shilin (reviewers), Data Communication and Networks, Beijing: China Machine Press, April 2000, 1st edition, pp. 91-114, 229-236

[3] Yu Yongquan, ed., ATMEL89 Series Microcontroller Application Technology, Beijing: Beijing University of Aeronautics and Astronautics Press, April 2002, 1st edition, pp. 124-192, pp. 321-326

[4]RTL8019AS chip information, Realtek Full-Duplex Ethernet Controller with Plug and Play Function Specification, Realtek Semi-conductor Co.,Ltd. May 1st. 2001

Read next

CATDOLL 102CM Li (TPE Body with Soft Silicone Head)

Height: 102cm Weight: 15.5kg Shoulder Width: 26cm Bust/Waist/Hip: 51/46/66cm Oral Depth: 3-5cm Vaginal Depth: 3-13cm An...

Articles 2026-02-22
CATDOLL Kara TPE Head

CATDOLL Kara TPE Head

Articles
2026-02-22
CATDOLL 123CM Sasha TPE

CATDOLL 123CM Sasha TPE

Articles
2026-02-22