A data acquisition method for a data acquisition system based on CAN bus and wireless communication
Through a data acquisition system based on CAN bus and wireless communication, CAN data is collected and parsed by wireless methods, the problems of traditional wired acquisition and difficulty in maintaining mobile terminals are solved, convenient and efficient data acquisition and analysis are achieved, and the cost and Maintenance pressure.
Patent Information
- Application Number
- CN201910970935.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-10-12
- Publication Date
- 2024-11-12
- Estimated Expiration
- 2039-10-12
AI Technical Summary
The existing CAN data acquisition tools are costly and difficult to maintain, and traditional wired methods are inconvenient. Mobile terminals need to develop customized data analysis, and the protocol update needs to be updated frequently, resulting in economic pressure and maintenance troubles.
Design a data acquisition system based on CAN bus and wireless communication, including a data acquisition unit and a mobile terminal, collect and parse CAN data through wireless means, and automatically detect CAN Potter using microprocessor, wireless communication unit and LED indicator lights. Rate, supports WIFI and Bluetooth connection, mobile terminal imports DBC files for data analysis and storage.
It improves the convenience of CAN data acquisition, reduces equipment costs, does not need to be reset automatically to detect baud rate, and has strong anti-interference ability of signal, avoids the inconvenience of reupdating the mobile client due to protocol updates, and supports multi-platform data analysis.
Smart Images

Figure CN110660210B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of data acquisition, and in particular relates to a data acquisition system and method based on CAN bus and wireless communication. Background Art
[0002] At present, the CAN bus data collection tools used in the automotive communication and related industries mainly include VECTOR, ZLGCAN, KVASER, etc. Even the products with high cost performance have prices ranging from several thousand to over ten thousand. At the same time, CAN data collection and analysis require supporting PC client software, and laptops have also become one of the necessary testing tools. For companies in the automotive field, after-sales personnel need to generally have the ability to collect and analyze messages. The high equipment cost and the use training of the corresponding software have brought certain economic pressure to the companies.
[0003] At the same time, some products with CAN data wireless collection function generally need to be customized for the mobile client data parsing solution. The parsing content needs to be written into the underlying code of the mobile client according to the user's CAN communication protocol. If the CAN communication protocol is updated, the mobile client also needs to be updated, which is more difficult to maintain and may also result in secondary charges. Summary of the invention
[0004] The technical problem to be solved by the present invention is to overcome the shortcomings of the prior art and provide a data acquisition system and method based on CAN bus and wireless communication, which is used to solve the problems of inconvenience of traditional wired CAN data acquisition and troublesome maintenance of mobile terminals. CAN data acquisition is performed by wireless method instead of traditional wired method, and the problem of mobile terminal parsing data is solved by loading DBC.
[0005] The technical solution of the present invention to solve the above technical problem is as follows: A data acquisition system based on CAN bus and wireless communication includes a data acquisition unit and a mobile terminal, wherein the data acquisition unit is connected to the mobile terminal;
[0006] The data acquisition unit includes a microprocessor, a switching unit connected to the microprocessor, and a wireless communication unit, and the data acquisition unit collects, encodes, and wirelessly transmits external CAN bus data to the mobile terminal;
[0007] The mobile terminal is used to display, analyze and store the received data.
[0008] Furthermore, the data acquisition unit is wirelessly connected to the mobile terminal via the wireless communication unit.
[0009] Furthermore, the adapter unit includes a CAN communication unit, a voltage conditioning unit and a serial communication unit, all of which are connected to the microprocessor, the CAN communication unit is connected to an external CAN bus, the voltage conditioning unit is connected to an external power supply, the serial communication unit is connected to the wireless communication unit, and the serial communication unit is used to transfer the encoded data of the microprocessor to the wireless communication unit.
[0010] Furthermore, the wireless communication unit includes a wireless WIFI module and / or a Bluetooth module.
[0011] Furthermore, the data acquisition unit also includes an LED indicator light connected to the microprocessor.
[0012] Furthermore, the LED indicator light includes a power indicator light, a CAN communication indicator light and a fault indicator light, and the CAN communication indicator light is used to display the load rate of the microprocessor.
[0013] Furthermore, the mobile terminal is a mobile phone terminal installed with an application program, and the mobile phone terminal is connected to the wireless communication unit.
[0014] Furthermore, the application of the mobile terminal is used to decode and display the data received from the wireless communication unit, and to perform message parsing and real-time data storage according to the imported DBC file.
[0015] Based on the above-mentioned data acquisition system based on CAN bus and wireless communication, the present invention also discloses a data acquisition method based on CAN bus and wireless communication, comprising the following steps:
[0016] S101: After the data acquisition unit is powered on normally, it is initialized and the power indicator light is turned on, the baud rate of the CAN bus is automatically detected, the correct baud rate is matched, and the wireless hotspot or Bluetooth is turned on;
[0017] S102: The mobile terminal connects to the wireless hotspot or Bluetooth emitted by the data acquisition unit and enters S103;
[0018] S103: The mobile terminal detects a user's operation request and sends an operation instruction, otherwise a loop judgment is performed;
[0019] S104: The data acquisition unit determines whether an operation instruction is received. If an operation instruction is received, the process proceeds to S105, otherwise a loop determination is performed;
[0020] S105: After receiving the operation instruction sent by the mobile terminal, the data acquisition unit starts to collect CAN data and encodes the data. The main encoding content includes CAN channel, ID, data, load rate, check byte, frame start, and frame stop;
[0021] S106: The data acquisition unit adjusts the flashing frequency of the CAN indicator light according to the load rate calculated in real time. The flashing frequency of the indicator light becomes faster as the amount of CAN data increases. If there is no data, the indicator light will not light up.
[0022] S107: The data collection unit transparently transmits the encoded data to the mobile terminal via the wireless communication unit and the TCP protocol or the Bluetooth baseband protocol;
[0023] S108: The mobile terminal receives the encoded data and decodes it;
[0024] S109: The mobile terminal displays the decoded data on the interface, and the displayed content mainly includes the receiving data time, CAN channel, ID, and data, and then enters S110;
[0025] S110: Determine whether the storage flag is on. If it is on, data is stored according to the storage rule. After the data is stored, enter S111. If the flag is not on, directly enter S111.
[0026] S111: If the mobile terminal detects a DBC parsing request from the user, it enters the DBC parsing interface and proceeds to S112; otherwise, it proceeds to S116;
[0027] S112: After entering the DBC parsing interface, the user selects a DBC parsing file, imports the parsing information required in the DBC file into the dynamic array, and enters S113;
[0028] S113: After the user selects the data to be analyzed in the analysis interface, the process proceeds to S114;
[0029] S114: performing data analysis according to the content of the DBC file, the analysis content includes the name corresponding to the ID, the signal corresponding to the data, the signal physical value, and the signal value table;
[0030] S115: The mobile terminal detects a user return request in the DBC parsing interface and returns to S109, otherwise, S113 to S115 are repeated;
[0031] S116: The mobile terminal detects a user storage request and proceeds to S117, otherwise proceeds to S118;
[0032] S117: After entering the storage interface, the user is prompted to select a storage format, storage name, and storage path, turn on the storage flag, and enter S118;
[0033] S118: The mobile terminal detects a user shutdown request and enters S119, otherwise returns to S108;
[0034] S119: The mobile terminal sends a stop instruction to the data acquisition unit;
[0035] S120: The data acquisition unit receives a stop instruction, stops CAN data acquisition and stops sending coded data.
[0036] The beneficial effects of the present invention are:
[0037] 1. Using mobile phone terminals to collect CAN data wirelessly improves the convenience of CAN bus data collection compared to traditional PC and wired collection methods;
[0038] 2. The data acquisition unit can convert the 12-24V OBD interface voltage into 3.3V voltage to solve the problem of different OBD interface voltages for passenger cars and commercial vehicles;
[0039] 3. The data acquisition unit can automatically detect the baud rate of CAN communication, and can complete the communication connection for different devices under test without resetting;
[0040] 4. The data acquisition unit can send out wireless hotspots by itself or connect to mobile phones via Bluetooth. There is no need to connect to external WIFI networks or mobile phone hotspots. The signal has strong anti-interference ability and high data transmission reliability.
[0041] 5. Mobile phones can import DBC parsing files to parse the collected CAN data, while improving system compatibility and scalability, avoiding the inconvenience of having to update the mobile phone after the communication protocol is modified;
[0042] 6. The mobile phone terminal will store the collected CAN data in real time and can convert the storage files into different formats, providing a data basis for multi-platform data analysis. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0044] Figure 1 A system structure block diagram of a specific embodiment of the present invention;
[0045] Figure 2 This is a basic control flow chart described in a specific embodiment of the present invention. DETAILED DESCRIPTION
[0046] The following embodiments of the technical solution of the present invention are described in detail in conjunction with the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and are therefore only used as examples, and cannot be used to limit the protection scope of the present invention.
[0047] It should be noted that, unless otherwise specified, the technical terms or scientific terms used in this application should have the common meanings understood by those skilled in the art to which the present invention belongs.
[0048] In the description of the present application, it should be understood that the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", "clockwise", "counterclockwise", "axial", "radial", "circumferential" and the like indicate orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the referred device or element must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as limiting the present invention.
[0049] In this application, unless otherwise clearly specified and limited, the terms "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0050] Example
[0051] like Figure 1 As shown, a data acquisition system based on CAN bus and wireless communication provided by the present invention includes a data acquisition unit and a mobile terminal, wherein the mobile terminal is a mobile phone terminal, the data acquisition unit is connected to the vehicle OBD interface, collects CAN bus data, and encodes and uploads it, and the data acquisition unit includes a wireless communication unit for providing a wireless hotspot for the mobile phone terminal to connect to the data acquisition unit through the wireless communication unit to form a local area network. After the mobile phone terminal is connected to the wireless hotspot, the received encoded data is decoded and displayed and stored, and data analysis can also be performed according to the imported DBC file.
[0052] The data acquisition unit also includes a microprocessor and a switching unit and an LED indicator light connected to the microprocessor. The switching unit includes a voltage conditioning unit, a CAN communication unit, and a serial communication unit all connected to the microprocessor. The microprocessor adopts a single-chip microcomputer of the STM32F103 series. The voltage conditioning unit is mainly composed of an LM2596 chip and its peripheral circuits, which are connected to the vehicle OBD interface and are used to adjust the vehicle's 12-24V voltage to a 3.3V voltage as a power supply for the microprocessor and the wireless communication unit. The data acquisition unit sets the baud rate of the CAN bus in sequence, reads the correct data after the setting is successfully matched, and fixes the setting to complete the automatic detection of the baud rate of the CAN bus.
[0053] Among them, the CAN communication unit is implemented by using the TJA1050 chip and its peripheral circuits. The CAN communication unit is connected to the CAN bus of the vehicle's OBD interface and is used to transmit CAN bus data to the microprocessor in real time. The serial communication unit uses the MAX232 chip to realize the communication between the microprocessor and the wireless communication unit, and transmits the data encoded by the microprocessor to the wireless communication unit.
[0054] In this embodiment, the LED indicator lights include a power indicator light, a CAN communication indicator light, and a fault indicator light, all of which are connected to the microprocessor through an I / O interface, wherein the flashing frequency of the CAN communication indicator light is used to indicate the real-time load rate of the microprocessor.
[0055] In this embodiment, the wireless communication unit is constructed using a wireless chip whose main chip is ESP8266 or a chip of model HC-08. Its specific purpose is to communicate with the microprocessor through the serial communication unit and AT command rules to realize data reception and feedback. During power-on initialization, the ESP8266 chip establishes a wireless hotspot according to the hotspot establishment request sent by the microprocessor, and the HC-08 chip establishes a Bluetooth communication connection according to the request sent by the microprocessor to realize Bluetooth communication. After receiving the encoded data, it is transparently transmitted to the mobile phone terminal.
[0056] At the same time, the mobile terminal is a mobile client with an application based on the Android system, which has the functions of display, analysis and storage. After connecting to the hotspot emitted by the wireless communication unit, or connecting to the wireless communication unit via Bluetooth, it can receive the CAN bus data uploaded by it and decode and display it;
[0057] Among them, the data parsing function of the mobile client is specifically reflected as follows: after importing the DBC file, the DBC file stored locally on the mobile client is extracted, and the information required for parsing CAN is stored in a dynamic array according to certain rules to improve the retrieval speed of the specified CAN data parsing. After the user selects the CAN data to be parsed, it is directly searched in the dynamic array and displayed on the mobile client.
[0058] Among them, the data storage function of the mobile client mainly writes real-time data to files according to the file storage rules of asc, csv, and txt.
[0059] Based on the above-mentioned data acquisition system based on CAN bus and wireless communication, the present invention also discloses a data acquisition method based on CAN bus and wireless communication, comprising the following steps:
[0060] S101: After the data acquisition unit is powered on normally, it is initialized and the power indicator light is turned on, the baud rate of the CAN bus is automatically detected, the correct baud rate is matched, and the wireless hotspot or Bluetooth is turned on;
[0061] S102: The mobile terminal connects to the wireless hotspot or Bluetooth emitted by the data acquisition unit and enters S103;
[0062] S103: The mobile terminal detects a user's operation request and sends an operation instruction, otherwise a loop judgment is performed;
[0063] S104: The data acquisition unit determines whether an operation instruction is received. If an operation instruction is received, the process proceeds to S105, otherwise a loop determination is performed;
[0064] S105: After receiving the operation instruction sent by the mobile terminal, the data acquisition unit starts to collect CAN data and encodes the data. The main encoding content includes CAN channel, ID, data, load rate, check byte, frame start, and frame stop;
[0065] S106: The data acquisition unit adjusts the flashing frequency of the CAN indicator light according to the load rate calculated in real time. The flashing frequency of the indicator light becomes faster as the amount of CAN data increases. If there is no data, the indicator light will not light up.
[0066] S107: The data collection unit transparently transmits the encoded data to the mobile terminal via the wireless communication unit and the TCP protocol or the Bluetooth baseband protocol;
[0067] S108: The mobile terminal receives the encoded data and decodes it;
[0068] S109: The mobile terminal displays the decoded data on the interface, and the displayed content mainly includes the receiving data time, CAN channel, ID, and data, and then enters S110;
[0069] S110: Determine whether the storage flag is on. If it is on, data is stored according to the storage rule. After the data is stored, enter S111. If the flag is not on, directly enter S111.
[0070] S111: If the mobile terminal detects a DBC parsing request from the user, it enters the DBC parsing interface and proceeds to S112; otherwise, it proceeds to S116;
[0071] S112: After entering the DBC parsing interface, the user selects a DBC parsing file, imports the parsing information required in the DBC file into the dynamic array, and enters S113;
[0072] S113: After the user selects the data to be analyzed in the analysis interface, the process proceeds to S114;
[0073] S114: performing data analysis according to the content of the DBC file, the analysis content includes the name corresponding to the ID, the signal corresponding to the data, the signal physical value, and the signal value table;
[0074] S115: The mobile terminal detects a user return request in the DBC parsing interface and returns to S109, otherwise, S113 to S115 are repeated;
[0075] S116: The mobile terminal detects a user storage request and proceeds to S117, otherwise proceeds to S118;
[0076] S117: After entering the storage interface, the user is prompted to select a storage format, storage name, and storage path, turn on the storage flag, and enter S118;
[0077] S118: The mobile terminal detects a user shutdown request and enters S119, otherwise returns to S108;
[0078] S119: The mobile terminal sends a stop instruction to the data acquisition unit;
[0079] S120: The data acquisition unit receives a stop instruction, stops CAN data acquisition and stops sending coded data.
[0080] Specific working principle: Before the implementation of this embodiment, the name, password, IP, port number and wireless transmission protocol of the wireless hotspot need to be solidified into the program of the microprocessor. When the microprocessor is powered on and initialized, the wireless communication unit is controlled by AT instructions to perform corresponding operations.
[0081] Specifically, the data acquisition unit is first connected to the vehicle OBD interface, and the 12-24V power supply of the OBD interface is used to convert the 3.3V voltage converted by the voltage conditioning unit as the power supply for the microprocessor and the wireless communication unit in the data acquisition unit. The initialization content mainly includes turning on the power indicator light after the microprocessor is powered normally, automatically detecting and matching the baud rate of the CAN bus in the OBD interface, and after the baud rate configuration is successful, the wireless communication unit is initially set up through the AT command, a wireless hotspot or Bluetooth connection is established, and the mobile client is waiting for the connection. After the user's mobile phone is connected to the wireless hotspot or Bluetooth, the mobile client application software is opened, and a communication connection is automatically established according to the IP and port number of the data acquisition unit. When the user's operation request is detected, the operation instruction is sent to the microprocessor through the wireless communication unit and the serial communication unit. After receiving the operation request, the microprocessor runs the CAN data acquisition task, encodes the ID, content, CAN channel, check byte, frame start and frame end of the collected CAN data into a frame of data, and then uploads it to the mobile client through the serial communication unit and the wireless communication unit. After receiving the coded data, the mobile client parses it according to the rules and displays it on the interface. When the mobile client detects that the user has a request for data parsing, a data parsing interface pops up to prompt the user to import the DBC parsing file. During the import process, the mobile client stores the name corresponding to the CAN data ID in the DBC file, the name corresponding to the CAN data signal, the start bit and length of the CAN data signal in the entire CAN data, the resolution and offset of the CAN data signal, the unit of the CAN data signal, the format of the CAN data signal, the numerical table of the CAN data signal, etc. in a dynamic array according to certain rules. After the mobile client detects that the user has selected the CAN data to be parsed, it quickly searches in the dynamic array, parses the data according to the parsing rules, and displays it on the parsing interface of the mobile client. When the mobile client detects a user storage request, a storage interface pops up to prompt the user to select the format, storage name and storage path to be stored, and continuously writes real-time data to the storage file according to the storage format rules. When the mobile client detects a user stop request, a stop command is sent through the wireless communication unit and the serial communication unit. After the data acquisition unit detects the stop command, the CAN data acquisition is stopped.
[0082] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A data acquisition method based on CAN bus and wireless communication, characterized in that: The acquisition system comprises a data acquisition unit and a mobile terminal, wherein the data acquisition unit is connected to the mobile terminal; The data acquisition unit includes a microprocessor, a switching unit connected to the microprocessor, and a wireless communication unit, and the data acquisition unit collects, encodes, and wirelessly transmits external CAN bus data to the mobile terminal; The mobile terminal is used to display, analyze and store the received data; The collection method comprises the following steps: S101: After the data acquisition unit is powered on normally, it is initialized and the power indicator light is turned on, the baud rate of the CAN bus is automatically detected, the correct baud rate is matched, and the wireless hotspot or Bluetooth is turned on; S102: The mobile terminal connects to the wireless hotspot or Bluetooth emitted by the data acquisition unit and enters S103; S103: The mobile terminal detects a user's operation request and sends an operation instruction, otherwise a loop judgment is performed; S104: The data acquisition unit determines whether an operation instruction is received. If an operation instruction is received, the process proceeds to S105, otherwise a loop determination is performed; S105: After receiving the operation instruction sent by the mobile terminal, the data acquisition unit starts to collect CAN data and encodes the data. The main encoding content includes CAN channel, ID, data, load rate, check byte, frame start, and frame stop; S106: The data acquisition unit adjusts the flashing frequency of the CAN indicator light according to the load rate calculated in real time. The flashing frequency of the indicator light becomes faster as the amount of CAN data increases. If there is no data, the indicator light will not light up. S107: The data collection unit transparently transmits the encoded data to the mobile terminal via the wireless communication unit and the TCP protocol or the Bluetooth baseband protocol; S108: The mobile terminal receives the encoded data and decodes it; S109: The mobile terminal displays the decoded data on the interface, and the displayed content mainly includes the receiving data time, CAN channel, ID, and data, and then enters S110; S110: Determine whether the storage flag is on. If it is on, data is stored according to the storage rule. After the data is stored, enter S111. If the flag is not on, directly enter S111. S111: If the mobile terminal detects a DBC parsing request from the user, it enters the DBC parsing interface and proceeds to S112; otherwise, it proceeds to S116; S112: After entering the DBC parsing interface, the user selects a DBC parsing file, imports the parsing information required in the DBC file into the dynamic array, and enters S113; S113: After the user selects the data to be analyzed in the analysis interface, the process proceeds to S114; S114: performing data analysis according to the content of the DBC file, the analysis content includes the name corresponding to the ID, the signal corresponding to the data, the signal physical value, and the signal value table; S115: The mobile terminal detects a user return request in the DBC parsing interface and returns to S109, otherwise, S113 to S115 are repeated; S116: The mobile terminal detects a user storage request and proceeds to S117, otherwise proceeds to S118; S117: After entering the storage interface, the user is prompted to select a storage format, storage name, and storage path, turn on the storage flag, and enter S118; S118: The mobile terminal detects a user shutdown request and enters S119, otherwise returns to S108; S119: The mobile terminal sends a stop instruction to the data acquisition unit; S120: The data acquisition unit receives a stop instruction, stops CAN data acquisition and stops sending coded data.
2. The data acquisition method of the data acquisition system based on CAN bus and wireless communication according to claim 1, characterized in that: The data acquisition unit is wirelessly connected to the mobile terminal via the wireless communication unit.
3. The data acquisition method of the data acquisition system based on CAN bus and wireless communication according to claim 2 is characterized in that: The adapter unit includes a CAN communication unit, a voltage conditioning unit and a serial communication unit, all of which are connected to the microprocessor. The CAN communication unit is connected to an external CAN bus, the voltage conditioning unit is connected to an external power supply, the serial communication unit is connected to the wireless communication unit, and the serial communication unit is used to transmit the encoded data of the microprocessor to the wireless communication unit.
4. The data acquisition method of the data acquisition system based on CAN bus and wireless communication according to claim 3 is characterized in that: The wireless communication unit includes a wireless WIFI module and / or a Bluetooth module.
5. The data acquisition method of the data acquisition system based on CAN bus and wireless communication according to claim 1, characterized in that: The data acquisition unit also includes an LED indicator light connected to the microprocessor.
6. The data acquisition method of the data acquisition system based on CAN bus and wireless communication according to claim 5, characterized in that: The LED indicator lights include a power indicator light, a CAN communication indicator light and a fault indicator light. The CAN communication indicator light is used to display the load rate of the microprocessor.
7. The data acquisition method of the data acquisition system based on CAN bus and wireless communication according to claim 1, characterized in that: The mobile terminal is a mobile phone terminal installed with an application program, and the mobile phone terminal is connected to the wireless communication unit.
8. The data acquisition method of the data acquisition system based on CAN bus and wireless communication according to claim 7, characterized in that: The application of the mobile terminal is used to decode and display the data received from the wireless communication unit, and to perform message parsing and real-time data storage according to the imported DBC file.
