Design of CAN/CAN bridge in bus network control

Publisher:WiseThinkerLatest update time:2015-08-26 Source: eechina Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
1 Introduction

Controller Area Network (CAN) [1] [2] is a special serial data communication bus developed by Robert Bosch in Germany for the automotive industry in the early 1980s. After years of development, it is now increasingly recognized by many automobile manufacturers and used in cars including BMW, Benz, and VOLVO. Due to its unique characteristics, CAN has been widely used not only in the automotive field but also in the industrial control field, such as industrial field control, community security, and environmental monitoring. Since it is often necessary to connect two CAN subnets in specific engineering applications, the CAN/CAN bridge is indispensable and is one of the key devices for networking. Based on the division of the bus network control system into two network control subsystems, chassis and body, this paper uses the Philips LPC2119 microcontroller to design a CAN/CAN bridge from the hardware and software perspectives.

2 CAN/CAN bridge in bus network control

Due to the increasing application of automotive electronics, CAN is increasingly used in cars. However, it is not widely used in China. It is only used in some high-end luxury models. The application of CAN in domestic buses is also limited to the implementation of single-bus local networking with the help of foreign companies. The networking of automotive electronic technology is an inevitable trend in the research and application of automotive electronics in China. As a standard vehicle network technology, CAN will play a role of bridge and link in the process of automotive networking application. Since the chassis part of the bus involves the safety of the whole vehicle, the real-time requirements and the amount of communication information are significantly higher than the body part. Therefore, this paper divides the bus network control system into two subsystems (chassis CAN and body CAN) and designs a bridge connecting the two CANs. The whole system framework is shown in Figure 1.


The bridge has the function of connecting CAN segments with different rates and filtering and forwarding CAN messages of different segments.

The advantages of using CAN/CAN bridge [1] are mainly reflected in the following aspects:

(1) Filtering communication volume. The bridge receives a message from a subnet and forwards it only when the message is sent to another subnet connected to the bridge. Otherwise, it will not be forwarded.

(2) The communication distance is extended.

(3) The maximum number of nodes in communication is increased.

(4) Different communication rates can be used for each network segment.

(5) The system reliability is improved. When a network failure occurs, it generally only affects individual network segments.

(6) The performance of the entire network is improved.

Of course, the use of a bridge also has certain disadvantages, such as:

(1) Since the bridge must store and then forward the received frames, the delay is increased.

(2) The MAC sublayer of the CAN bus does not have a flow control function. When the network load is heavy, the buffer in the bridge may overflow due to insufficient storage space, resulting in frame loss.

(3) If the bridge fails, the operation of the two adjacent subnets will be affected.

3 Hardware Design of CAN/CAN Bridge

3.1 LPC2119

The CAN/CAN bridge is a hardware and software system with the ARM microcontroller LPC2119[3][5] as the core. LPC2119 is a 16/32-bit ARM7TDMI-SMCU produced by Philips that supports real-time simulation and tracing, with 128KB embedded high-speed Flash memory. The unique acceleration structure enables 32-bit code to run at the maximum clock rate. Applications that have strict control over code size can use 16-bit Thumb mode to reduce code size by more than 30%, while the performance loss is small. LPC2119 integrates two CAN controllers, which makes it possible to design CAN/CAN bridges. Its main features are: data transmission rate on a single bus is up to 1Mb/s; 32-bit register and RAM access; compatible with CAN2.0B; global acceptance filter can recognize all 11-bit and 29-bit Rx identifiers; acceptance filter provides FullCANstyle automatic reception for selected standard identifiers.

The CAN controller integrated in LPC2119 is roughly the same as Philips' SJA1000CAN controller, except that the acceptance filter is slightly different, which makes it convenient for developers who are accustomed to SJA1000 to adopt LPC2119. In the traditional SJA1000, the receiving filter can only meet some ID filtering with high regularity, or arbitrary filtering of a small number of IDs (generally less than 10-15), and it is difficult to implement more complex arbitrary ID filtering, which undoubtedly increases the burden of system software design and runtime. The LPC2000 series 32-bit ARM microcontroller provides a global receiving identifier query function for all CAN controllers. It contains a 512×32 (2k bytes) RAM, which can store 1 to 5 identifier tables in the RAM through software processing. The entire AFRAM can accommodate 1024 standard identifiers or 512 extended identifiers, or a mixture of two types of identifiers. Since the allowed table range is 2k bytes, it can easily meet the requirements of complex ID receiving filters.

The workflow of global receiving filtering: When the receiving end of the CAN controller has received a complete identifier, it will notify the receiving filter. The receiving filter responds to this signal and reads the controller number and identifier size (11bit or 29bit). Then, the receiving filter searches the table in the AFRAM for matching to decide whether to receive or abandon this frame information. 3.2 Structural design of CAN/CAN bridge based on LPC2119

The hardware block diagram of CAN/CAN bridge is shown in Figure 2. LPC2119 is connected to two buses through optocoupler circuit and high-speed CAN bus transceiver TJA1050 respectively. The connection method of two CAN is basically the same. CAN bus drivers are powered separately by isolated DC/DC modules. In this way, not only the electrical isolation between the two CAN interfaces is achieved, but also the isolation between the bridge and the CAN bus is achieved. Although this increases the complexity and cost of the bridge hardware to a certain extent, it is worth it. Taking isolation measures can confine the fault to a certain network segment without affecting other network segments, which is convenient for maintenance and ensures the safety of system equipment. Optocoupler circuit is used to physically isolate the CAN transceiver circuit from LPC2119 to avoid electrical influence on the work of LPC2119.


In addition to the above main parts, the CAN/CAN bridge also adds LED indication, watchdog circuit and reset circuit. Several LEDs mainly indicate the working status of the two CANs and error alarms. LPC2119 has a built-in watchdog circuit, which will automatically reset when the system does not work properly due to program runaway or other reasons. The reset circuit uses MAX708SD to generate a stable reset signal. [page]

3.3 Software Design of CAN/CAN Bridge

The main function of the CAN/CAN bridge is to filter and forward data between two CAN channels. Due to the real-time requirements of communication in the bus network control system, the time requirements for data storage and forwarding should be as short as possible during software design. In order to meet this requirement, the data is received using the vector interrupt (IRQ) method. In addition, since the data communication volume of the chassis CAN control subsystem is significantly higher than that of the body CAN control subsystem, the CAN1 receiving priority connected to the chassis CAN control subsystem is set to the highest, and the CAN2 receiving priority connected to the body CAN control subsystem is second. At the same time, the interrupt service program is simplified as much as possible to make the system response time as short as possible. Two FIFO ring receiving buffers are set for the two CAN channels. Since the data communication volume of CAN1 is high, the FIFO ring receiving buffer of CAN1 is larger than that of CAN2, which is more suitable for the actual situation.

The software design of the CAN/CAN bridge mainly includes: initialization of two CAN controllers, setting of FIFO ring receive buffer, setting of global acceptance filter of two CAN controllers, receiving interrupt service program, CAN sending program, and main monitoring program. The

initialization process of the CAN controller is shown in Figure 3. Among them, the configuration of the global acceptance filter is a difficult point, and it is also a place different from the SJA1000 independent CAN controller. There are 5 address registers used to point to the tables in the acceptance filter RAM: fullCAN standard address, standard single address, standard address range, extended single address and extended address range. These tables must be continuous in the memory. The starting addresses of the last 4 tables are the end addresses of the adjacent previous tables respectively. The end address of the extended address range table is given in the table end register. If the starting address of a table is equal to the starting address of the next table or the value of the table end register, the table is empty.


A send pointer, a receive pointer and the current data frame number frameCount are set in the FIFO ring receive buffer. When frameCount is 0, it indicates that the FIFO ring receive buffer is empty.

The receiving interrupt service program puts the received data into the corresponding FIFO ring receiving buffer and modifies the receiving pointer and the current data frame number frameCount.

The main monitoring program is responsible for monitoring whether there is data in the FIFO ring receiving buffer of the two CANs. If there is data in the FIFO ring receiving buffer of one CAN, the data is sent to the other CAN. The main monitoring program constantly queries the current data frame number frameCount flag in the FIFO ring receiving buffer of the two CANs. If it is non-zero, it immediately sends data to the other channel, and modifies the sending pointer and the current data frame number in the subroutines CAN1SendToCAN2() and CAN2SendToCAN1(). The main monitoring program flow is shown in Figure 4.


4 Summary

This paper designs a CAN/CAN bridge based on LPC2119, and discusses the design process from the perspective of hardware and software. The author uses CANalyst-II and USBCAN-II of Guangzhou Zhou Ligong Microcontroller Development Co., Ltd. to simulate the chassis CAN and body CAN of the bus respectively to repeatedly test the bridge with a large amount of data. When 100,000 frames of data are continuously sent to the two CANs, it can be accurately forwarded, indicating that the bridge works reliably. The next research goal is to transplant the real-time multitasking operating system μC/OS-II on the bridge to further improve the real-time performance of the bridge.

The author's innovation: The bus network control system is divided into two network control subsystems, chassis and body, and a CAN/CAN bridge is designed to interconnect the two network control subsystems.
Reference address:Design of CAN/CAN bridge in bus network control

Previous article:Study on three low power consumption modes of STM32
Next article:Research on infrared light vehicle speed management system based on ARM

Recommended ReadingLatest update time:2024-11-16 15:49

Debug automotive designs faster with oscilloscope CAN-dbc character triggering and decoding
The differential Controller Area Network (CAN) bus is widely used in the powertrain and body control of today's automobiles. The CAN bus is a communication protocol developed by Bosch over 30 years ago and has long been considered the "workhorse" serial control bus for automobiles. The CAN bus is also widely used in i
[Test Measurement]
Debug automotive designs faster with oscilloscope CAN-dbc character triggering and decoding
Design of Ethernet-CAN conversion circuit based on C8051F040
Abstract: Ethernet and CAN bus are widely used, but due to their different communication protocols, data communication between the two bus devices is impossible. Therefore, an Ethernet bus and CAN bus interface conversion circuit based on CP2200 and C8051F040 is designed, and some related hardware circuits and softw
[Microcontroller]
Design of Ethernet-CAN conversion circuit based on C8051F040
New power semiconductor with double-layer heat dissipation capability - CanPAK
In recent years, the concept of environmental protection and energy conservation has gradually gained attention, which has promoted the development of various new energy sources, energy utilization technologies, and new devices and equipment. The promotion of energy policies has also gradually expanded the business op
[Power Management]
New power semiconductor with double-layer heat dissipation capability - CanPAK
Research and design of CAN and RS-232 converter based on single chip microcomputer control
  1. Overview   CAN (Controller Area Network) bus is a serial data communication protocol developed by BOSCH of Germany to solve the data exchange between many controls and tests in modern automobiles. It is a multi-master serial communication bus. CAN bus is an open, digital, multi-point communication control system
[Microcontroller]
Research and design of CAN and RS-232 converter based on single chip microcomputer control
CAN bus cool knowledge-how does the edge step come from?
Do you know the waveform of the CAN bus? Do you know what factors cause the instability of the CAN signal? This article will take you to explore the culprit that affects the stability of the CAN waveform - the edge step. Impedance matching refers to achieving a suitable match between the signal source or transmi
[Automotive Electronics]
CAN bus cool knowledge-how does the edge step come from?
CAN bus: the core of automotive electronics
The automotive electronics industry is quietly emerging in Nanjing. The 14th Institute and Nanjing Automobile jointly established Nanjing Tianqing Automotive Electronics Company; the Northern Information Industry Group also regards automotive electronics as a strategic focus for future development. Both companies have
[Automotive Electronics]
CAN bus: the core of automotive electronics
Porsche Taycan's electrical and electronic architecture explained
As one of the main infrastructures of vehicles, the importance of electronic and electrical architecture is even more prominent under the current trend of intelligence and electrification. Previously, we have reviewed the electronic and electrical architectures of Tesla, Volkswagen ID series, Audi, BMW and other mod
[Embedded]
Porsche Taycan's electrical and electronic architecture explained
Application of CAN bus technology in station signal system
  With the continuous advancement of network technology and the continuous improvement of industrial controller local area network technology, the application of remote control technology in industry is becoming more and more widespread. The local machine controls the on-site machine to perform various operations throu
[Microcontroller]
Application of CAN bus technology in station signal system
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号