Design and Implementation Strategy of Embedded Gateway System Based on ARM

Design and Implementation Strategy of Embedded Gateway System Based on ARM 0 Overview

CAN (Controller Area Network) is a controller area network. The CAN bus specification has been formulated by the International Organization for Standardization as an international standard ISO11898, and has been supported by many semiconductor device manufacturers. It has launched various products with integrated CAN protocol. CAN is a bus-type serial communication network. Due to its many new technologies and unique design, low cost, high reliability, real-time performance, flexibility, strong anti-interference ability, etc., it has been widely used in various automation control systems in. In the fields of automotive electronics, automatic control, power systems, etc., the CAN bus has unparalleled advantages.

With its advantages of large communication data volume, fast transmission speed, good openness, and low cost, Ethernet makes up for the shortcomings of low fieldbus communication rate, and has become the most widely used local area network technology for information networks at this stage. There are still some problems in using Ethernet directly to enter the field of industrial control. The media access mode CSDA / CD of Ethernet cannot guarantee the certainty and real-time nature of network transmission, and cannot meet the requirements of the harsh environment on the industrial site. Introduce Ethernet into the field of industrial measurement and control. By cooperating with the field bus (CAN BUS) division of labor, it forms two heterogeneous network structures. It combines efficient Ethernet and low-speed field buses to solve the real-time and reliability of large-scale measurement and control systems. Contradiction, improve the efficiency of the entire system. The interconnection of two heterogeneous networks needs to be implemented with an embedded gateway.

The main task of CAN / Ethernet gateway design is protocol conversion, which requires correct and complete data analysis, as well as quick response, low time consumption, good real-time and safety. The ARM microprocessor based on the RISC architecture has high instruction execution efficiency, the software operating platform is easy to build, and it has abundant peripheral expansion circuits to meet real-time multi-tasking requirements. The use of ARM technology to construct an Ethernet and CAN fieldbus protocol conversion gateway is an efficient and feasible solution.

1 Gateway hardware system

The main function of the gateway is to perform the protocol conversion between the Ethernet data message and the CAN data frame, and realize the interconnection of the Ethernet and the CAN bus. The hardware components of the system include CAN bus interface design and Ethernet interface design, as shown in Figure 1.

S3C2410 is a low-cost, low-power, high-performance 32-bit RISC embedded processor introduced by Samsung. The chip uses ARM920T core, 5-stage pipeline and Harvard structure, operating frequency up to 266 MHz, running speed up to 1.1 MIPS. S3C2410 provides abundant internal resources, such as: SDRAM controller, LCD controller, 3-channel UART, 4-channel DMA, 2 SPI modules, supports three data transmission modes of polling, interrupt and DMA. Although there is no CAN controller inside, it can be expanded through the SPI interface. The interface circuit is simple and easy to implement.

The CAN bus interface circuit is mainly composed of independent CAN controller MCP2510 with SPI interface, CAN bus transceiver TJA1050, high-speed optical isolation 6N137 and DC / DC power isolation module DCR010505. The independent CAN controller MCP2510 fully supports the technical specifications of V 2.0A and V 2.0B of the CAN bus. When designing the system, connect the MCP2510 as a slave device to the SPI0 port of the S3C2410. The TJA1050 bus transceiver is an interface chip between the CAN controller and the physical bus, which enhances the driving capability of the bus. In order to enhance the anti-interference ability of CAN bus nodes, TXCAN and RXCON of MCP2510 are not directly connected to TXD and RXD of TJA1050, but are connected to TJA1050 through two photoelectric couplers 6N137. The DC module is isolated. In this way, complete electrical isolation between CAN nodes outside the system bus is achieved, enhancing the stability and security of the nodes. Both ends of the bus are connected with a terminal resistance (120 Ω) and a TVS tube to eliminate the reflected signal and effectively improve the anti-interference ability of the system.

The Ethernet interface circuit expands the network interface chip RTL8019AS on the S3C2410 chip. RTL8019AS is a highly integrated Ethernet controller based on the ISA bus produced by Taiwan REALTEK Company. It implements all the functions of the Ethernet media access layer (MAC) and physical layer (PHY), including the sending and receiving of MAC data frames, address recognition, cyclic redundancy check (Cyclic Redundancy Check, CRC) encoding / checking, Manchester encoding and decoding , Overtime retransmission, link integrity test, signal polarity detection and correction, etc. RTL8019AS has three interface modes with the main processor, jumper mode (Jumper), plug and play mode (PnP) and jumperless mode (Jumperless). The system uses a common jumper mode to select I / O ports and interrupts.

2 Protocol conversion process

When the device on the CAN bus sends data to the Ethernet network, the embedded gateway parses the received CAN data packet to extract the content in the data field; then encapsulates according to the TCP / IP protocol, and the embedded gateway sends the encapsulated data to send Give the Ethernet control chip RTL8019AS. RTL8019AS automatically adds the relevant information required by the Ethernet physical layer and logical link layer to these data, and transmits it to Ethernet through the physical interface. Conversely, when Ethernet sends TCP / IP data packets to the device on the CAN bus, it first sends the data to RTL8019AS. After the embedded gateway receives the data from RTL8019AS, it extracts the actual data to be transmitted and then encapsulates it into CAN bus data Format, send data to the field devices in the network through the CAN bus.

The embedded gateway hardware must have an Ethernet interface and a CAN bus interface, and the software must have a TCP / 1P protocol stack and CAN bus driver; usually there is a complete TCP / IP protocol stack in the embedded Linux kernel. Since REALTEK supports Linux development, the Linux system already contains the universal driver for the RTL8019AS chip. The CAN bus protocol driver is not a standard configuration. Therefore, the design of the CAN bus interface and the preparation of its driver are the most important tasks for the implementation of the embedded gateway.


3 CAN driver program design

The Linux driver is part of the Linux kernel and is the interface of the embedded system control hardware. It shields the working details of the device for the user and provides the user with a transparent access mechanism for the hardware device. The development of driver program plays an important role in the development of embedded systems. The development of stable and complete drivers can improve the performance of the entire system.

3. 1 CAN driver procedure

The internal structure block diagram of MCP2510 is shown as in Fig. 2.

The MCP2510 contains 3 transmit buffers and 2 receive buffers, and also has flexible interrupt management capabilities. The CAN protocol machine is responsible for the interface with the CAN bus, the SPI interface logic is used to communicate with the MCU, and the registration, buffer group and control logic are used to complete various settings and operation controls.

In the Linux multi-tasking operating system, the design of the CAN bus communication program can be divided into sending data module, receiving waiting module and interrupt processing module. The data transmission and reception of CAN bus in the system are two different threads. Establish data sending and receiving buffers in the driver. The interrupt handler is only responsible for filling (or reading) the data in the buffer, and then wake up the task of waiting for the data to be received (or sent). The sending and receiving of data are through independent buffers and realized by interrupts. The interrupt response time of the operating system determines the fastest sending and receiving speed of CAN bus data in software.

3.2 The main points of the realization of CAN device driver

3.2.1 CAN device driver operation function

The CAN device driver finally provides the application with a flow control interface, which mainly includes operations such as open, realse, read, write, and ioctl. Adding a device driver is actually writing the corresponding program code for the above operation. When the driver is loaded into the kernel, it will first run the driver's initialization function, and then wait for the system to call the relevant function defined in the file_operaTIons data structure to implement the operation of the device. The system uses Linux 2.4.18 version, and its file system interface is written as:

s3c2410_mcp2510_open is responsible for making necessary preparations for the I / O operations to be performed, including limiting the number of times CAN is opened, clearing 3 send buffers, and 2 receive buffers.

s3c2410_mcp2510_write transmits the data to be sent to the send buffer of the MCP2510 through the SPI bus, and then sends the data to the CAN bus through the MCP2510.

s3c2410_mcp2510_read is used to receive the data of the receive buffer from the CAN bus on the MCP2510, read it to the user area through the SPI bus, and return the number of bytes read.

s3c2410_mcp2510_ioctl is used to control the baud rate of CAN bus communication, set the frame ID, set the working mode, set the device filter, etc.

s3c2410_mcp2510_release is used to release occupied memory, interrupts and other resources.

3.2.2 Initialization function of CAN device

The initialization function of the CAN device is mainly responsible for creating the node device file of the CAN device, registering the interrupt processing function of the CAN device, initializing the MCP2510 and so on.

In the Linux system, the initialization function starts from s3c2410_mcp2510_init (). Register a character device driver with the system by calling register_chrdev; create a CAN device node of the device file system through the devfs_register () function. At the same time, the CAN device driver applies for an interrupt by calling the request_irq function and registers the CAN interrupt processing function s3c2410_isr_mcp2510 () of the CAN device with the system. After implementing the various interface functions of the MCP2510, you also need to write the module loading function module_init () and module unloading function module_exit () of the MCP2510, which are used to register the device with the kernel and unregister the device.

3.2.3 Load and use of driver

Linux device drivers will appear in the form of kernel modules. Eth-ernet / CAN gateway device driver as part of the kernel, the device driver should be compiled into a loadable module at compile time. When using the insmod command to load the kernel module, the module's loading function mod-ule_init (initialization function name) will be automatically executed by the kernel, add the initialization function to the kernel global initialization function list, and execute the driver's initialization function during kernel initialization to complete After the initialization and registration of the driver, the driver stops waiting and is called by the application. When a kernel module is uninstalled with the rm-mod command, the module's uninstall function module_exit (exit processing function name) will also be automatically executed by the kernel, completing the reverse function of the module loading function. After the driver is loaded into the kernel, you can open, read, write, and release CAN device files.

4 Conclusion

With the improvement of industrial control system performance, the application of Ethernet in industry will become more and more extensive. The design and implementation of an embedded gateway are introduced in detail here. As a link between Ethernet and fieldbus, it realizes the protocol conversion between Ethernet and CAN fieldbus, and provides a solution with fast transmission speed, low cost, high stability and security for the interconnection of CAN / Ethernet. At the same time, using the embedded ARM processor, the interface resources are rich, the design is versatile, it is convenient to expand the interconnection of other field buses and Ethernet, and has good application promotion value.

Food Processor 3 In 1

Food Processor 3 In 1 is one of our popular food processor among our customers. This kind of food processor including blender, juicer and grinder. Besides, the blender jar has plastic jar and glass jar food processor optional. 

Description for Food Processor 3 In 1

350W/450W/600W

Including juicer, 1.25L plastic jar blender and grinder

2 speeds wth pulse

Carton box: 49.5*44.5*61cm  4pcs/ctn

20'GP: 912pcs     40'HQ: 2104pcs

food processor 3 in 1

Food Processor 3 In 1

Food Processor 3 In 1,Food Processor 3 In 1 Juicer,3 in 1 Food Processor Blender,3 in 1 Baby Food Processor

Flying Electronic Co., Ltd , https://www.flyingelectronic.com