Control local area network bus data acquisition device
By screening and storing key node data in the CAN bus data acquisition device, the problems of low data storage efficiency and difficulty in extracting key information in the prior art are solved, and efficient data storage and real-time data processing are realized.
Patent Information
- Application Number
- CN202510179497.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-19
- Publication Date
- 2025-05-23
AI Technical Summary
The existing CAN bus data acquisition solutions have problems such as low data storage efficiency, difficulty in extracting key information, and difficulty in taking into account real-time and data processing efficiency.
It provides a control LAN bus data acquisition device, which receives the original data on the CAN bus through the main control chip and the communication module, filters out the key node data, and stores the original data and the key node data into the structure variable and memory respectively.
It improves the storage efficiency of CAN bus data, reduces the difficulty and time cost of data analysis, and ensures the efficiency of real-time data acquisition and processing.
Smart Images

Figure CN120034490A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of bus data acquisition, and in particular to a control local area network bus data acquisition device. Background Art
[0002] At present, Controller Area Network (CAN) bus data acquisition devices are widely used in automotive electronics, industrial control and other fields. CAN bus data acquisition mainly includes the following types:
[0003] Full data collection and storage: Collect and store all data on the CAN bus. The collected data is complete, but the data volume is huge, the storage space is large, the later data analysis is difficult, and it may cause the flooding of key information.
[0004] Data collection based on specific ID filtering: Filter data based on the preset CAN ID list and only collect data of specific IDs. It can reduce the amount of data, but it is not flexible enough to adapt to complex application scenarios, and may collect a large amount of irrelevant redundant data.
[0005] Real-time monitoring and analysis by the host computer: The collected CAN bus data is transmitted to the host computer for analysis in real time. It can monitor the system status in real time, but it depends on the processing power of the host computer and cannot perform offline analysis. Data storage also depends on the host computer.
[0006] In summary, the relevant CAN bus data acquisition solutions have the following problems:
[0007] Low data storage efficiency: The full data collection method stores a large amount of redundant data, resulting in a waste of storage space and shortening the life of the storage medium.
[0008] Difficulty in extracting key information: It is difficult to quickly extract key information from large amounts of data, which increases the difficulty and time cost of data analysis.
[0009] It is difficult to strike a balance between real-time performance and data processing efficiency: In embedded systems with limited resources, it is difficult to strike a balance between real-time data acquisition and complex data processing, which may result in data loss or system response delays.
[0010] Insufficient system flexibility: The method based on fixed ID filtering is difficult to adapt to complex application scenarios and requires frequent configuration changes. Summary of the invention
[0011] The purpose of this application is to provide a control local area network bus data acquisition device, which can improve the storage efficiency of CAN bus data and reduce the difficulty of analyzing CAN bus data.
[0012] To achieve the above objectives, this application provides the following solutions:
[0013] The present application provides a control LAN bus data acquisition device, comprising: a main control chip and a communication module;
[0014] The main control chip is connected to the bus under test through the communication module;
[0015] The main control chip is used to receive the original data of each device on the bus under test through the communication module, filter out key node data from the original data, store the original data in a structure variable, and store the key node data in a memory.
[0016] Optionally, the main control chip is a CH32 series microcontroller.
[0017] Optionally, the communication module is a control area network transceiver.
[0018] Optionally, the main control chip is also connected to a host computer; the main control chip is also used to receive interaction instructions from the host computer, and respond to the interaction instructions according to the key node data.
[0019] Optionally, the main control chip periodically stores the original data into a structure variable.
[0020] Optionally, the control LAN bus data acquisition device also includes a power module; the power module is connected to the main control chip and the communication module respectively, and the power module is used to supply power to the main control chip and the communication module.
[0021] Optionally, the control LAN bus data acquisition device further includes a power failure detection module and an SD memory card;
[0022] The power failure detection module is connected to the power module and the main control chip respectively; the power failure detection module is used to convert the voltage output by the power module into a voltage detection signal in real time, and send the voltage detection signal to the main control chip;
[0023] The main control chip is also connected to the SD memory card; the main control chip is also used to determine in real time whether the voltage value of the voltage detection signal is less than a set threshold, and when the voltage value of the voltage detection signal is less than the set threshold, the original data and the key node data are stored in the SD memory card.
[0024] Optionally, when the voltage value of the voltage detection signal is less than a set threshold, the main control chip stores the original data in the SD memory card in CSV format, and stores the key node data in the SD memory card in TXT format.
[0025] Optionally, the main control chip is also used to determine whether the original data contains valid time information. If so, a CSV file is created using the valid time information as the file name. If not, a CSV file is created using a default file name to store the original data.
[0026] Optionally, the control LAN bus data acquisition device also includes a USB-TYPEC interface; the SD memory card communicates with an external computer via the USB-TYPEC interface to export the original data and key node data stored in the SD memory card to the external computer.
[0027] According to the specific embodiments provided in this application, this application has the following technical effects:
[0028] The present application provides a control local area network bus data acquisition device, in which a main control chip receives raw data of each device on the bus under test through a communication module, stores the raw data in a structure variable, and screens out key node data from the raw data, and stores the key node data in a memory, thereby avoiding the problem of huge data volume and difficult analysis caused by storing all CAN bus data, and improving the storage efficiency of CAN bus data. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0030] Figure 1 A schematic diagram of a control LAN bus data acquisition device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0031] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0032] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0033] In an exemplary embodiment, Figure 1As shown, a control local area network bus data acquisition device is provided, including a main control chip 1 and a communication module 2.
[0034] The main control chip 1 is connected to the bus under test 3 through the communication module 2 .
[0035] The main control chip 1 is used to receive the original data of each device on the bus under test 3 through the communication module 2, filter out key node data from the original data, store the original data in a structure variable, and store the key node data in a memory.
[0036] The main control chip 1 periodically stores the original data into a structure variable.
[0037] In a specific application example, the main control chip 1 is a CH32 series microcontroller. The communication module 2 is a control local area network transceiver.
[0038] In another exemplary embodiment, the main control chip 1 is also connected to the host computer 4. The main control chip 1 is also used to receive the interactive instructions of the host computer 4, and respond to the interactive instructions according to the key node data. The main control chip 1 can also exchange data with the host computer 4 through the control LAN transceiver. Among them, the interactive instruction can be a query instruction, including a query ID and query information.
[0039] In another exemplary embodiment, the control LAN bus data acquisition device further includes a power module 5. The power module 5 is connected to the main control chip 1 and the communication module 2 respectively, and the power module 5 is used to supply power to the main control chip 1 and the communication module 2.
[0040] Specifically, the power module 5 is powered by an external power supply. The power module 5 provides a 9V to 32V DC power supply to the main control chip 1 and the communication module 2. The power module 5 includes two DC-DC converters, 2405 and 2403. 2405 powers the CAN transceiver, and 2403 powers the CH32 series microcontroller. The CH32 series microcontroller powers the SD memory card 7.
[0041] In another exemplary embodiment, the control LAN bus data acquisition device further includes a power-off detection module 6 and an SD memory card 7 .
[0042] The power failure detection module 6 is respectively connected to the power module 5 and the main control chip 1. The power failure detection module 6 is used to convert the voltage output by the power module 5 into a voltage detection signal in real time, and send the voltage detection signal to the main control chip 1.
[0043] The main control chip 1 is also connected to the SD memory card 7. The main control chip 1 is also used to determine in real time whether the voltage value of the voltage detection signal is less than a set threshold (optionally 2.7V), and when the voltage value of the voltage detection signal is less than the set threshold, the original data and the key node data are stored in the SD memory card 7.
[0044] Specifically, when the voltage value of the voltage detection signal is less than a set threshold, the main control chip 1 stores the original data in the SD memory card 7 in a CSV format, and stores the key node data in the SD memory card 7 in a TXT format.
[0045] In a specific application example, the main control chip 1 communicates with the SD memory card 7 via the SDIO interface, writes the original data into the SD memory card 7 in CSV format using the FATFS file system, and writes the key node data into the SD memory card 7 in TXT format.
[0046] In another exemplary embodiment, the main control chip 1 is also used to determine whether the original data contains valid time information. If so, a CSV file is created using the valid time information as the file name. If not, a CSV file is created using a default file name to store the original data.
[0047] In another exemplary embodiment, the control LAN bus data acquisition device further includes a USB-TYPEC interface. The SD memory card 7 communicates with an external computer via the USB-TYPEC interface to export the original data and key node data stored in the SD memory card 7 to the external computer.
[0048] The host computer 4 can exchange data with the main control chip 1 through CAN communication to query required data, and can also connect to the USB-TYPEC interface to communicate with the SD memory card 7 through USB to read data files stored in the SD memory card 7.
[0049] The present application can parse and filter the collected data, store the filtered key node data in the storage medium according to the time information, and extract the required data from the file and report it through the CAN bus according to the interactive instructions issued by the host computer 4. When the deviation of the tested bus 3 is detected, it can try to automatically recover until it works normally.
[0050] The following introduces the overall working process of the control LAN bus data acquisition device provided by the present application.
[0051] (1) The control LAN bus data acquisition device is mounted on the bus under test 3 through the CAN interface.
[0052] (2) After the main control chip 1 receives the node data from other devices on the bus 3 under test, it enters the CAN interrupt. If the received raw data is astronomical time data, the year, month, and day time information is directly stored in the year, month, and day variables. Otherwise, the collected raw data is stored in the can_data structure variable to store the id information and data information.
[0053] (3) In the main function, the data received in can_data is classified and stored in the can_data_for_write and can_data_for_not_write structure arrays. Among them, can_data_for_write is the bus data information that needs to be stored according to the CAN communication protocol, and can_data_for_not_write is the interactive instruction of the host computer 4. The can_data_for_write raw data is stored in a cycle of 1 second. After each recording cycle begins, the data of each CAN ID is sampled and recorded once. Even if new data appears in the ID in the same cycle, it will no longer be recorded, thereby avoiding data redundancy and reducing storage space occupancy.
[0054] (4) Filter and process the can_data_for_write raw data to select the bus data information of key nodes, such as engine speed, vehicle speed, fuel consumption, etc. Store the key node data in keydata. When the key node data is received next time, compare it with the keydata in the memory. If it is greater than the current value, update keydata. If it is less than or equal to the current value, keydata remains unchanged.
[0055] (5) can_data_for_not_write stores the query ID and query information sent by the host computer 4, and different IDs respond to different contents. According to the provisions of the CAN communication protocol, the software version number, generation time and key node data (statistical parameters such as engine speed, vehicle speed, fuel consumption, etc.) can be responded. After the response is completed, the can_data_for_not_write data is cleared and waits for the next query instruction.
[0056] For example, the instruction id sent by the host computer 4 is 0x123, the first byte is 01, and the main control chip 1 responds with software version information; the id is 0x123, the first byte is 11, and the main control chip 1 responds with software version information; the id is 0x456, and the main control chip 1 responds with today's maximum engine speed, etc.
[0057] (6) Create a new data file for data storage based on the received time information. If the main control chip 1 receives valid time information from the bus 3 under test, such as the Global Positioning System (GPS) time or the time provided by other timing systems, the time information is used as the file name in the format of YYYYMMDD_(serial number).csv; if no valid time information is received, a new file is created using the default file name "data_(serial number).csv". can_data_for_write The original data is stored in the .csv file. The key node data is stored in the .txt file. The file name follows the same naming rules as the original data file, and the meaning of each parameter is indicated in the file.
[0058] (7) Data export:
[0059] Query and export of host computer 4: The user issues a query command through the cantest software of host computer 4 to query key node data. The query command contains the ID of the target parameter. After receiving the query command, the main control chip 1 accesses the corresponding data in the SD memory card 7 and sends the query result to the host computer 4.
[0060] USB-TYPEC cable export: Users can directly export detailed raw data and key node data in the SD memory card 7 to the computer via the USB-TYPEC cable. After connecting the USB-TYPEC cable, the control LAN bus data acquisition device will automatically mount as a storage device, and users can directly access the data files in it.
[0061] Compared with the related art, the beneficial effects of this application include the following points:
[0062] 1) Targeted data collection: Focus on processing key node data (such as engine and transmission system data), and periodically save the original values of the remaining CAN data, avoiding the problem of huge data volume and difficult analysis caused by storing all CAN bus data.
[0063] 2) Timestamp-based file naming facilitates data management: Generating file names based on time information makes it easier for users to classify, retrieve and manage data, thereby improving data processing efficiency.
[0064] 3) Efficient processing of CAN bus data and host computer instructions: Only data is received and initially stored in the CAN interrupt, which shortens the interrupt response time, ensures real-time acquisition of CAN data, and avoids data loss. It is especially suitable for application scenarios with high real-time requirements. The main program is responsible for data screening, classification, storage and host computer instruction processing to achieve efficient data management and fast instruction response. The interrupt and main program work together to avoid mutual interference, reduce the probability of interrupt errors, and improve overall stability and reliability.
[0065] 4) Flexible data export methods: It provides two methods: host computer query export and USB-TYPEC cable direct export, taking into account both efficiency and integrity. Host computer query export can quickly obtain key node data, which is suitable for real-time monitoring and rapid diagnosis; USB-TYPEC cable direct export can obtain all data, which is suitable for offline in-depth analysis.
[0066] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0067] In this application, all actions to obtain signals, information or data are carried out in compliance with the relevant data protection laws and policies of the country where they are located and with the authorization given by the owner of the corresponding device.
[0068] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0069] This article uses specific examples to illustrate the principles and implementation methods of this application. The description of the above embodiments is only used to help understand the method and core ideas of this application. At the same time, for those skilled in the art, according to the ideas of this application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting this application.
Claims
1. A control LAN bus data acquisition device, characterized in that: The control LAN bus data acquisition device comprises: a main control chip and a communication module; The main control chip is connected to the bus under test through the communication module; The main control chip is used to receive the original data of each device on the bus under test through the communication module, filter out key node data from the original data, store the original data in a structure variable, and store the key node data in a memory.
2. The control LAN bus data acquisition device according to claim 1, characterized in that: The main control chip is a CH32 series microcontroller.
3. The control LAN bus data acquisition device according to claim 1, characterized in that: The communication module is a control area network transceiver.
4. The control LAN bus data acquisition device according to claim 1, characterized in that: The main control chip is also connected to the host computer; the main control chip is also used to receive interactive instructions from the host computer and respond to the interactive instructions according to the key node data.
5. The control LAN bus data acquisition device according to claim 1, characterized in that: The main control chip periodically stores the original data into a structure variable.
6. The control LAN bus data acquisition device according to claim 1, characterized in that: The control LAN bus data acquisition device also includes a power module; the power module is connected to the main control chip and the communication module respectively, and the power module is used to supply power to the main control chip and the communication module.
7. The control LAN bus data acquisition device according to claim 6, characterized in that: The control LAN bus data acquisition device also includes a power failure detection module and an SD memory card; The power failure detection module is connected to the power module and the main control chip respectively; the power failure detection module is used to convert the voltage output by the power module into a voltage detection signal in real time, and send the voltage detection signal to the main control chip; The main control chip is also connected to the SD memory card; the main control chip is also used to determine in real time whether the voltage value of the voltage detection signal is less than a set threshold, and when the voltage value of the voltage detection signal is less than the set threshold, the original data and the key node data are stored in the SD memory card.
8. The control LAN bus data acquisition device according to claim 7, characterized in that: When the voltage value of the voltage detection signal is less than a set threshold, the main control chip stores the original data in the SD memory card in a CSV format, and stores the key node data in the SD memory card in a TXT format.
9. The control LAN bus data acquisition device according to claim 8, characterized in that: The main control chip is also used to determine whether the original data contains valid time information. If so, a CSV file is created using the valid time information as the file name. If not, a CSV file is created using a default file name to store the original data.
10. The control LAN bus data acquisition device according to claim 7, characterized in that: The control LAN bus data acquisition device also includes a USB-TYPEC interface; the SD memory card communicates with an external computer via the USB-TYPEC interface to export the original data and key node data stored in the SD memory card to the external computer.