CAN-bus interconnects Gateway Design and Implementation

Abstract: This paper systematically studies the CAN bus and Ethernet interconnection technical points, the first analysis of interconnect technology in the realization of the difficulties encountered in the process - protocol conversion. Then a CAN bus and Ethernet system interconnect design and detail of its system software and hardware realization. In order to improve system performance, high-speed micro Kong Zhiqi SX52 to design embedded transparent gateway, detailed description Leyong SX52 in the TCP / IP protocol stack implementation approach to the Wangluo SX52 strong agreement Chulinengli ensure 了 overall system performance upgrade.

1 Introduction

Technology and social development, to the late 20th century globalization, competition became intense. Competition have gradually implemented computer integrated manufacturing system, with system integration, information integration perspective to organize industrial production. In this system, intelligent field devices for the realization of multi-point digital communications, computer and control technology and computer networks closer together, resulting in a live environment in industrial operation, reliable performance, low cost field bus (FieldBus) technology.

Fieldbus is a manufacturing site for the lowest communication network, which implements a computer-based on-site survey control equipment or equipment, two-way serial multi-node digital communications. Fieldbus technology is the key to automatic control systems and field devices with communication capabilities, to connect them into a network system, on-site communication network and control system integration. As the network system, which is open unified communications protocol. CAN bus, field bus technology is formed in the industrial application of a mature technical standards. It's an agreement based on ISO / OSI model basis, but only the bottom of the model using the physical layer, data link layer and the top of the application layer. Automation systems in large enterprises, the upper layer of corporate management and production monitoring are commonly used Ethernet and PC, while the lower plant site are based on field bus and SCM monitoring equipment. Upper and lower levels of communication, usually in industrial control machine plus Ethernet card, plus slots on the PC-interface card or EPP parallel port printer interface card to achieve. This connection the high cost, long development cycle. In view of this situation, we design a separate CAN Ethernet gateway interconnection system, successfully Ethernet and CAN bus network of existing direct data association.

2 System Design

CAN bus is a bus-based control network interconnect devices. In the CAN bus devices can be mounted up to 110 nodes, the devices will be free to communicate with each other to achieve complex network control system. But the device information layer can not directly reach the information management, in order to enter the information management device information through a data gateway should.

Here we designed a SX52 gateway for CAN and Ethernet interconnect. Overall system is divided into three parts: on-site monitoring network (CAN network), embedded transparent SX52 gateway, Ethernet information management terminal (such as monitoring platform and network databases, etc.). Ethernet information management terminal and the CAN bus CAN node through the ETHERNET, SX52 gateway, CANBUS communicate with each other, which played a central SX52 gateway interconnection of heterogeneous network effects.

Heterogeneous network interconnection protocol conversion is the key technical and difficult conversion layer protocol conversion method can be used generally, since the low-up step by step. Mostly currently interconnect layer or network layer in the Internet started to be made to the following layers on the interconnect layer up layer by layer protocol conversion, this conversion method is based on the basic principles of layered protocol: the low-level support for high-level, high-level call low-rise, low-level disconnect after the high-level connections also will disconnect, but it will not affect the high-level low-level disconnect. From the network's hierarchical structure, we design the interconnection system has a hierarchical structure as shown in Figure 1. Ethernet running TCP / IP protocol, it has the application layer, transport layer, network layer, Ethernet data link layer and physical layer; CAN bus with the application layer, data link layer and physical layer, including the application layer by the user own definition, data link layer and physical layer defined by the CAN protocol; SX52 Data Gateway has the physical layer, data link layer and application layer, the application layer is the information ETHERNET and CAN data exchange layer, SX52 microcontroller In this layer with each other to explain and transmit data from the two different protocols.

CAN-bus interconnects Gateway Design and Implementation

Figure 1 CAN bus and Ethernet interconnection network hierarchy

In this design, SX52 Gateway is designed to become a transparent data gateway, that is, build and resolve the Ethernet application layer protocol data packet complete CAN, CAN protocol data packets as TCP / IP network application layer data transmission, its practical significance of specific data communication without any explanation. Gateway designed the reason why the transparent type, is based on three considerations: 1) Transparent Gateway for relatively simple non-transparent gateway, the hardware need not expand the large capacity of data cache memory for communication data; software need not consider the data aggregation and distribution of processing, reduced programming complexity, improve speed and real-time communication. 2) Transparent Gateway adaptability, it can be applied to different project requirements, and non-transparent gateway to the gateway according to different requirements will have to make different changes to procedures. 3) because the protocol converter designed to be simple, not more complex processing, thus enhancing the reliability of communication.
CAN-bus network, the maximum transmission rate for the 1Mpbs, while Ethernet is now generally 10Mbps. Here to consider the issue of speed matching between the two, where you can solve this problem from two aspects: First, the gateway to use larger RAM, used as a communication data buffer, to improve the efficiency of network transmission. Second, limited to the CAN bus, Ethernet data transmission, it is less than CAN bus communication speed.

3 CAN protocol analysis

CAN is to comply with OSI model, in accordance with the OSI reference model, CAN structure is divided into two layers: data link layer and physical layer. In accordance with standard IEEE802.2 and 802.3, the data link layer in turn divided into:

- Logical Link Control (LLC)

- Media Access Control (MAC)

Also the physical layer is divided into:

- Physical Signaling (PLS)

- The physical media attachment (PMA)

- Media related interface (MDI)

MAC sub-layer run with called "failure to define entity (FCE)" to monitor the management entity. Failure to define is to determine short-term disturbances and a possible permanent fault self-test mechanism. With the physical layer fault detection and management entity to monitor the physical media (such as short circuit or interruption of the bus, the bus fault management). LLC and MAC agreement the two entities through the exchange of the same frame or protocol data unit (PDU-Protocol Data Unit) communicate with each other.

LLC sub-layer provides features include: frame reception filtering, overload notice and recovery management. Among them, circular function overloading is that if the internal conditions of the receiver to delay the next LLC frame or remote frame LLC, the LLC sublayer by overloading the frame starts to send up to produce two overload frames to delay the next data frame or remote frame.

The OSI seven layer network model in accordance with terms, CAN bus network to complete the bottom two layers of protocol of Gong Zuo, namely the physical layer and data link layer, Ta Men You CAN Kong Zhiqi the hardware implementation level shifting frame of the package. In practice, also need to build their own upper layer protocol. Here a simple and practical design of the "command key + data item" Structure


CAN-bus interconnects Gateway Design and Implementation

Application layer frame structure of Figure 2

Taking into account the general features of industrial control small, so the length of the command key is set to 1BYTE (256 can be described by an order). Set of data in the data item in the light of the length of CAN bus is a short frame transmission (data frames, each frame of data only 8BYTE), some data parameters required by the orders may be greater than 7BYTE, while the data is likely to have greater returns So, here set the length of one byte of data items to user-defined data frame length can reach 256 bytes.

4 SX52's TCP / IP protocol stack design

ARP protocol can achieve the logical addresses to physical addresses of the dynamic mapping. Ethernet interfaces support a unique 48-bit physical address. In the SX52, ARP protocol is through a "IP address of the Ethernet address corresponding to" single-core to achieve registration. When the remote host needs to know its physical address, the remote host will send the ARP request to it, then it will respond to the remote host's request, to tell each other their physical address. When the application layer need to transfer IP packets, SX52 ARP protocol can also request the physical address of the remote purposes.

Internet data packets to transfer data packets in the Ethernet controller to send buffer is built, it uses the recently received packet to send the purpose of the Ethernet address as the packet destination address. Of course, this may not be correct Ethernet address, therefore, before the actual sending data packets, ARP protocol to send data packet will check the IP address is present in the nuclear ARP, if sending data packets in the IP address in the nuclear , in the send buffer in the Ethernet packet will use the Ethernet address of nuclear ARP update, if not, then the ARP protocol to send an ARP request packet, then wait for a response. Once the ARP response is received, the ARP will use just received nuclear target Ethernet address update, then wait to send the packet will also be updated to use the Ethernet address, and then be sent. If the ARP request packets sent without response, leading to ARP timer time-out, which is waiting to send the packet will be discarded, the normal protocol stack to run.

IP protocol is TCP / IP protocol suite lies at the core of the agreement. All of the TCP, UDP, ICMP and IGMP for IP packet data format for transmission. IP provides unreliable, connectionless datagram delivery service, can not guarantee success of IP packets arrive at their destinations. If some error occurs, such as a router temporarily run out of buffer, IP has a simple error handling algorithm: discard the datagram and then send ICMP messages reported to the source side. The reliability of any request must be provided from the top. Connectionless IP does not maintain any mean follow-up data reported on the status information, the processing of each packet is independent of each other. This also shows that, IP datagrams may not be received by sending the order. In this design, IP protocol is for the specific application environment of a reasonable simplification. CAN bus control network is a short frame, real-time network, so, IP data packet without fragmentation (MF = DF = 0), at the same time, set the IP type of service for the general type, the head length of 20 bytes, the first minister of degree field is 5, the life TTL set to 64.

TCP application layer to provide a connection-oriented, reliable byte stream service. In the face of industrial control applications, the TCP protocol can be complex to do a reasonable simplification, because the CAN network transmission speed, data volume is small and l0Mpbs Ethernet transmission does not occur normally blocked, Ethernet host will have sufficient capacity to timely processing of communications data. So can a fixed time-out and retransmission time for 5s, RTL8019AS also has two 1500-byte receive buffer, and the CAN network to control the network, the amount of information is small, it can be fixed to accept the window to 1400 bytes. Design services used to meet general TCP applications, it can be ignored and the options and fill urgent pointer field value. Simplified by the above three points, in fact greatly simplifies the implementation of TCP protocol, because TCP retransmission timeout and the time to identify and control the window size has a more complex algorithms and implementation mechanism.

5 Innovations Summary

This innovation is the traditional industrial control automation field bus connection costs are high, development of a long cycle of inadequate offices, design a separate CAN-Ethernet gateway interconnect systems, has successfully achieved the existing Ethernet and CAN the direct data bus interconnection network. Fieldbus via the Internet, corporate intranet connected to automatic control systems and field devices into enterprise integrated automation and information systems as an integral part. System in the open, interoperable, intelligent field devices, system structure, on-site environmental adaptability performance are greatly improved, the successful realization of the two heterogeneous network data communications.

Declined comment