Abstract: The integration, digitalization, networking and intelligentization of equipment in the industrial field is an inevitable trend. The "information island" can no longer adapt to the current informatization. It is urgent to network the control and data acquisition of field equipment. Intelligent nodes with communication function are the key to networking equipment. CP2200 is the smallest Ethernet controller in the industrial field. When combined with a microcontroller, it can realize Ethernet intelligent nodes to complete the task of field data acquisition and control in the industrial field. Keywords: intelligent node; Ethernet; CP2200; TCP/IP protocol 1. Introduction With the development of information technology, the Internet has become more and more deeply involved in people's work and life. The measurement and control system has also gradually become networked. In today's measurement and control system, every node connected to the fieldbus network, namely sensors, transmitters, actuators, etc., is no longer a traditional instrument with a single function, but an intelligent device that integrates data acquisition, conversion, control, calculation, alarm, diagnosis and digital communication functions, also known as an intelligent module or intelligent node [1]. Intelligent nodes must adhere to certain protocols when implementing communication functions. Ethernet and TCP/IP protocols have become the most widely used, while other bus protocols such as RS485, RS232, CAN, and LANWORKS are only used in some local systems. How to implement Ethernet intelligent nodes and transmit data, and how to load TCP/IP protocols to connect to the Internet, has become a new hot topic in embedded systems research. Intelligent nodes play a crucial role in network measurement and control. Located at the field where sensors and actuators are located, they can autonomously complete field information acquisition, processing, and storage; they can also upload the acquired information via Ethernet to a PC's human-machine interface for data analysis and display. Furthermore, they can receive commands from the PC and implement various control functions for the field actuators according to system needs. If such intelligent nodes can be designed, their application areas will be very broad. 2. Ethernet Controller Chip CP2200 2.1 Introduction to CP2200 CP2200 is an Ethernet controller [2], which includes a Media Access Controller (MAC) integrating IEEE 802.3 Ethernet, a 10BASE-T Physical Layer (PHY), and 8kB of non-volatile Flash memory. It is packaged in a 48-pin TQFP package. CP2200 can add Ethernet communication functionality to any microcontroller or main processor with more than 11 port I/O pins. The 8-bit parallel bus interface supports Intel and Motorola bus modes and can be addressed using multiplexed or non-multiplexed modes. There is a mode selection pin for configuring the bus interface mode. In non-multiplexed mode, the data transfer rate can exceed 30Mbps. The on-chip FLASH memory can be used to store user constants, Web server content, or as general-purpose non-volatile memory. The last 6 memory cells of the FLASH memory have been pre-written with a unique 48-bit MAC address before leaving the factory, eliminating the serialization step that is essential in the production process of most embedded systems. The CP2200 has four different levels of functional power modes, allowing the main processor to manage total system power consumption. The interrupt select pin also allows the main processor to enter "sleep" mode and has an automatic wake-up function when a data packet arrives or when the CP2200 is inserted into the network. Full/half-duplex adaptive. [align=center] Figure 2-1 CP2200 System Block Diagram[/align] 2.2 CP2200 System Block Diagram 2.3 CP2200 Cache and Flash Memory Organization [align=center] Figure 2-2 CP2200 Cache and Flash Memory Organization Diagram[/align] As shown in Figure 2-2, the CP2200 has a 2K transmit cache and a 4K receive cache, which share the same address space and are accessed via RAMADDRH:RAMADDRL pointers; and an 8K on-chip FLASH with its own address space, accessed via FLASHADDRH:FLASHADDRL pointers. 2.4 The CP2200's register master can access the CP2200's direct or indirect registers via a parallel interface, thereby controlling the CP2200. The CP2200/1 has 114 internal direct registers and 9 indirect registers. These registers are divided into 11 categories based on function: interrupt status and control registers, reset source registers, power mode registers, transmit status and control registers, receive interface status and control registers, receive buffer status and control registers, FLASH access registers, MAC access registers, MAC indirect registers, and PHY status and control registers. [align=center] Figure 3-1 Connection Schematic of C8051F020 and CP2200[/align] 3. Connection Schematic of Intelligent Node This system adopts a non-multiplexed approach. The P7 port of the C8051F020 is used as the data bus to connect to the D[0:7] of the CP2200; the P6 port is used as the address bus to connect to the A[0:7] of the CP2200; P5.7 is used as the chip select of the CP2200; the P4.5 of the C8051F020 is connected to the CP2200 to perform a reset operation, and must maintain a low level for at least 15μs. The CP2200 operates in interrupt mode. The CP2200 has 14 interrupt sources. When an event occurs, an interrupt request is sent to the C8051F020. 4. Ethernet Communication Interface Software Design [align=center] Figure 4-1 Typical Ethernet Frame[/align] This system design uses the IEEE 802.3 Ethernet protocol. Its frame structure is shown in Figure 4-1. This frame format is used for both transmission and reception operations on the physical channel. The preamble, start-of-frame bit, CRC checksum, and necessary padding are automatically added/removed by hardware and are independent of upper-layer software. Length/Type is the type field, indicating the data type of the frame; different protocols have different type fields. For example, 0800H indicates an IP packet, 0806H indicates an ARP packet, 814CH indicates an SNMP packet, and 8137H indicates an IPX/SPX packet (values less than 0600H are used for IEEE 802 and indicate the packet length). Data is the data field, and this field cannot exceed 1500 bytes because Ethernet specifies that the maximum length of the entire transmission packet cannot exceed 1514 bytes. Since the minimum data packet size for Ethernet frame transmission is 64 bytes, after deducting 18 bytes (Destination MAC Address, Source MAC Address, Length/Type, and CRC), 46 bytes of data must still be transmitted. When the data segment is less than 46 bytes, it is padded with zeros to reach the minimum frame length of 64 bytes. 4.1 CP2200 Initialization Process The system must be initialized after power-on to function properly. Figure 4-2 shows the initialization process. [align=center] Figure 4-2 CP2200 Initialization Process[/align] 4.2 Frame Reception and Transmission Process Once system initialization is complete, the C8051F020 can send collected data to the master PC or respond to the master PC's ARP requests, sending its own IP address and MAC address to the master PC. After system reset and initialization, if the receive buffer, filter, and hash table are also initialized, the smart node can receive commands, control data, download update programs, or ARP requests from the master PC. When the CP2200 receives a new frame, it notifies the C8051F020 via an interrupt, and then reads the frame as shown in Figure 4-3. [align=center] Figure 4-3 Frame Reception and Transmission Process[/align] Frame abnormal termination only occurs in half-duplex mode, typically caused by network congestion. 4.3 TCP/IP trimming and design The intelligent node part is actually a relatively independent microcontroller system. To complete the task of uploading and downloading, it often communicates with the main control PC. In some application environments, it also needs to perform data acquisition and processing tasks. Relatively speaking, the microcontroller system resources are limited. Network protocols are usually designed in layers, and the TCP/IP protocol is also a layered structure. It consists of four conceptual layers based on the hardware layer [3], namely the network interface layer, the Internet layer, the transport layer and the application layer. In order to achieve communication with the main control PC at the peer layer, at least IP protocol and TCP or UDP protocol should be designed and implemented in our intelligent node. However, the TCP/IP protocol is a very large system. It is impossible to integrate all protocols. It can only be trimmed based on TCP/IP and then used as an embedded application, solidified into the ROM of the microcontroller system, so that the data transmission is encapsulated in the TCP/IP protocol format, thereby achieving the purpose of transmission on the Internet. Implementing the TCP protocol requires a large capacity data storage to store the data information waiting for acknowledgment. If multiple TCP connections are established at the same time, additional RAM is required to store connection information, such as IP address, port number, buffer pointer, etc. UDP's header is only 8 bytes, much more compact than TCP's 20-60 bytes, offering higher data transmission efficiency. Furthermore, UDP is a connectionless protocol, allowing for a lighter, faster interface, making it better suited for real-time requirements in industrial applications, particularly advantageous in microcontroller-based embedded systems. Therefore, we chose UDP as the transport layer protocol for our intelligent node's higher-level protocols, instead of TCP. We also implemented ARP, ICMP, and IP protocols, while other protocols, along with TCP, were trimmed. During the design process, we considered both real-time requirements and network congestion and utilization. Therefore, we couldn't immediately initiate communication after each data acquisition, as this would reduce line utilization due to the excessive headers from various protocols. Sending data packets of 1500 bytes each time would also reduce real-time performance. Therefore, we used 256 bytes as a data frame for each communication process. 5. Flowchart of the Main Program for the Intelligent Node [align=center] Figure 5-1 Flowchart of the Main Program for the Intelligent Node [/align] 6. Summary In today's industrial field, there is an urgent pursuit of equipment integration, digitization, networking, and intelligence. How can we achieve networking of field equipment? Ethernet intelligent nodes are particularly important in such applications. The author's innovation lies in using the CP2200 Ethernet controller chip to implement the hardware and software design of the Ethernet intelligent node. With slight modifications, it can fully utilize its powerful communication, data acquisition, and control functions when applied to a specific field. References: [1] Feng Dongqin. Ethernet and TCP/IP[J]. Automation Instrument. 2003.24(5):67-70 [2] User Manual of cp220/1. http://www.silabs.com. [3] Xie Xiren. Computer Network (Fourth Edition)[M]. Beijing: Electronic Industry Press. 2003.6 [4] Men Lei et al., Li Yuqiang et al. Research on Ethernet-based Embedded System[J]. Journal of Shenyang University of Technology, 2004.4. [5] User Manual of C8051F020/1/2/3. http://www.silabs.com. [6] Xi Bofang Yanjun. Research on Network Communication Technology in Industrial Ethernet. Microcomputer Information. 2005.21(2):148-149 [7] Luo Zhijia et al. Application of Ethernet-based Distributed Data Acquisition and Monitoring System. Microcomputer Information. 2006.22(1):22-24