Design of CAN bus analyzer based on ARM microcontroller and smart phone

Publisher:创意航海Latest update time:2019-12-06 Source: elecfans Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

In view of the need for CAN bus communication quality, testing and verification, as well as the complexity of traditional CAN analyzers and the insufficiency of having to use a PC as a display terminal, a design of a CAN bus analyzer based on an ARM microcontroller and a smart phone is demonstrated. The analyzer uses a hardware circuit with an ARM microcontroller as the core to complete real-time data collection and monitoring of the CAN network; it uses Bluetooth communication to achieve communication between the analyzer and the smart phone and uses the smart phone as the terminal to complete data analysis. The article specifically designs the analyzer hardware, software and smart phone page, proposes a new baud rate automatic detection method, and finally gives the actual test results of the designed CAN bus analyzer, which can realize the functions of CAN bus baud rate automatic detection, normal monitoring and CAN bus status analysis.


CAN (controller area network) is a serial data bus with strong real-time performance, good flexibility and high standardization. It is widely used in automotive electronics, industrial automation, ships, medical equipment, industrial equipment and other fields. Its test equipment, CAN network analyzer, has become a must-have for developers. With the help of the easy-to-use CAN bus analyzer, it is possible to quickly find the design problems or abnormal interference problems in the CAN bus system during use, and eliminate the faults and problems.


Traditional CAN analyzers require the computer to be connected to the CAN analyzer via USB, and then the bus to be tested is connected to the CAN analyzer via the DB9 interface. Since the CAN bus is a popular field bus in the vehicle industry, such a debugging method is not very convenient for vehicles that need to be road tested, and it is difficult to ensure normal operation. Similarly, in the field of industrial control, the traditional CAN analyzer may cause some confusion in industrial sites with many wiring harnesses because both ends have wires. In addition, in order to ensure safety, today's equipment using the CAN bus sometimes has more than one bus. Traditional analyzers have at most two interfaces, which means that if you want to test more than two CAN buses at the same time, you need two USB interfaces. If the two CAN buses are far apart, you need a longer USB cable. For this reason, here is a Bluetooth CAN bus analyzer with low cost, small size, simple structure, wireless debugging and low environmental requirements.


1 Hardware Design

1.1 Overall design

In view of the various shortcomings of traditional CAN analyzers, this paper proposes a new CAN analyzer that uses a smartphone instead of a PC as a display terminal, uses Bluetooth wireless transmission instead of USB cable transmission, and has its own lithium battery. The overall design structure is shown in Figure 1.

Design of CAN bus analyzer based on ARM microcontroller and smart phone

Figure 1 Overall design block diagram of Bluetooth CAN analyzer


Since the CAN analyzer is a communication protocol with a high baud rate, and complex calculations are required for communication quality analysis and fault location, the Bluetooth CAN analyzer proposed in this paper includes three parts in the overall design: one part is a processing motherboard with ARM as the processing core, which is responsible for CAN bus baud rate detection, data acquisition and Bluetooth communication signal transmission; the second part is a lithium battery, which is responsible for providing power to the motherboard. The lithium battery voltage is 5V, the capacity is 3000mAh, and the size is 11.6mmX42mm×69ram, which can ensure that the system works for more than 10h; the third part is a smart phone, which is responsible for receiving CAN bus data and processing the data.


1.2 Motherboard Design

There are 4 modules on the mainboard, namely, isolated CAN interface module, ARM processor module, Bluetooth serial port module, and power circuit module. The design block diagram is shown in Figure 2, and the actual picture is shown in Figure 3.


The isolated CAN interface module is responsible for sending the ARM data to the CAN bus and sending the data on the CAN bus to the ARM processor.

Design of CAN bus analyzer based on ARM microcontroller and smart phone

Figure 2 Mainboard system design block diagram

Design of CAN bus analyzer based on ARM microcontroller and smart phone

Figure 3 Motherboard shopping map


The ARM processor module is the core of this analyzer, using the NXP LPC2119 processor. LPC2119 is based on a 16/32-bit ARM7TDMI-STM CPU that supports real-time simulation and tracing, with 128KB embedded high-speed Flash memory, and internally integrated with 2 CAN controllers. Its main features are: data transmission rate on a single bus up to 1MB/s; 32-bit register and RAM access; compatible with CAN2.0B, IS011898.1 specifications; global acceptance filter can identify all 11-bit and 29-bit identifiers; acceptance filter provides FullCAN-style automatic reception for selected standard identifiers. It is mainly responsible for processing the data on the CAN bus and then sending it to the mobile phone through the Bluetooth serial port. In addition, the ARM module is also responsible for detecting the baud rate on the unknown CAN bus and sending it to the mobile phone.


The Bluetooth serial port module is responsible for exchanging data between ARM and the mobile phone, and the communication rate of its serial port reaches 1382400bps. The power module is responsible for supplying power to each module.


2 Software Design

Software is the key to Bluetooth CAN analyzer. According to the hardware system structure, the software consists of two parts, namely, the baud rate detection and data transmission software running on the ARM processor; and the CAN analyzer operation interface running on the smartphone. For the software running in the ARM processor, this article focuses on introducing a new baud rate automatic detection method.


2.1 Design of baud rate automatic detection software

To achieve communication between the CAN bus and the CAN analyzer, the same baud rate is required, so the baud rate detection is very important. The current mainstream baud rate detection method is a baud rate detection method established using a response mechanism. It starts by listening to some recommended CAN bus preferred baud rates, namely 1Mbit/s, 800kbit/s, 500kbit/s, 250kbit/s, 125kbit/s, (100kbit/s), 50kbit/s, 20kbit/s, 10kbit/sHl: If the complete CAN message can be received without failure, it means that the baud rate detection is successful; if the baud rate of the CAN bus is not the preferred baud rate, the baud rate can be determined by the response of the host and the CAN bus. This detection method is slow, has certain errors and has a certain impact on the network under test.


In view of the shortcomings of the baud rate detection method using the response mechanism, this paper proposes a new automatic baud rate detection method. This automatic baud rate detection system cleverly uses the interrupt port of the ARM processor to record the waveform on the CAN bus into the ARM processor, and then analyzes the obtained waveform to obtain the baud rate of the system. It has a fast detection speed (less than 200ms), accurate detection (the baud rate obtained is an exact value, not a range value), does not send data to the network under test, and has a very low cost and does not require any additional chips.


The specific implementation method is: in terms of hardware, connect the RX pin of the isolated CAN interface to the timer capture port of the ARM. In terms of software, first record the interval period of two adjacent up-jumps and down-jumps of the RX pin; secondly, sort the periodic data, and the data should be in a step-like shape; then divide the data into steps and find the median of each step. The first step is the duration of 1-bit data, the second step is the duration of 2-bit data... and so on. Since the CAN bus will not have the same level for 6 consecutive bits, there are only 5 steps, and the second data is equal to 2 times the first data, the third data is equal to 3 times the first data, and so on. According to this feature, the data can be verified and the duration of the final 1-bit data can be adjusted. The final baud rate is the reciprocal of the 1-bit duration. The flow chart is shown in Figure 4.

Design of CAN bus analyzer based on ARM microcontroller and smart phone

Figure 4 Baud rate detection flow chart


2.2 Smartphone interface design

The design of the smartphone interface uses Eclipse. Eclipse is an open-source, Java-based, extensible development platform. It is just a framework and a set of services for building a development environment through plug-in components, and comes with a standard plug-in set, including Java development tools. The mobile phone operation interface is shown in Figures 5 and 6.

Design of CAN bus analyzer based on ARM microcontroller and smart phone

Figure 5 Software running interface

Design of CAN bus analyzer based on ARM microcontroller and smart phone


3 Experimental verification

In order to verify the design effect of this Bluetooth CAN analyzer, a test system including an ARM-based motherboard, a lithium battery, a smart phone (with Android system installed), and a USB-CAN simulating the system under test was built, and then actual tests were carried out. The test flow chart is shown in Figure 7.

Design of CAN bus analyzer based on ARM microcontroller and smart phone

Figure 7 Actual test flow chart


The actual test system is shown in Figure 8. The actual test shows that as long as there is data flow on the simulated CAN bus, for different CAN bus baud rate settings, the Bluetooth CAN analyzer designed in this paper can accurately and quickly automatically detect the baud rate and can realize data reception and transmission.

Design of CAN bus analyzer based on ARM microcontroller and smart phone

Figure 8 Actual test system diagram


4 Conclusion

By building a hardware system based on NXP's LPC2119 processor, smartphones, Bluetooth as a means of information transmission and corresponding software design, the baud rate of the CAN bus can be automatically detected and data received and sent, verifying the correctness of the Bluetooth CAN analyzer. The implementation of the Bluetooth CAN analyzer, with its simple operation, easy to carry, and good shock resistance, will provide great convenience for CAN bus development engineers; at the same time, it can be found that by further strengthening the design and optimization of the software, the analyzer can also provide more valuable information about the CAN bus.

[1] [1]
Reference address:Design of CAN bus analyzer based on ARM microcontroller and smart phone

Previous article:Fault Analysis of GF-D800 Semi-automatic Biochemical Analyzer
Next article:Design of Power Fiber Signal Analyzer Based on ARM and FPGA

Latest Test Measurement Articles
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号