Abstract: This paper introduces the structure of an embedded IP load cell based on W31OOA and several implementation methods of its network interface; it focuses on the implementation of the network interface and Web function based on the TCP/IP protocol stack chip W3100A; and provides an application example of the embedded IP load cell. Keywords: IP sensor, network interface, W31OOA, load cell. In industrial production, traditional measurement and control systems have gradually shifted from centralized to distributed. The intelligence of sensors and actuators distributed in the field is increasing, and their communication requirements are becoming more urgent. With the rapid development of the Internet, the TCP/IP protocol is gradually becoming a globally universal network communication protocol standard. If the field sensors implement the TCP/IP protocol, that is, embed the network connection function into the field sensors, making the traditional sensors truly independent network nodes, data acquisition and information transmission can be directly carried out on the Intranet/Internet via Web, which not only unifies the standard but also achieves the purpose of remote control and operation. The embedded IP load cell based on W31OOA is designed to achieve this purpose. 1. IP Load Cell Structure The embedded IP load cell is a new type of sensor with Internet functionality, developed based on intelligent sensors. Essentially, it implements a TCP/IP network communication protocol interface on top of a traditional sensor, allowing the sensor to communicate directly with the computer network as a network node. Its main components include: a sensing unit, an intelligent processing unit, and a TCP/IP communication protocol interface. Figure 1 shows the structural block diagram of the embedded IP load cell. The working principle of the entire sensor is as follows: A traditional sensor converts the measured load signal into an electrical signal, first converting it into a digital signal through an A/D converter, then processing the data (filtering, calibration) by a microprocessor before transmitting the result to the network; data exchange with the network is completed by a network interface module based on the TCP/IP protocol. The embedded IP load cell's internal memory stores the sensor's physical characteristics, such as offset, sensitivity, and calibration parameters; the microprocessor handles data processing and output calibration; and the TCP/IP protocol enables the sensor's network connection. Compared to traditional sensors, embedded IP sensors based on the W3100A offer advantages such as reliability, low cost, and good scalability. They can directly process and manipulate raw data internally and exchange data with the outside world via Intranet/Internet, thus exhibiting miniaturization, networking, and intelligence. Because the sensor can interconnect with Intranet/Internet, resource sharing is achieved. 2. Several Implementation Schemes for the TCP/IP Protocol Stack The key to implementing IP sensors lies in the design of the network interface, and the key to implementing the network interface lies in the implementation of the TCP/IP communication protocol. Currently, there are two main implementation methods: ① Implementing the TCP/IP protocol stack in software. This involves porting the TCP/IP protocol stack to the system and then calling relevant API functions to achieve network communication. Alternatively, without porting, the corresponding protocol layers can be simplified based on the standard TCP/IP protocol, and relevant API functions can be written to complete simple TCP/IP communication. However, this method requires the support of an operating system, a high-performance MCU, and a large-capacity memory. ② Directly using a TCP/IP protocol stack chip. The main advantage of this approach is that the application system design does not need to consider any network protocols. It only needs to interpret and execute the instructions and data transmitted by the network chip to achieve connection with the Internet and data transmission to the network, without the need for operating system support. The embedded IP load cell based on the W3100A chip in this paper is implemented using this method. 3 Sensor System Hardware Design 3.1 Introduction to the W3100A Chip The W3100A is a TCP/IP protocol stack chip manufactured by Wiznet, a South Korean company. It includes protocol layers such as TCP (Transmission Control Protocol), IP (Internet Protocol), UDP (User Datagram Protocol), ICMP (Internet Control Message Protocol), and DLC (Data Link Control), as well as the MAC protocol. The chip provides two interfaces to the upper application layer—an MCU interface and an I2C interface—and one MII (Media Independent Interface) interface to the lower physical layer. The chip supports full-duplex data communication of 4 M to 5 Mb/s; it has an internal dual-port RAM data buffer, is packaged in a 64-pin LQFP package, and its internal structure is shown in Figure 2. The chip internally provides 512 bytes of control register storage space and 16 KB of data storage buffer. An 8 KB transmit data buffer is used by the MCU for data transmission; the MCU can only write to it, not read from it. An 8 KB receive data buffer is used by the MCU for data reception; the MCU can only read from it, not write to it. The chip provides registers for the MCU to access, specifically categorized as follows: control registers (command, status, and interrupt); system registers (gateway address, subnet mask, IP address, etc.); pointer registers for data transmission and reception; and channel registers for channel operations. Refer to the literature for the functions and addresses of each register. 3.2 Hardware Interface and Data Transmission The W3100A provides both parallel and serial communication methods with the MCU. Figure 3 shows the serial connection method based on I2C. The MCU is the processor in the sensor, and the Ethernet physical layer device uses the RTIL8201 chip. The W3100A provides an MII interface to connect with the RTL8201. Pins RX_CLK, RXDV, RXD[3;0], and COL are used for data reception, while TX_CLK, TXE, and TXD[3;0] are used for data transmission. The MCU provides a simulated I2C interface for communication with the W3100A. I2C is a serial communication bus, using the data line SDA and the clock line SCL to complete communication. TCP connections are divided into active connections (TCP client mode) and passive connections (TCP server mode). This article mainly uses the TCP passive connection method, as shown in Figure 4. First, the chip's TCP/IP initialization must be completed, mainly by setting the necessary registers. These registers include GAR, SMR, SHAR, and SIPR. After the above registers are set, the chip is activated by executing bit 0 of the control register CO_CR, Sys_init. Second, the corresponding channel is set, such as channel 0, with the protocol selection register C0_SOPR set to 0X01 to select the TCP protocol. The Socket_Init function in the channel O control register CO_CR is executed, simultaneously setting C0_Tw_PR, C0_TR_PR, and CO_TA_PR to the same value. Then, the Connect and Listen command bits of C0_CR are executed, establishing a TCP connection. TCP data transmission and reception can only occur after the connection is established, and the data buffer space size is specified by setting RMSR and TMSR. The TCP data transmission process is performed using C0_TW_PR and CO_TA_PR, which have the same initial value. The MCU then increments the value of C0_TW_PR based on the amount of data to be transmitted. Finally, the difference between C0_TW_PR and C0_TA_PR represents the size of the free data buffer space. A transmission command is executed, and the value of C0_TA_PR is incremented. After the data transmission is complete, their values are equal again. 4. Sensor System Software Design The workflow of the IP load cell is as follows: First, the load signal is acquired; second, the signal is converted from digital to digital (A/D) and the result is stored in EEPROM. The signal and processing result can be embedded into a pre-defined webpage stored in EEPROM for client access via the Internet. Simultaneously, the load signal data is displayed on the local LCD. The W31130A operates similarly to the Windows Socket API; therefore, the program is written in C language based on the Socket API, using the instrument as a server within Cygnal's integrated development environment. For the C8051F021, since the W3100A is used to implement the TCP protocol, the program is much simpler. The main communication program flow is shown in Figure 5. The network configuration file is pre-stored in EEPROM. The instrument's local IP address is set to a static IP address. If a static IP address is not available, a Dynamic Host Configuration Protocol (DHCP) can be used to dynamically obtain one. 5. Application Examples Sodium dichromate is an important inorganic chemical raw material. In the production of sodium dichromate, batching is a crucial step. Due to the harsh environment at the batching site, with abundant toxic dust and high noise levels, the health of workers is severely affected [...]. Traditional computer batching systems often fall short in remote monitoring due to the limited remote transmission capabilities of their sensors. Therefore, developing IP sensors with web functionality is essential. The block diagram of the sodium dichromate batching system based on IP sensors is shown in Figure 6. The system's web operation is based on a client/server model. The sensor consists of a web browser and a web server, communicating via the HTTP protocol. Therefore, the upper-layer protocol of the sensor should also use HTTP. To enable interaction between the browser and the embedded web sensor, in addition to resolving the TCP/IP communication protocol interface, an EEPROM should be provided in the sensor to store the corresponding web page files. During interaction, HTTP uses a Uniform Resource Locator (URL) to determine which resources the sensor should provide to the browser. To save space, a flexible Hush algorithm is used. Each file in the EEPROM has a unique Hush value, allowing for quick calculation of the file address during access. In addition, it can create dynamic web pages based on special tags embedded in the web page, that is, display real-time collected data and perform control operations.