At present, most embedded systems are still in the stage of separate application. In the industry, only the control communication networks (such as CAN, I2C, PROFIBUS, etc.) isolated from the Internet are used to implement MCU networking. If you can connect the embedded system to the Internet that is widely used, or use the Internet as the medium on the basis of the existing network, you can easily and inexpensively transfer information to almost any place on the world for remote monitoring. Therefore, embedded Internet technology came into being and became a hot spot in the industry.
2. Embedded Internet Technology Principles and Solutions
Embedded Internet technology, that is, the integration of embedded systems with the Internet to achieve system networking, involves two key issues that are the medium for the transmission of information and the protocol used.
The connection to the Internet can be via Ethernet or telephone lines. In most workplaces, Ethernet is provided and electronic devices can be plugged in at any time through a hub (HUB). In homes, carriers such as power lines and telephone lines are also available. If it is connected to a LAN, you only need to set a hard or soft IP address for the device. If you are using a telephone line, you can use the telephone user's ID. Realizing the access connectivity of embedded electronic devices now is almost no problem. So the key problem of embedded Internet technology lies in how to realize the widely used TCP/IP communication protocol in the MCU. However, the TCP/IP communication protocol has relatively high requirements for computer memory and computing speed, and the ordinary single-chip microcomputer cannot meet its requirements.
According to the characteristics of various MCUs, the methods for implementing the TCP/IP protocol can be divided into the following types:
1) High-end MCU chip
Using ARM core series processors or high-end MCUs such as the 386EX, its fast operation speed and high performance can run real-time operating system (RTOS) on the chip, and can also embed complete TCP/IP protocol.
2) 32-bit MCU chip
32-bit machines also have sufficient resources and capabilities to run the TCP/IP protocol and some embedded operating systems. Therefore, in principle, the idea is the same as high-end machines.
3) 8/16-bit MCU chip
Due to the processing power and storage issues of 8-bit and 16-bit MCUs, it is difficult to implement the TCP/IP protocol. Therefore, according to its characteristics, the TCP/IP protocol is simplified to retain its most basic things. At the same time, the upper layer protocol may not be used or simply implemented. The original TCP/IP protocol will be converted into an embedded TCP/IP protocol, which we will describe later.
According to the implementation method of the TCP/IP protocol in the MCU and the requirements of the embedded system, the general implementation of the embedded Internet solution is as follows:
· The standard network protocol (TCP/IP) has been extended to embedded devices. The embedded system realizes the networking function. Each device can be connected to the Internet. This is the best solution to the problem and the future direction of development of electrical appliances and equipment. For example, Netscillon's ARM+NET series chips can be embedded in any device to achieve the Internet. This solution requires high performance of the microprocessor.
· Implemented through a dedicated web server. The 8-bit and 16-bit MCUs are widely used in existing embedded systems, and do not require that each device be directly connected to the Internet. Users can access the device through the Internet and then use the lightweight network to expand to multiple devices. On the device. Such as power lines, RS-485, RS-232, I2C and so on. The dedicated WEB server can be used as a sub-network device router to convert and implement communication between the embedded system and the external network. emWare is a web server designed specifically for embedded microcontroller devices.
· Connect through emGateway. The embedded gateway runs the TCP/IP protocol, and is connected to the lightweight network of embedded devices (such as RS-232, RS-485, fieldbus, etc.) to provide protocol conversion and routing functions with the Internet or a local area network.
2.1 Overview of Embedded TCP/IP Protocols
Transmission Control Protocol/Internet Protocol (TCP/IP) is a standard protocol for building the Internet. It was first implemented on a PC. Because of the great difference between the embedded system and the PC, the implementation of the TCP/IP protocol in the embedded system is very different from that in the PC operating system.
Since the embedded system does not have a multi-tasking operating system and is directly facing the hardware, the embedded TCP/IP protocol requires a simple application layer. At the same time, different embedded systems require different application layer protocols for the embedded Internet, and the protocols at the application layer also correspond to the protocols implemented at the link layer. Therefore, the system must select and simplify the application layer protocol according to its own needs and the implementation of the link layer protocol.
The transport layer provides end-to-end communications for applications on two hosts. The transport layer has two different transport protocols: connection-oriented TCP (Transmission Control Protocol) and connectionless UDP (User Datagram Protocol). TCP must establish TCP access between hosts through access to the network before access or transmission. The data flow transmitted by the TCP adopts the sequence number and response measures. It can find the loss of data, the out-of-sequence of the segment, and the transmission error. Excluded, so the TCP protocol provides reliable transmission of data streams. However, compared with UDP, its reliability is at the cost of complexity and requires a complicated and large program to implement it. UDP provides unconnected and unreliable services. There may be data packet loss, duplicates, and connection failures. However, because there is no access mechanism, it can achieve high-speed transmission and give full play to the speed of physical transmission equipment. UDP is suitable for use in situations where the communication medium is very reliable, such as Ethernet.
The network layer handles the activities of packets in the network. The protocols include IP (Internet Protocol), ARP (Address Resolution Protocol), ICMP (Internet Internet Control Message Protocol), and IGMP (Internet Group Management Protocol). The IP protocol is the core protocol of the TCP/IP family, which makes it possible to communicate between heterogeneous networks. Therefore, if the embedded Internet needs to communicate across different networks, it must implement the IP protocol. The ARP protocol maps logical IP addresses to physical addresses. The ICMP protocol is mainly used to deliver error messages and other information that needs attention. The application PING that we usually use is to use the ICMP protocol to test the connectivity of the network. For an ordinary embedded Internet application, the connectivity of the network can be tested in the ICMP protocol. Therefore, only the PING response protocol with type 0 and code 0 in ICMP can be implemented. Usually the embedded Internet does not consider IGMP.
The main role of the link layer is to send and receive data packets for its upper layer protocol. According to the physical layer, the main protocols are Ethernet, Token Ring, FDDI (fiber distributed data interface) and RS232 serial line protocol. This can be done by the selected network interface chip.
3. Design example
The application of an ordinary 8/16-bit MCU to form an embedded gateway is a hot spot with the most potential for development. Ethernet, which uses the TCP/IP protocol, has become the most popular packet switched LAN technology. The entire network has only one underlying communication protocol and also has open TCP/IP network technology. It can meet the requirements of all levels of the control system. Fieldbus and serial communication commonly used in industrial control fields can be connected to Ethernet through an embedded gateway, thus facilitating the connection between the control network and the Internet. Currently, the industrial control network based on Ethernet has become the future development trend. Therefore, this design adopts the "crop" TCP/IP protocol stack and Ethernet control chip driver embedded in the 16-bit MCU, and access to the Internet through Ethernet.
This kind of scheme needs to be on the link layer at first, because of adopting the way of receiving people of Ethernet, the system must realize IEEE802.3 standard, this can adopt the common Ethernet interface chip RTL8019AS to finish. Second, in order to ensure system communication over Ethernet, the system also needs to implement the ARP reply protocol. To implement the IP protocol at the network layer, in order to be able to test the connection between the system and the network, the system needs to implement the ping response protocol in the ICMP protocol. At the transport layer we choose the UDP protocol. On the application layer, the single-chip microcomputer system transfers data from the Ethernet and the data terminal, and the application layer only processes the large data packet for package and disassembly.
RTL8019AS is a full-duplex Ethernet controller manufactured by RealTek, conforming to Ethernet II, IEEE802.3 (10Base5, 10Base2, 10BaseT) standards; compatible with NE2000; supporting 8-bit, 16-bit data bus; built-in 16KB SRAM, Used to send and receive buffers, can reduce the speed requirements on the main processor. External RAM uses the PSD4135 (512KB), which provides a large buffer for data processing. It also has address latching and address decoding functions. Using E2PROM-93C46, you can save the physical address and other parameters of the network card.
The RTL8019AS here handles the Ethernet protocol (IEEE 802.3). The flow of data is: the request information comes from the local area network, is sent to RTL8019AS through RJ45, the processed data packet is sent to 80C196 protocol stack, and the protocol stack analyzes the data packet to get the original request information. The request information is then processed by 80C196, and a reply message is generated. The process of replying information to the LAN is just the opposite. RJ45 interface with this system and LAN.
The number of data segments can be from 46 Bytes to 1500 Bytes, with less than 46 Bytes when using zero complement; more than 1500 Bytes, you need to split into multiple frames to send. The leading bit, frame start bit and frame check sequence are only used by the controller itself. The composition of the data frame received by the main processor includes: receiving state, page address pointer of the next frame, destination address, source address, and data Length, data segment. When the data length value in the IEEE 802.3 standard is less than or equal to 0x0600, it indicates the length of the data segment; otherwise, it indicates the type of the data frame. For example, the value is 0x0800, indicating that the data segment is an IP packet; the value is 0x0806, indicating that the data segment is an ARP packet.
3.1 System Software
After the hardware is selected and the address lines, data lines, and status lines are connected between the chips, software design is started. Software design mainly includes: chip initialization program, Ethernet controller driver program, TCP/IP protocol stack program, and system network configuration program. The chip initialization program is used to set the MCU operating mode and peripheral chip selection; the Ethernet controller driver is used to set the working status and working mode of the Ethernet control chip, and allocate the buffer for sending and receiving data; the system network configuration program is used for the monitoring system. Assign an IP address and domain name.
When the network has data, the RTL8019AS will receive and process the Ethernet data frame and send it to the SCM. The 80C196 will analyze the data packet. If it is an ARP (physical address resolution) data packet, the program will be transferred to the ARP processing program. If it is an IP packet and the IP address is correct, continue analyzing if the ICMP packet, then call the ICMP handler. If it is a UDP data packet, after the 80C196 unpacks the data, the data is partially transferred to the PSD4135 or output through the serial port. Conversely, when there is data to be sent, the 80C196 will call the UDP wrapper to encapsulate the data and send it to the RTL8019's cache. The specific flow is: Data is put into the UDP data segment -> Generate UDP checksum -> Create IP header -> (ARP address resolution) -> Generate Ethernet header -> Put in the network card send buffer -> Send.
4 Conclusion
Industrial Ethernet control network based on embedded Internet is the development trend of the next generation of industrial control network. This article elaborated various technical principles of embedded Internet, and realized the function of embedded gateway through Ethernet interface control chip and embedded TCP/IP protocol. It is believed that with the increasingly perfection of embedded Internet technology, this type of solution that can be connected with field networks and other existing networks to facilitate easy connection will be more widely used.
references
1. Li Ming.Kang Jingqiu. Research and Development of Embedded TCP/IP Protocol Stack. Computer Engineering and Applications 2002.16
2. Kenneth D. Reed. "TCP/IP Fundamentals" 3com Translation Beijing: Electronics Industry Press
3.Kenneth D.Reed. "Analysis of the Agreement" translated by Sun Tan Zhang Xuefeng Beijing: Electronic Industry Press
4.Tao Bo, Ding Han et al. Industrial Control Based on Embedded Internet. Measurement and Control Technology, 2002.20.(8)
5. Wan Jinghua, Ding Yajun Ethernet Controller Embedded Device Network Interconnect MCU and Embedded System Application 2001.12
Adapter Ring,Lens Adapter Ring,Camera Adapter Ring,Filter Adapter Ring
SHAOXING COLORBEE PLASTIC CO.,LTD , http://www.fantaicolorbee.com