Adaptive data compression method and system for controller area network (CAN)
By monitoring the CAN bus load rate and fluctuation analysis, and dynamically selecting the compression encoding mode, the problems of data transmission delay and low efficiency under high load of CAN network are solved. This enables efficient data compression in environments with high real-time requirements, improving the real-time performance and reliability of the system.
Patent Information
- Application Number
- CN202511256364.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-03
- Publication Date
- 2025-12-12
AI Technical Summary
Existing CAN data transmission technology cannot dynamically adapt to changes in bus load and lacks an effective data compression mechanism, resulting in increased data transmission latency and reduced communication efficiency under high load. Furthermore, traditional data compression methods are computationally complex and unsuitable for CAN network environments with high real-time requirements.
By monitoring the real-time bus load rate of the CAN bus, dynamically entering or exiting the compression mode, performing fluctuation analysis on the target data signal, selecting an appropriate compression encoding mode, and deciding whether to send the compressed message based on net benefit, the system includes a bus load monitoring module, a mode control module, a signal analysis module, a compression mode selection module, a data compression module, and a data receiving and parsing module.
It improves the real-time performance and reliability of the CAN network, optimizes data transmission efficiency, ensures good communication performance under different load conditions, and enhances the system's anti-interference ability and adaptability.
Smart Images

Figure CN121125015A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of industrial automation and automotive electronics, and more particularly, to an adaptive data compression method and system for controller area network. BACKGROUND
[0002] In the field of modern industrial automation and automotive electronics, controller area network (CAN) is widely used for data communication between devices. CAN network has become the preferred solution for communication between many distributed control systems and vehicle electronic control units (ECU) due to its high reliability, multi-master communication capability and good anti-interference performance. However, with the increasing complexity of the system and the growing demand for data transmission, the load problem of CAN bus gradually emerges. High load rate can lead to increased data transmission delay, reduced communication efficiency, and even data loss, which seriously affects the real-time performance and reliability of the system.
[0003] Existing CAN data transmission technology mainly relies on fixed data frame format and transmission rate, lacking adaptability to dynamic load in data transmission process. In the case of large data volume or high communication frequency, the bus load rate is likely to exceed the design threshold, causing communication bottlenecks. In addition, although traditional data compression methods can reduce data volume to some extent, they often require complex algorithms and high computational resources, and the compression effect is limited, making it difficult to effectively apply in CAN networks with high real-time requirements.
[0004] In the implementation of the embodiments of the present application, there are at least the following problems or defects in the prior art: the existing CAN data transmission technology cannot dynamically adapt to the change of bus load, and lacks effective data compression mechanism to optimize data transmission efficiency; traditional data compression methods have high computational complexity and are not suitable for CAN network environment with high real-time requirements, and the compression effect is not ideal, which cannot meet the growing demand for data transmission. SUMMARY
[0005] The present application provides an adaptive data compression method and system for controller area network.
[0006] In a first aspect of the present application, an adaptive data compression method for controller area network is provided, comprising:
[0007] monitoring the real-time bus load rate of the CAN bus;
[0008] when the real-time bus load rate continuously exceeds the first preset threshold, entering compression mode;
[0009] in compression mode, performing fluctuation analysis on at least one target data signal;
[0010] According to the result of the fluctuation analysis, a corresponding compression encoding mode is selected for the target data signal;
[0011] The target data signal is compressed based on the selected compression encoding mode;
[0012] The net benefit after compression is calculated, and it is determined whether to send the compressed message according to the net benefit;
[0013] If it is determined to send the compressed message, the message containing the compressed data is packaged and sent;
[0014] If it is determined not to send the compressed message, the message containing the original data is sent;
[0015] The receiving end receives the message and parses the message to reconstruct the data;
[0016] When the virtual uncompressed load rate continues to be lower than the second preset threshold, the compression mode is exited.
[0017] Further, the step of monitoring the real-time bus load rate of the CAN bus comprises:
[0018] The total sum of bits actually transmitted by all CAN frames within a unit time window is calculated;
[0019] According to the total sum of bits and the nominal propagation rate of the CAN bus, the real-time bus load rate is calculated, and the calculation formula is as follows:
[0020]
[0021] Where ∑FrameBits represents the total sum of bits actually transmitted by all CAN frames within a time window, BitRate represents the nominal propagation rate of the CAN bus, TimeWindow represents the time window for load rate calculation, L real represents the real-time bus load rate.
[0022] Further, the step of analyzing the fluctuation of at least one target data signal comprises:
[0023] The difference between the current sampling value and the previous sampling value is calculated;
[0024] The difference is stored in a sliding window difference buffer with a size of M;
[0025] According to the comparison result of the data in the sliding window difference buffer and at least one preset threshold, the fluctuation state of the target data signal is determined.
[0026] Further, the preset threshold includes a stable threshold and an overflow threshold, and the stable threshold and the overflow threshold are determined according to the percentage of the full-scale range of the target data signal.
[0027] Furthermore, the step of determining the fluctuation state includes:
[0028] If the absolute value of all differences within the sliding window is less than the stationarity threshold, then the state is considered stationary.
[0029] If the absolute value of any difference within the sliding window is greater than or equal to the overflow threshold, it is determined to be a state of violent fluctuation.
[0030] Otherwise, it is judged as a normal fluctuation state.
[0031] Furthermore, the compression encoding mode includes:
[0032] The first compression mode, used in a steady state, compresses the difference to the first target bit width;
[0033] The second compression mode is used in normal fluctuation conditions to compress the difference to the second target bit width.
[0034] The third compression mode is used in situations of violent fluctuations. It sends the original absolute value, with the first target bit width being one-quarter of the original bit width and the second target bit width being one-half of the original bit width.
[0035] Furthermore, it also includes:
[0036] When the target data signal is in a state of violent fluctuation, send a calibration message containing the complete absolute value of the data signal;
[0037] Periodically send calibration messages containing the complete absolute value of the target data signal;
[0038] After receiving the calibration message, the receiving end updates its reference value using the complete absolute value in the message.
[0039] Furthermore, the step of calculating the compressed net profit includes:
[0040] The total number of bits saved after compression is calculated using the following formula:
[0041] Saving bits =Bytes original ×8-(8+Bits compressed )
[0042] Among them, Saving bits This represents the total number of bits saved after compression, in bytes. original Bits represents the length of the original data (in bytes). compressed This represents the total length of the compactly arranged bits after compression;
[0043] If the total number of bits saved is greater than zero, then the compressed message will be sent.
[0044] Otherwise, it decides to send a message containing the raw data.
[0045] Furthermore, the step of parsing the message to reconstruct the data includes:
[0046] Read the DLC field of the message;
[0047] The DLC is compared with a predefined original data length;
[0048] If the DLC is equal to the original data length, then the data is parsed in the original format;
[0049] If the DLC is less than the original data length, the message is identified as containing a bitmap descriptor and compressed data, and the compressed data is decompressed according to the instructions of the bitmap descriptor.
[0050] In a second aspect of the invention, an adaptive data compression system for a controller local area network is provided, comprising:
[0051] The bus load monitoring module is used to monitor the real-time bus load rate of the CAN bus.
[0052] The mode control module is used to control the entry into compression mode when the real-time bus load rate continuously exceeds a first preset threshold, and to control the exit from compression mode when the virtual uncompressed load rate continuously falls below a second preset threshold.
[0053] The signal analysis module is used to perform wave analysis on at least one target data signal in compressed mode;
[0054] The compression mode selection module is used to select a corresponding compression coding mode for the target data signal based on the results of the volatility analysis.
[0055] A data compression module is used to compress the target data signal based on the selected compression encoding mode;
[0056] The revenue decision module is used to calculate the net revenue after compression and decide whether to send the compressed message based on the net revenue.
[0057] The message encapsulation and sending module is used to encapsulate and send a message containing compressed data when it is decided to send a compressed message, and to send a message containing the original data when it is decided not to send a compressed message.
[0058] The data receiving and parsing module is used to receive messages and parse the messages to reconstruct the data.
[0059] The embodiments of the present invention have at least the following beneficial effects:
[0060] 1. By monitoring the real-time bus load rate of the CAN bus and dynamically entering or exiting the compression mode according to the load, the problem of increased data transmission delay and reduced communication efficiency of the CAN bus under high load in the existing technology is effectively solved, thereby improving the real-time performance and reliability of the system and ensuring good communication performance under different load conditions.
[0061] 2. By performing fluctuation analysis on the target data signal and selecting the corresponding compression encoding mode based on its fluctuation state, the shortcomings of traditional data compression methods, such as high computational complexity, limited compression effect, and unsuitability for CAN network environments with high real-time requirements, are overcome. This achieves efficient data compression while ensuring data integrity and optimizes data transmission efficiency.
[0062] 3. The system sends calibration messages during periods of severe fluctuation and updates the baseline value at the receiving end based on the calibration messages, solving the problem of difficulty in accurately reconstructing data when data signals fluctuate drastically in existing technologies. This further improves the accuracy and stability of data transmission and enhances the system's anti-interference capability and adaptability. Attached Figure Description
[0063] The above and other objects, features, and advantages of exemplary embodiments of the present invention will become readily apparent from the following detailed description taken in conjunction with the accompanying drawings. Several embodiments of the invention are illustrated in the drawings by way of example, not limitation, in which:
[0064] Figure 1 This is a flowchart illustrating an adaptive data compression method for a controller area network according to an embodiment of the present invention.
[0065] Figure 2 This is a flowchart of signal level analysis and compression coding provided in an embodiment of the present invention;
[0066] Figure 3 This is a schematic diagram of dual calibration provided in an embodiment of the present invention;
[0067] Figure 4 This is a schematic diagram of the message data field structure before and after compression according to an embodiment of the present invention;
[0068] Figure 5 This is a flowchart of data decompression provided in an embodiment of the present invention;
[0069] Figure 6 This is a schematic diagram of the structure of an adaptive data compression system for a controller area network provided in an embodiment of the present invention. Detailed Implementation
[0070] The technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. The components of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application. It should be noted that similar reference numerals and letters in the following drawings indicate similar items; therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. Furthermore, in the description of this application, the terms "first," "second," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0071] In traditional controller area network (CAN) communication architectures, the dynamic adjustment mechanism for bus load and signal compression strategies have inherent flaws. Due to the lack of continuous monitoring and feedback mechanisms for real-time bus load, the system cannot autonomously trigger compression operations when multiple nodes concurrently transmit high-frequency data, resulting in inefficient use of physical layer bandwidth resources. Existing signal processing schemes employ static compression coding strategies, failing to consider the time-varying characteristics of signal fluctuations. This leads to redundant coding during stable signal periods, but may introduce data truncation errors during periods of signal abrupt change.
[0072] For example, in an automotive electronic control unit cluster, when the engine control module, vehicle stability system, and autonomous driving sensors transmit data synchronously, periodic status signals and sudden event signals coexist on the bus. Engine speed signals exhibit low fluctuation characteristics, with the difference between adjacent sampled values often less than 5% of full scale, yet existing systems still transmit raw data with a fixed bit width. The wheel speed signals of the anti-lock braking system experience step changes exceeding 15% of full scale during emergency braking, at which point traditional compression algorithms suffer from insufficient preset bit width, leading to critical data loss. In this mixed signal scenario, the bus load rate can jump from 40% to 95% within a millisecond timescale, but the system lacks the ability to dynamically adjust its transmission strategy.
[0073] If these issues are not addressed, the system will face a chain reaction of unbalanced bus resource allocation. High-priority control commands will experience transmission delays due to channel congestion, directly impacting vehicle braking response time and steering control accuracy. Signal reconstruction errors will accumulate continuously in the closed-loop control system, potentially causing the electronic stability program to misjudge vehicle attitude. More seriously, in autonomous driving mode, the deterioration of the synchronization of multi-sensor data streams will directly affect the reliability of environmental perception algorithms, threatening driving safety.
[0074] To address the aforementioned challenges, this application first considers establishing a dynamic sensing mechanism for bus load, achieving quantitative assessment of load status by continuously monitoring the amount of data transmitted at the physical layer. To address the differences in signal fluctuation characteristics, this application analyzes the time-domain variation patterns of different data sources and establishes a sliding window-based difference statistical model. To resolve the conflict between encoding efficiency and data integrity, this application designs a multi-mode compression strategy that automatically switches the encoding bit width based on the dynamic characteristics of the signal. For the compression decision mechanism, this application introduces a benefit evaluation model, determining whether to perform compressed transmission by calculating bit savings, thus avoiding unnecessary compression operations that consume computational resources. Through the synergistic effect of the above technical elements, a closed-loop optimized data transmission system is formed.
[0075] like Figure 1 As shown, this application proposes an adaptive data compression method for a Controller Area Network (CAN), comprising: monitoring the real-time bus load rate of the CAN bus; entering a compression mode when the real-time bus load rate continuously exceeds a first preset threshold; performing fluctuation analysis on at least one target data signal in the compression mode; selecting a corresponding compression encoding mode for the target data signal based on the result of the fluctuation analysis; compressing the target data signal based on the selected compression encoding mode; calculating the net gain after compression and deciding whether to send the compressed message based on the net gain; if deciding to send the compressed message, encapsulating and sending a message containing compressed data; if deciding not to send the compressed message, sending a message containing the original data; receiving the message and parsing the message to reconstruct the data; exiting the compression mode when the virtual uncompressed load rate continuously falls below a second preset threshold.
[0076] The monitoring of the real-time bus load rate of the CAN bus refers to the percentage of data transmission volume within a specific time window relative to the nominal propagation rate. This can be achieved by calculating the total number of bits actually transmitted in all CAN frames within a unit time window and then dividing by the product of the nominal propagation rate and the time window. This feature dynamically senses the bus load status, providing a basis for determining whether to enable compression. The compression mode refers to the data transmission optimization state triggered when the real-time bus load rate exceeds a preset threshold. This can be implemented by setting a bus load rate threshold comparator. This feature actively initiates the compression mechanism when the bus load is too high, avoiding communication delays or data loss. The volatility analysis refers to the statistical evaluation of the variation amplitude of adjacent sample values of the target data signal. This can be achieved by calculating the difference between the current sample value and the previous sample value and statistically analyzing the difference range based on a sliding window. This feature identifies the dynamic characteristics of the data signal, providing a basis for selecting the optimal compression coding mode. The compression coding mode refers to using different bit width compression strategies based on differences in data volatility. This can be implemented by preset bit width compression rules corresponding to stable states, normal volatility states, and severe volatility states. This feature balances data accuracy and compression efficiency through a differentiated compression strategy. The net benefit after compression refers to the difference between the number of bits saved and the compression processing overhead, specifically calculated by subtracting the difference between the original data bit length and the compressed data bit length and encapsulation overhead. This feature quantifies the actual benefits of compression, avoiding unnecessary resource consumption due to ineffective compression. The virtual uncompressed load rate refers to the bus load rate assuming all compressed packets are sent at the original data level, specifically calculated by the ratio of the original data length of the compressed packet to the time window. This feature evaluates the overall effectiveness of the compression mechanism, ensuring that the bus load remains within a safe range after exiting compression mode.
[0077] The core innovation of this application lies in triggering a dynamic compression mechanism by real-time monitoring of bus load, selecting the optimal compression encoding mode by combining data signal fluctuation analysis, and deciding whether to send compressed messages based on the net compression benefit, thereby achieving adaptive load rate control while ensuring real-time communication.
[0078] The working process and principle of this application are as follows: First, the network congestion status is assessed by monitoring the real-time bus load rate of the CAN bus. When the real-time bus load rate continuously exceeds a preset first threshold, the system enters compression mode and begins processing the target data signal. In compression mode, fluctuation analysis is performed on the selected target data signal to determine its variation characteristics. Based on the results of the fluctuation analysis, an appropriate compression encoding mode is selected for each target data signal. This dynamic selection mechanism of compression mode can adjust the compression strategy according to the real-time characteristics of the signal, thereby improving compression efficiency.
[0079] After selecting a compression encoding mode, the system compresses the target data signal. After compression, the net gain is calculated, i.e., the data volume before and after compression is compared to determine whether to send the compressed message. This step ensures that the compression operation truly reduces data transmission volume and avoids ineffective compression operations. If the net gain after compression is positive, a message containing compressed data is encapsulated and sent; otherwise, a message containing the original data is sent.
[0080] After receiving a message, the receiving end performs appropriate parsing and data reconstruction, either compressed or uncompressed, depending on the message type. This flexible receiving mechanism ensures the correct interpretation and reconstruction of the data.
[0081] The system also continuously monitors the virtual uncompressed load rate. When this load rate remains below a second preset threshold, it exits compression mode and resumes normal data transmission. This adaptive mechanism can adjust the transmission strategy promptly when the network load returns to normal, avoiding unnecessary compression operations.
[0082] Through this mechanism of dynamic monitoring, adaptive compression, and intelligent decision-making, this application optimizes CAN bus data transmission and can maintain efficient network operation under high load conditions.
[0083] As a preferred embodiment, the solution of this application is specifically implemented as follows:
[0084] In a typical automotive CAN network, the CAN bus load rate is monitored in real time. The load rate is calculated based on the ratio of the number of valid data bits transmitted per unit time to the bus's theoretical maximum transmission capacity. For example, for a 500kbps CAN bus, the load rate is calculated every 100 milliseconds.
[0085] When the load rate is detected to exceed 80% for five consecutive sampling cycles, the system enters compression mode. In compression mode, engine speed, vehicle speed, and throttle opening are selected as target data signals for processing.
[0086] Perform volatility analysis on each target signal. Use a sliding window of 10 sampling points to calculate the difference between adjacent sample values. If the absolute value of the difference is less than 2% of the full scale of the signal, it is considered a stable state; if the absolute value of the difference is greater than 10% of the full scale, it is considered a state of violent fluctuation; otherwise, it is considered a state of normal fluctuation.
[0087] The compression coding mode is selected based on the fluctuation state. For a stable state, differential coding is used and the difference is compressed to 1 / 4 of the original bit width; for a normal fluctuation state, the difference is compressed to 1 / 2 of the original bit width; for a violent fluctuation state, the original absolute value is sent.
[0088] After compression, the number of bits saved is calculated. If the number of bits saved is greater than zero, the compressed data is encapsulated in a CAN message and sent; otherwise, the original data message is sent.
[0089] The receiving end determines whether the data is compressed based on the Data Length (DLC) field of the message. If the DLC is less than the original data length, it is processed as compressed data; otherwise, it is processed as original data. For compressed data, decompression and data reconstruction are performed according to a pre-agreed compression mode.
[0090] The system continuously calculates the virtual uncompressed load rate, which is the load rate assuming all data is transmitted in an uncompressed manner. When this virtual load rate is below 70% for 10 consecutive sampling periods, the system exits compression mode and resumes normal transmission.
[0091] This application further proposes steps for monitoring the real-time bus load rate of the CAN bus, including: calculating the total number of bits actually transmitted in all CAN frames within a unit time window; and calculating the real-time bus load rate based on the total number of bits and the nominal propagation rate of the CAN bus, as shown in the following formula:
[0092]
[0093] Where ∑FrameBits represents the total number of bits actually transmitted in all CAN frames within the time window, ∑FrameBits represents the nominal propagation rate of the CAN bus, TimeWindow represents the time window for load rate calculation, and L real This indicates the real-time bus load rate.
[0094] The length of the time window is set according to the system's real-time requirements, for example, in the range of 100 to 500 milliseconds. The total number of bits is obtained by accumulating the actual number of transmitted bits for the identifier, data field, and padding bits of all CAN frames within the time window. The nominal propagation rate is directly read from the CAN controller configuration parameters, such as 500 kbps or 1 Mbps. The denominator in the formula is the theoretical maximum transmission capacity of the bus within that time window, obtained by multiplying the nominal propagation rate by the time window. The ratio of the numerator to the denominator reflects the actual load percentage.
[0095] Specifically, the setting of the unit time window needs to balance computation frequency and resource consumption. A shorter window can respond to load changes faster, but it will increase computational overhead. The calculation of the total bit sum covers the complete CAN frame structure, avoiding errors caused by ignoring padding bits or identifiers. The nominal propagation rate is used as a fixed parameter to ensure the consistency of the calculation benchmark. By comparing the actual transmitted bits with the theoretical capacity, the real-time load rate is quantified as a percentage, making it easy to compare with preset thresholds. For example, when the time window is 200 milliseconds and the nominal rate is 500kbps, the theoretical capacity is 500,000bit / s × 0.2s = 100,000 bits. If the actual total transmitted bits is 85,000 bits, the real-time load rate is calculated as 85%. This calculation method eliminates the deviations caused by ignoring frame structure details or using estimated values in traditional methods, providing an accurate basis for mode switching.
[0096] As a preferred embodiment, the solution of this application is specifically implemented as follows:
[0097] Monitoring the real-time bus load rate of the CAN bus includes the following steps:
[0098] First, calculate the total number of bits actually transmitted in all CAN frames within a unit time window. Specifically, select a fixed time window, such as 100 milliseconds. Within this time window, count the number of bits in all transmitted CAN frames. The number of bits in each CAN frame includes the start-of-frame bit, arbitration segment, control segment, data segment, CRC segment, ACK segment, and end-of-frame bit.
[0099] Secondly, based on the calculated total bit count and the nominal propagation rate of the CAN bus, the real-time bus load rate is calculated. The calculation formula is:
[0100]
[0101] Where ΣFrameBits represents the total number of bits actually transmitted in all CAN frames within the time window, BitRate represents the nominal propagation rate of the CAN bus, TimeWindow represents the time window for load rate calculation, and L_real represents the real-time bus load rate.
[0102] For example, assuming that the total number of CAN frame bits counted within a 100-millisecond time window is 40,000 bits, and the nominal propagation rate of the CAN bus is 500kbps, the real-time bus load rate is calculated as follows:
[0103] L real = (40000 / (500000×0.1))×100
[0104] In this way, the load on the CAN bus can be monitored in real time, providing a basis for decision-making in subsequent adaptive data compression.
[0105] like Figure 2 As shown, this application further proposes a step for performing volatility analysis on at least one target data signal, including: calculating the difference between the current sampled value and the previous sampled value; storing the difference in a sliding window difference buffer of size M; and determining the volatility state of the target data signal based on the comparison result between the data in the sliding window difference buffer and at least one preset threshold.
[0106] The sliding window difference buffer has a capacity M set to an integer between 8 and 16 to store the differences from the most recent sampling. Preset thresholds include two fixed values, corresponding to 5% and 20% of the full-scale range of the data signal, respectively. The current sampling difference is calculated using signed integer subtraction, and the result overwrites the oldest historical difference when stored in the buffer. The logic for judging fluctuation states is based on the statistical characteristics of all differences within the sliding window, rather than the result of a single sampling.
[0107] Specifically, when the absolute value of all differences within the sliding window is less than 5% of the full scale, it indicates that the data signal is in a stable state. In this case, high-bit-width compression may cause redundancy. When the absolute value of any difference exceeds 20% of the full scale, it indicates a sudden change, requiring the complete transmission of the original data. Other cases are considered normal fluctuations. By setting a sliding window with a fixed capacity, historical data can be stored in a rolling manner with limited memory resources, avoiding the need for infinitely growing data buffers. For example, when M is set to 12, the system only needs to maintain a circular queue containing 12 differences, automatically discarding the oldest record each time a new difference enters. This design ensures both the timeliness of fluctuation analysis and controls computational complexity, making it suitable for CAN bus environments with high real-time requirements.
[0108] As a preferred embodiment, the solution of this application is specifically implemented as follows:
[0109] The volatility analysis of the target data signal includes the following steps:
[0110] Calculate the difference between the current sample value and the previous sample value. For example, if the current sample value is 1024 and the previous sample value is 1020, the calculated difference is 4.
[0111] The differences are stored in a sliding window difference buffer of size M. Specifically, a circular array of length 10 can be set as the sliding window difference buffer. After each new difference is calculated, it is stored in the oldest position in the array to achieve a first-in, first-out sliding window effect.
[0112] The fluctuation state of the target data signal is determined by comparing the data in the sliding window difference buffer with preset thresholds. Further, two preset thresholds can be set: a stability threshold and an overflow threshold. The stability threshold can be set to 5, and the overflow threshold can be set to 20. All differences in the sliding window difference buffer are iterated through, and the absolute value of each difference is compared with these two thresholds to determine the fluctuation state of the target data signal.
[0113] This application further proposes preset thresholds including a stability threshold and an overflow threshold, which are determined based on a percentage of the full-scale range of the target data signal.
[0114] The full-scale range refers to the difference between the maximum and minimum values of the target data signal within its physical range. The stabilization threshold is set to 1%-5% of the full-scale range, and the overflow threshold is set to 15%-20% of the full-scale range. The capacity M of the sliding window difference buffer is set according to the signal sampling period, typically ranging from 8 to 16 sampling points. The threshold percentage parameter is implemented through offline calibration or online adaptive adjustment, with independent configuration tables established for different signal types.
[0115] Specifically, taking an engine speed signal as an example, its full-scale range is 0-8000 rpm. A stability threshold is set to 2% of the full scale, i.e., 160 rpm, and an overflow threshold is set to 20%, i.e., 1600 rpm. When all speed differences within the sliding window are less than 160 rpm, a stable state is determined, triggering the first compression mode; if any difference exceeds 1600 rpm, a severe fluctuation is determined, triggering the third compression mode. This threshold determination method directly correlates the judgment standard with the actual physical magnitude of the signal, avoiding the problem of poor adaptability of fixed thresholds to signals with different ranges. Through percentage parameter configuration, the range specifications of different sensors can be quickly adapted, ensuring the consistency of the physical meaning of fluctuation state classification.
[0116] As a preferred embodiment, the solution of this application is implemented as follows: The preset thresholds include a stability threshold and an overflow threshold, which are determined based on a percentage of the full-scale range of the target data signal. For example, for a temperature sensor signal with a full-scale range of 0-100, the stability threshold can be set to 1% of the full-scale range, i.e., 1℃, and the overflow threshold can be set to 10% of the full-scale range, i.e., 10℃. This means that if the difference between consecutive sampled values is less than 1℃, the signal is considered to be in a stable state; if the difference is greater than or equal to 10℃, the signal is considered to be in a state of violent fluctuation. Furthermore, these thresholds can be adjusted according to specific application scenarios to adapt to different types of data signals and system requirements.
[0117] This application further proposes a step for determining the fluctuation state, including: if the absolute value of all differences within the sliding window is less than the stability threshold, it is determined to be a stable state; if the absolute value of any difference within the sliding window is greater than or equal to the overflow threshold, it is determined to be a violent fluctuation state; otherwise, it is determined to be a normal fluctuation state.
[0118] The sliding window difference buffer has a fixed capacity of M, used to store the difference data over M consecutive sampling periods. The stability threshold and overflow threshold are set as percentages of the target data signal's full-scale range; for example, the stability threshold is set to 1% of full scale, and the overflow threshold is set to 10% of full scale. Difference calculation is performed by subtracting the current sample value from the previous sample value, and the result is stored as a signed integer. The fluctuation state determination logic employs a hierarchical judgment mechanism, prioritizing the detection of severe fluctuation states, followed by stable states, with the remaining cases categorized as normal fluctuation states.
[0119] Specifically, after the difference is stored in the sliding window buffer, the system iterates through all elements in the buffer sequentially. When the absolute value of any element exceeds the overflow threshold, a severe fluctuation state is immediately triggered, interrupting the subsequent judgment process. If the absolute values of all elements are below the stability threshold, a stable state is marked. For data fluctuations between the two thresholds, the system classifies them as normal fluctuation states. This hierarchical judgment mechanism effectively reduces computational complexity; for example, with M=8, a maximum of 8 comparisons are required to complete the state determination. By setting the overflow threshold as a hard boundary condition, sudden data jumps can be captured in a timely manner, preventing the compression algorithm from accumulating errors during severe fluctuations. At the same time, the stability threshold ensures that small fluctuations are not misjudged as valid fluctuations, maintaining the stability of the compression algorithm.
[0120] As a preferred embodiment, the solution of this application is specifically implemented as follows:
[0121] The steps for determining the fluctuation state include: if the absolute value of all differences within the sliding window is less than the stability threshold, it is determined to be a stable state; if the absolute value of any difference within the sliding window is greater than or equal to the overflow threshold, it is determined to be a violent fluctuation state; otherwise, it is determined to be a normal fluctuation state.
[0122] Specifically, in practical applications, the sliding window size can be set to 10 sampling points, the stability threshold to 1% of the full-scale range, and the overflow threshold to 10% of the full-scale range. For example, for a temperature sensor signal in the 0-100℃ range, the stability threshold can be set to 1℃, and the overflow threshold to 10℃. The system first calculates the temperature difference between adjacent sampling points and stores the 10 most recent differences in the sliding window difference buffer. Then, the system checks the differences in the buffer: if the absolute value of all differences is less than 1℃, the signal is determined to be in a stable state; if the absolute value of any difference is greater than or equal to 10℃, the signal is determined to be in a state of violent fluctuation; if neither the conditions for a stable state nor the conditions for a state of violent fluctuation are met, the signal is determined to be in a state of normal fluctuation.
[0123] This application further proposes a compression coding mode including: a first compression mode for a stable state, which compresses the difference to a first target bit width; a second compression mode for a normal fluctuation state, which compresses the difference to a second target bit width; and a third compression mode for a violent fluctuation state, which sends the original absolute value, with the first target bit width being one-quarter of the original bit width and the second target bit width being one-half of the original bit width.
[0124] The first compression mode compresses the difference to one-quarter of the original bit width, suitable for stable conditions with minimal data fluctuations, achieving the maximum compression ratio. The second compression mode uses half the original bit width, covering scenarios with normal fluctuations, balancing compression ratio and data accuracy. The third compression mode directly sends the original absolute value during periods of severe fluctuation, avoiding decoding errors caused by difference overflow. These three modes form a dynamic compression strategy through tiered bit width configuration.
[0125] Specifically, when volatility analysis determines a stable state, the absolute value of the difference is limited to 25% of full scale, and compression is performed using a first target bit width, requiring only a quarter of the original bit width for each difference. Under normal volatility conditions, the difference range expands to 50% of full scale, and the difference is stored using a second target bit width, achieving a balance between compression ratio and data coverage. Under severe volatility conditions, if the difference exceeds a preset threshold, the original absolute value is sent directly to ensure data integrity. By matching the volatility state with the compressed bit width, bus load is reduced while avoiding data distortion caused by insufficient compressed bit width.
[0126] As a preferred embodiment, the solution of this application is specifically implemented as follows:
[0127] The compression coding modes include: a first compression mode for a stable state, which compresses the difference to a first target bit width; a second compression mode for a normal fluctuating state, which compresses the difference to a second target bit width; and a third compression mode for a violently fluctuating state, which sends the original absolute value, with the first target bit width being one-quarter of the original bit width and the second target bit width being one-half of the original bit width.
[0128] Specifically, in practical applications, an appropriate compression encoding mode can be selected based on the fluctuation state of the target data signal. For example, for 16-bit temperature sensor data, when the temperature changes slowly, the first compression mode is used to compress the difference to 4 bits, one-quarter of 16 bits; when the temperature changes rapidly but not drastically, the second compression mode is used to compress the difference to 8 bits, half of 16 bits; when the temperature suddenly changes drastically, the third compression mode is used to directly send the original 16-bit absolute value.
[0129] like Figure 3 As shown, this application further proposes that when the target data signal is in a state of violent fluctuation, a calibration message containing the complete absolute value of the data signal is sent; a calibration message containing the complete absolute value of the target data signal is sent periodically; and the receiving end updates its reference value using the complete absolute value in the message after receiving the calibration message.
[0130] The transmission of calibration messages is triggered by severe fluctuations, specifically by determining if the absolute value of any difference within the sliding window difference buffer exceeds an overflow threshold. The calibration message contains uncompressed, complete absolute value data fields, with the same format as the original data message. The time interval for periodically transmitting calibration messages is dynamically adjusted based on the update frequency of the target data signal, for example, set to a fixed period of 100ms or synchronized with the signal sampling period. The receiving end maintains a reference value register for each target data signal. Upon receiving a calibration message, it replaces the reference value in the register with the complete absolute value from the message; subsequent decompression is performed based on the updated reference value for difference restoration.
[0131] Specifically, when the target data signal enters a state of violent fluctuation, a calibration message carrying the complete absolute value of the current sampled value is immediately generated and sent, overwriting the original reference value at the receiving end and eliminating the accumulated error caused by continuous large differences. Simultaneously, calibration messages are generated every preset period to ensure that the receiver's reference value can still be synchronized periodically under normal fluctuation or stable conditions, avoiding drift caused by long-term transmission of differences. For example, for a 16-bit data signal, the calibration message directly transmits the 16-bit original value, rather than the compressed difference. After parsing the calibration message, the receiving end updates the reference register of the corresponding data channel with the absolute value in the message. Subsequent received compressed differences are accumulated and restored based on the new reference value, ensuring that the reconstructed data is consistent with the actual value at the sending end.
[0132] As a preferred embodiment, the solution of this application is specifically implemented as follows:
[0133] When the target data signal is in a state of violent fluctuation, a calibration message containing the complete absolute value of the data signal is sent. Furthermore, calibration messages containing the complete absolute value of the target data signal are sent periodically. Upon receiving the calibration message, the receiving end updates its reference value using the complete absolute value in the message.
[0134] Specifically, in a CAN network, a calibration message transmission period is set, for example, once every 100ms. The calibration message contains the complete absolute value of the target data signal, represented in 32-bit floating-point format. This allows the receiver to periodically update its internally maintained reference value, ensuring that long-term accumulated errors do not exceed acceptable limits.
[0135] For example, suppose the target data signal is engine speed. When a drastic change in engine speed is detected within a short period, a calibration message containing the complete absolute value of the current speed is immediately sent. Furthermore, regardless of whether the speed change is drastic, the system sends a calibration message containing the complete speed value every 100ms. Upon receiving these calibration messages, the receiving ECU immediately updates its internally stored reference value using the complete speed value from the message.
[0136] like Figure 4 As shown, this application further proposes a step for calculating the net benefit after compression, including: calculating the total number of bits saved after compression, as shown in the following formula:
[0137] Saving bits =Bytes original ×8-(8+Bits compressed )
[0138] If the total number of bits saved is greater than zero, then the compressed message will be sent; otherwise, the original data message will be sent.
[0139] Among them, Bytes original This indicates the length of the raw data, quantized in bytes to ensure that the computational basis is consistent with the byte alignment characteristics of the CAN frame data structure. Bits compressed This represents the total bit length after compression and compact arrangement, including differentially encoded data and necessary bitmap descriptors. A fixed value of 8 bits is introduced into the formula as the overhead for the compressed message header, used to store the compression mode identifier or bitmap information. This value matches the physical characteristics of the smallest unit of data in the CAN protocol—the byte. By logically comparing the saved bits with zero, the decision logic is transformed into a binary judgment, avoiding complex threshold settings and reducing computational resource consumption.
[0140] Specifically, when the original data length is 4 bytes, the original number of bits is 32 bits. If the compressed, compactly arranged data occupies 20 bits, and an 8-bit header is added, the total number of bits is 28 bits. According to the formula, the number of bits saved is 32 - 28 = 4 bits, which meets the condition for sending a compressed message. Conversely, if the compressed data occupies 28 bits, and the total number of bits after adding the header reaches 36 bits, the number of bits saved is -4 bits, and the original message is automatically selected for transmission. This calculation mechanism ensures that each compression operation is quantized and verified, avoiding invalid compression operations that consume bus resources. By accurately quantifying the compression benefits, compression efficiency and transmission overhead are effectively balanced, ensuring the objectivity and reliability of bus load optimization decisions.
[0141] As a preferred embodiment, the solution of this application is implemented as follows: During data compression, the original data is encapsulated into an 8-byte CAN frame. After compression using differential encoding, the compressed data is compactly arranged into 15 bits. The number of bits saved is calculated to be 8 × 8 - (8 + 15) = 41 bits. Since the number of bits saved is greater than zero, the compressed message is allowed to be sent. When the compressed data produces a negative saving value, for example, if the original data length is 2 bytes and the compressed data is compactly arranged into 20 bits, the number of bits saved is 2 × 8 - (8 + 20) = -12 bits, and the original data message is sent directly.
[0142] This application further proposes calculating the net gain after compression and deciding whether to send the compressed message based on the net gain. The steps for calculating the net gain after compression include: calculating the total number of bits saved after compression, as shown in the following formula:
[0143] Saving bits =Bytes original ×8-(8+Bits compressed )
[0144] Among them, Saving bits This represents the total number of bits saved after compression, in bytes. original Indicates the length of the original data, in bytes (Bits). compressed This indicates the total length of the compressed, compactly arranged bits. If the total number of bits saved is greater than zero, the compressed message is sent; otherwise, the original data message is sent.
[0145] The calculation formula quantifies the actual benefits of compression by comparing the total number of bits in the original data with the total number of bits in the compressed data plus additional overhead. The total number of bits in the original data is converted to bits by multiplying the number of bytes by eight. The total number of bits in the compressed data includes the length of the compactly arranged bits and the fixed eight-bit header overhead. By comparing the difference between the two, it is determined whether the compression effectively reduces the amount of data transmitted.
[0146] Specifically, when the original data length is four bytes, the original total number of bits is thirty-two bits. If the compressed, compactly arranged bits are twenty bits, and an eight-bit header is added, the total number of bits is twenty-eight bits, saving a total of four bits. In this case, the net gain is positive, and the compressed message is sent. If the compressed, compactly arranged bits are twenty-eight bits, and a header is added, the total number of bits is thirty-six bits, saving a total of negative four bits, and the original data is sent. This calculation method ensures that compression is only enabled when effectively reducing the amount of data transmitted, avoiding further increases in bus load due to ineffective compression.
[0147] like Figure 5 As shown in the figure, as a preferred embodiment, the specific implementation of the solution in this application is as follows: When the receiving end receives a message, it first reads the data length code field. The data length code is compared with the predefined original data length value in binary. If the data length code is equal to the original data length value, the data field is directly parsed according to the standard CAN data frame format to obtain the original data signal value. If the data length code is less than the original data length value, a bitmap descriptor is extracted starting from the first byte of the message data field. This bitmap descriptor uses binary bits to identify whether each data signal is compressed. According to the indication of the bitmap descriptor, the subsequent compressed data segments are split by bit operations. The split compressed data blocks are then subjected to difference restoration operation according to the predefined compression encoding rules to finally reconstruct the complete original data signal sequence.
[0148] like Figure 6 As shown, this application further proposes an adaptive data compression system for a controller area network, including a bus load monitoring module, a mode control module, a signal analysis module, a compression mode selection module, a data compression module, a benefit decision module, a message encapsulation and transmission module, and a data reception and parsing module.
[0149] The system includes several modules: a bus load monitoring module to obtain the real-time load rate by calculating the ratio of the total number of bits transmitted within a unit time window to the nominal propagation rate; a mode control module with a dual-threshold trigger mechanism to activate compression mode when the real-time load rate is consistently higher than the first threshold and deactivate compression mode when the virtual uncompressed load rate is consistently lower than the second threshold; a signal analysis module with a sliding window difference buffer to determine signal fluctuation status by comparing the absolute value of the difference with a preset threshold; a compression mode selection module with a mapping relationship between three encoding modes: a stable state corresponds to quarter-bit width compression, normal fluctuations correspond to half-bit width compression, and severe fluctuations switch to original value transmission; a data compression module using bitmap descriptors to mark compressed data segments and compactly arrange the compressed data; a benefit decision module to determine whether to enable compression by calculating the difference between the original number of bytes and the number of bits after compression; a message encapsulation and sending module to select compressed or original message format based on the decision result; and a data receiving and parsing module to distinguish message types by recognizing differences in the DLC field and perform corresponding decompression operations.
[0150] Specifically, the bus load monitoring module periodically collects the amount of data transmitted on the bus, and the mode control module dynamically switches its operating state according to changes in the load rate. When entering compression mode, the signal analysis module performs sliding window difference analysis on the target signal, and the compression mode selection module matches the optimal compression bit width based on the fluctuation state. The data compression module generates compressed data blocks containing bitmap descriptors, and the benefit decision module determines the effectiveness of compression by calculating the number of bits saved. If the number of bits saved by compression is positive, the message encapsulation and transmission module encapsulates the compressed data into a DLC-shortened message frame; otherwise, it sends the original data frame. The receiving end identifies the message type by parsing the DLC field. When a compressed message is detected, it restores the data bit width based on the bitmap descriptor. In the case of severe fluctuations, it receives calibration messages to update the baseline value. Each module achieves closed-loop control through the data interface, and the mode control module synchronously adjusts the compression mode activation state to ensure that the bus load rate is maintained within a safe threshold range.
[0151] As a preferred embodiment, the solution of this application is implemented as follows: An adaptive data compression system for a controller area network includes a bus load monitoring module, a mode control module, a signal analysis module, a compression mode selection module, a data compression module, a benefit decision module, a message encapsulation and transmission module, and a data reception and parsing module. The bus load monitoring module generates a real-time bus load rate by calculating the ratio of the total number of bits actually transmitted in all CAN frames within a unit time window to the nominal propagation rate. The mode control module triggers a compression mode when the real-time bus load rate continuously exceeds a preset threshold, and disables the compression mode when the virtual uncompressed load rate continuously falls below another preset threshold. The signal analysis module performs fluctuation analysis on the target data signal, specifically storing the difference between the current sampled value and historical values through a sliding window difference buffer, and determining the signal fluctuation state based on the comparison result of the difference with a preset threshold. The compression mode selection module selects the corresponding compression encoding mode based on the fluctuation state, including a first compression mode for a stable state, a second compression mode for a normal fluctuation state, and a third compression mode for a violent fluctuation state. The data compression module performs bit-width compression or full absolute value transmission on the target data signal according to the selected mode. The benefit decision module calculates the total number of bits saved after compression to determine whether to send a compressed message. If the saved bits are greater than zero, a compressed message is sent; otherwise, the original message is sent. The message encapsulation and sending module encapsulates and sends the message based on the decision result. The compressed message includes a bitmap descriptor to indicate the distribution of compressed data. The data receiving and parsing module identifies the message's DLC field to determine if it contains compressed data. If it is a compressed message, it decompresses and reconstructs it based on the bitmap descriptor; if it is an original message, it is parsed directly. When a drastic fluctuation is detected, the system sends a calibration message containing complete absolute values to update the receiver's reference value, ensuring the accuracy of data reconstruction.
[0152] Through the above technical solutions, this application achieves dynamic sensing and adaptive compression adjustment of the CAN bus load. By matching the optimal compression strategy through volatility analysis, it reduces the bus load rate while avoiding a decrease in communication reliability caused by compression. The system ensures the net benefit of compression operations through a benefit-decision mechanism, effectively reducing resource waste caused by ineffective compression. Calibration messages and baseline update mechanisms ensure data integrity under drastic fluctuations, avoiding the impact of accumulated errors on the system. Modular design enables the system to respond to bus load changes in real time without increasing additional computational burden, improving communication efficiency and stability.
[0153] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.
Claims
1. An adaptive data compression method for Controller Area Networks (CAN), characterized in that, Includes the following steps: Monitor the real-time bus load rate of the CAN bus; When the real-time bus load rate continuously exceeds the first preset threshold, it enters compression mode; In compression mode, fluctuation analysis is performed on at least one target data signal; Based on the results of the volatility analysis, a corresponding compression coding mode is selected for the target data signal; The target data signal is compressed based on the selected compression coding mode; Calculate the net benefit after compression, and decide whether to send the compressed message based on the net benefit; If it is decided to send a compressed message, then encapsulate and send a message containing the compressed data; If it is decided not to send the compressed message, then send the message containing the original data. The receiving end receives the message and parses the message to reconstruct the data; When the virtual uncompressed load rate remains below the second preset threshold, exit compression mode.
2. The method according to claim 1, characterized in that, The steps for monitoring the real-time bus load rate of the CAN bus include: Calculate the total number of bits actually transmitted in all CAN frames within a unit time window; The real-time bus load rate is calculated based on the total bit sum and the nominal propagation rate of the CAN bus, using the following formula: Where ∑FrameBits represents the total number of bits actually transmitted in all CAN frames within the time window, BitRate represents the nominal propagation rate of the CAN bus, TimeWindow represents the time window for load rate calculation, and L real This indicates the real-time bus load rate.
3. The method according to claim 1, characterized in that, The step of performing volatility analysis on at least one target data signal includes: Calculate the difference between the current sample value and the previous sample value; The difference is stored in a sliding window difference buffer of size M; The fluctuation state of the target data signal is determined based on the comparison result between the data in the sliding window difference buffer and at least one preset threshold.
4. The method according to claim 3, characterized in that, The preset threshold includes a stabilization threshold and an overflow threshold, which are determined based on a percentage of the full-scale range of the target data signal.
5. The method according to claim 3, characterized in that, The steps for determining the fluctuation state include: If the absolute value of all differences within the sliding window is less than the stationarity threshold, then the state is considered stationary. If the absolute value of any difference within the sliding window is greater than or equal to the overflow threshold, it is determined to be a state of violent fluctuation. Otherwise, it is judged as a normal fluctuation state.
6. The method according to claim 1, characterized in that, The compression encoding mode includes: The first compression mode, used in a steady state, compresses the difference to the first target bit width; The second compression mode is used in normal fluctuation conditions to compress the difference to the second target bit width. The third compression mode is used in situations of violent fluctuations. It sends the original absolute value, with the first target bit width being one-quarter of the original bit width and the second target bit width being one-half of the original bit width.
7. The method according to claim 1, characterized in that, Also includes: When the target data signal is in a state of violent fluctuation, send a calibration message containing the complete absolute value of the data signal; Periodically send calibration messages containing the complete absolute value of the target data signal; After receiving the calibration message, the receiving end updates its reference value using the complete absolute value in the message.
8. The method according to claim 1, characterized in that, The steps for calculating the compressed net profit include: The total number of bits saved after compression is calculated using the following formula: Saving bits =Bytes original ×8-(8+Bits compressed ) Among them, Saving bits This represents the total number of bits saved after compression, in bytes. original Bits represents the length of the original data (in bytes). compressed This represents the total length of the compactly arranged bits after compression; If the total number of bits saved is greater than zero, then the compressed message will be sent. Otherwise, it decides to send a message containing the raw data.
9. The method according to claim 1, characterized in that, The step of parsing the message to reconstruct the data includes: Read the DLC field of the message; The DLC is compared with a predefined original data length; If the DLC is equal to the original data length, then the data is parsed in the original format; If the DLC is less than the original data length, the message is identified as containing a bitmap descriptor and compressed data, and the compressed data is decompressed according to the instructions of the bitmap descriptor.
10. An adaptive data compression system for a Controller Area Network (CAN), characterized in that, include: The bus load monitoring module is used to monitor the real-time bus load rate of the CAN bus. The mode control module is used to control the entry into compression mode when the real-time bus load rate continuously exceeds a first preset threshold, and to control the exit from compression mode when the virtual uncompressed load rate continuously falls below a second preset threshold. The signal analysis module is used to perform wave analysis on at least one target data signal in compressed mode; The compression mode selection module is used to select a corresponding compression coding mode for the target data signal based on the results of the volatility analysis. A data compression module is used to compress the target data signal based on the selected compression encoding mode; The revenue decision module is used to calculate the net revenue after compression and decide whether to send the compressed message based on the net revenue. The message encapsulation and sending module is used to encapsulate and send a message containing compressed data when it is decided to send a compressed message, and to send a message containing the original data when it is decided not to send a compressed message. The data receiving and parsing module is used to receive messages and parse the messages to reconstruct the data.
Citation Information
Patent Citations
Scheduling method and device of concurrent service
CN104683060A
Complete vehicle CAN bus load rate calculation method
CN115664887A
Data compression method, device, electronic equipment and system
CN117318727A
Data transmission method, device and equipment and computer storage medium
CN119520631A
Power load high-frequency data compression and acquisition method based on edge adaptive mode matching
CN119602805A