Serial to Ethernet interface converter based on RTL8019AS
2026-04-06 02:40:22··#1
0 Introduction With the increasing popularity of internet applications and the continuous improvement of information sharing, it has become a trend for microcontroller-centric data acquisition, detection, and control systems to connect to networks and share information. The traditional internet application is gradually shifting from a PC-centric era to a microcontroller-centric era. However, in the current industrial control field, microcontroller systems mainly communicate via RS-232, RS-485, and CAN bus protocols, which cannot directly connect to the internet, thus leaving the system isolated. These systems widely use low-cost 8-bit microcontrollers, which generally only have an RS-232 asynchronous serial communication interface. To connect to the internet, the communication interface must be modified. This modification involves not only physical changes to the interface but, more importantly, changes to the data format and conversion of the communication protocol. Therefore, this paper proposes a design scheme for an RS-232 serial communication interface to an RJ45 Ethernet interface converter. Existing microcontroller systems can use this converter to connect to Ethernet and further access the internet. This scheme also provides a reference for the development of embedded network systems. 1. Overall Structure and Working Process of the Converter The RS-232 serial port to RJ45 network interface converter consists of a control unit, a network interface unit, and a power supply unit. The overall structure is shown in Figure 1. The control unit is responsible for data transmission and reception and data format conversion; its core is a microcontroller. The network interface unit completes the encapsulation and decapsulation of Ethernet frames and signal transformation. The power supply unit provides power to the control unit and the network interface unit. The microcontroller system has a standard RS-232 serial asynchronous communication interface. To access the Internet through the converter, it is generally necessary to first connect to a local area network (LAN), which typically uses Ethernet, and then connect to the Internet via Ethernet. Therefore, the network interface of the converter proposed in this paper uses an Ethernet RJ45 interface, as shown in Figure 2. If data is sent from the microcontroller system to the Internet, the asynchronous serial data frame sent by the microcontroller system is converted into an Ethernet data frame by the converter and then uploaded to the Internet; the reverse is also true. 2. Hardware Design 2.1 Control Unit This unit consists of a microcontroller, memory, and latches, as shown in Figure 3. The microcontroller used is the W78E51, an 8-bit MCU (microcontroller) from Winbond, Taiwan. This chip has a large internal program memory of 32kB and provides ISP in-system programming functionality for easy program debugging and software upgrades. Since the W78E51's on-chip RAM is very limited, a 62256 external data memory is used to temporarily store data frames from Ethernet and RS-232 to handle data packet reception and processing. Its chip select signal /CE is connected to the 78E51's P2.7 port, and /OE and /WE are connected to the 78E51's /RD and /WR respectively. The 62256 memory occupies 32kB of the microcontroller's external data address space 0000H~7FFFH. The MAX232 level conversion chip, with a few external components, can convert TTL and RS-232 levels. 2.2 Network Interface Unit: The network control unit consists of an Ethernet controller, memory, and coupling isolation transformer, as shown in Figure 4. The network controller uses the RTL8019AS, a highly integrated dedicated Ethernet interface chip manufactured by REALTEK. It supports PNP auto-detection, has embedded 16 kB of SRAM, and features a full-duplex communication interface. The RTL8019AS is designed for the ISA bus and is used to implement the network's physical layer protocol. This mainly includes the physical connection between the network controller and the network cable, MAC (Media Access Control), frame assembly and disassembly, frame transmission and reception, error checking, data signal encoding/decoding, and serial-to-parallel conversion. The RTL8019AS's packet transmission/reception process is completed through two DMA operations. The local DMA handles data transfer between the RTL8019AS and the on-chip FIFO queue, facilitating data exchange between the controller and the network cable. The remote DMA handles data transfer between the RTL8019AS and an external processor. Since the RTL8019AS operates in jumper mode, with IOS0 and IOS3 connected to high level and IOS1 and IOS2 connected to low level, the I/O base address of the RTL8019AS is determined to be 240H. The W78E51 microcontroller operates the RTL8019AS via the address bus and read/write bus. Therefore, SA0~SA4 and SA6 of the RTL8019AS address bus are connected to the microcontroller address bus ADDR8~ADDR12 and ADDR15 respectively, SA9 is connected to high level, and SA5, SA7, SA8 and SA10~SA19 are all grounded. The I/O base address 240H of the RTL8019AS is mapped to the microcontroller address 8000H. In this way, the W78E51 can access the external data memory 8000H to realize the operation of the RTL8019AS base address. The RTL8019AS's data transmit and receive pins TPOUT-, TPOUT-, FPIN-, and FPIN+ are connected to the Ethernet RJ45 interface via an isolation filter transformer 20F-01. This coupling isolation transformer primarily functions as a signal transmission, impedance matching, waveform restoration, noise suppression, and high-voltage isolation transformer. The W78E51 microcontroller controls the various operations of the RTL8019AS. Network data flows into the RTL8019AS's buffer via the RJ45 interface, is processed by the RTL8019AS, and then read by the W78E51 into a 62256 temporary storage unit. The temporarily stored data is transmitted to the microcontroller system or other devices via the RS-232 serial port. When sending data to the Ethernet, the microcontroller system or other devices send data packets to the data buffer allocated in the 62256 by the W78E51 via the RS-232 serial port. Then, the framed data is written to the RTL8019AS's on-chip SRAM via remote DMA operation and finally sent to the Ethernet via the RJ45 interface. 2.3 Power Supply Unit To simplify the converter's structure and reduce cost, the power supply is external, employing two power supply methods: USB power and a +5V universal power supply. The converter is designed with two power interfaces. 3 Program Flow The program flow is shown in Figure 5. After the converter powers on and resets, the main program enters the state of detecting Ethernet data packets, analyzing the type of received data packets and processing them accordingly. If the microcontroller system sends data to the converter, the converter enters the serial port interrupt service routine to process the received serial data packets. 4 Conclusion This converter was successfully applied to the renovation project of a coal mine fan monitoring system. Before the renovation, only the computer connected to the fan monitoring microcontroller system could observe the fan's operating status. After the renovation, any computer connected to the mine's local area network can observe the fan's operating status. Although this converter basically realizes communication between the microcontroller system and Ethernet, the converter's function is relatively simple. Embedding the HTTP protocol into the converter for Web-based communication would be even better.