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.
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
- Popular Resources
- Popular amplifiers
- New Energy Vehicle Control System Inspection and Maintenance (Edited by Bao Pili)
- Detailed explanation of big data technology system: principles, architecture and practice (Dong Xicheng)
- Automotive CAN embedded intrusion detection system based on deep learning
- Lightweight FPGA-based IDS-ECU architecture for automotive CAN networks
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Optimization and Implementation Method of Task Scheduling in μC/OS
- Does anyone know what model this monster is?
- MSP430 MCU Development Record (6)
- Using ESP's rtc memory in mpy
- Linux serial communication 1——96-N-8-1 format
- [STM32WB55 Review] Summary
- I need help with the simplest program to control 12864 with keys
- TUSB9261 -- USB3.0 to SATA interface bridge chip programming guide
- 【Video】Bluetooth Low Energy Mesh Training Video
- How to upgrade the program of msp430 microcontroller