A method, apparatus and electronic device for detecting vehicle fuel level
By using first-order low-pass filtering and trend-adaptive variable-step-size damping filtering, the filtering step size is dynamically adjusted, solving the detection error problem of traditional fuel gauges under bumpy and uphill/downhill conditions, and achieving accurate and rapid response of fuel level.
Patent Information
- Application Number
- CN202611545592.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-08
- Publication Date
- 2026-11-17
AI Technical Summary
Traditional fuel gauges have large detection errors under conditions such as vehicle bumps and uphill/downhill driving, and cannot accurately display the remaining fuel level.
A first-order low-pass filter combined with a trend-adaptive variable-step damping filter is used to dynamically adjust the filter step size according to the vehicle scenario, the direction of oil level change, and the number of consecutive changes, so as to suppress the sudden changes in liquid level and quickly respond to refueling or oil leakage conditions.
It improves the accuracy, stability, and real-time performance of fuel level display, and can suppress errors and respond quickly to refueling or fuel leaks under bumpy road conditions.
Smart Images

Figure CN123111410A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of vehicle fuel level detection and display technology, and more specifically, to a vehicle fuel level detection method, device, and electronic device. Background Technology
[0002] Traditional fuel gauges use a pointer-type structure, displaying the fuel level by pointing the pointer to the fuel gauge scale. Their circuits are purely analog circuit designs, usually without an MCU (Microcontroller Unit) chip. They generally consist of two sets of electromagnetic coils and a pointer with a permanent magnet, and the pointer moves between E and F by using changes in the strength of the magnetic field.
[0003] Traditional fuel gauges typically rely on sensors inside the fuel tank to collect fuel level signals, which are then used by a pointer with a permanent magnet driven by a magnetic field generated by an electromagnetic coil. However, the sensors inside the fuel tank are easily affected by vehicle bumps, inclines, and declines, leading to excessive detection errors. As a result, the pointer display does not match the actual fuel level, making it impossible to accurately determine the exact number of liters of fuel remaining in the tank. Summary of the Invention
[0004] In view of this, the purpose of this application is to provide a vehicle fuel level detection method, device, electronic device and computer-readable storage medium, which aims to solve the problem in the prior art that it is difficult to simultaneously ensure the smoothness and accuracy of the fuel level display under bumpy road conditions with a fixed filter coefficient.
[0005] In a first aspect, embodiments of this application provide a method for detecting the fuel level in a vehicle, including: In each control cycle, the instantaneous fuel quantity is obtained by acquiring the raw signal based on the liquid level sensor arranged in the fuel tank and performing a first-order low-pass filter on the raw signal. Obtain the current fuel level display value, calculate the difference between the instantaneous fuel level and the current fuel level display value, and determine the direction of fuel level change and the corresponding number of consecutive changes based on the difference; The current scenario of the vehicle is determined based on the current vehicle speed and current rotation speed. Based on the current scenario, the direction of fuel quantity change and the number of consecutive changes, the filter step size of the current control cycle is determined. The filter step size is used as the filter coefficient to perform variable step size damping filtering on the instantaneous fuel quantity to obtain the undetermined display value. The fuel consumption value is determined and displayed based on the current scenario and the pending display value.
[0006] In some possible embodiments, obtaining the instantaneous fuel quantity by acquiring the raw signal based on the liquid level sensor arranged in the fuel tank and performing a first-order low-pass filter on the raw signal includes: The raw ADC resistance value is acquired based on the liquid level sensor placed inside the fuel tank; When the first-order low-pass preprocessing enable switch is turned on, the original ADC resistance value is subjected to first-order low-pass preprocessing based on the preset integer ratio filter coefficient to obtain the instantaneous oil quantity.
[0007] In some possible embodiments, determining the current scenario of the vehicle based on the current vehicle speed and current rotational speed includes: When the current vehicle speed is greater than the first threshold, the current scenario is determined to be a driving scenario; When the current vehicle speed is not greater than the first threshold and the current rotation speed is not less than the second threshold, the current scenario is determined to be a parking idling scenario. When the current vehicle speed is not greater than the first threshold and the current rotation speed is less than the second threshold, the current scenario is determined to be a parking and engine-off scenario.
[0008] In some possible embodiments, the number of consecutive changes includes the number of consecutive upward changes and the number of consecutive downward changes. Determining the filter step size of the current control cycle based on the current scenario, the direction of oil quantity change, and the number of consecutive changes includes: When the current scenario is a driving scenario and the direction of fuel quantity change is upward, the filter step size is determined by multiplying the initial filter rate and the upward step size acceleration by the number of consecutive upward changes. When the current scenario is a driving scenario and the direction of fuel quantity change is downward, the filter step size is determined by multiplying the initial filter rate and the downward step size acceleration by the number of consecutive downward changes; When the current scenario is a parking idling scenario and the direction of fuel quantity change is downward, the preset parking idling fixed step size is used to determine the filtering step size; When the current scenario is a parking and engine shutdown scenario and the direction of fuel quantity change is upward, keep the current internal fuel display value unchanged, skip the variable step size damping filter of the current control cycle, and use the current internal fuel display value as the pending display value. The filtering step size is not greater than the preset upper limit of the filtering rate.
[0009] In some possible embodiments, after determining the filter step size of the current control cycle based on the current scenario, the direction of oil quantity change, and the number of consecutive changes, the method further includes: Determine whether the absolute value of the difference between the instantaneous fuel quantity and the current internal fuel display value is not greater than the filter step size of the current control cycle; If the absolute value is not greater than the filter step size of the current control cycle, then the instantaneous fuel quantity is used as the current internal fuel display value, and the variable step size damping filter of the current control cycle is skipped, and the instantaneous fuel quantity is used as the pending display value.
[0010] In some possible embodiments, determining and displaying the fuel consumption display value based on the current scenario and the pending display value includes: When the current scenario is the driving scenario and the direction of fuel quantity change is upward, the pending display value is used as the internal fuel display value, and the current external fuel display value is frozen. When the preset display conditions or thawing conditions are met, the pending display value is used as the internal display value of the fuel, and the pending display value is used as the current external display value of the fuel and displayed. The display conditions include the current scenario being a parking idling scenario or a parking and engine off scenario, or the current scenario being a driving scenario and the direction of fuel level change not being upward; the defrosting conditions include the direction of fuel level change being downward.
[0011] In some possible embodiments, the method further includes: In the scenarios of idling or turning off the engine, the instantaneous fuel quantity is sampled using a dual-cycle sliding window. The first cycle includes at least a preset first number of samples, and the difference between the maximum and minimum values in the samples is not greater than a preset difference. The second cycle includes at least a preset second number of samples, and the preset second number is greater than the preset first number. After removing extreme values from the samples within the sliding window with two cycles, the average value is calculated to obtain the steady-state reference value; Based on the difference between the current instantaneous oil level and the steady-state reference value, the preset refueling threshold, the preset oil leakage threshold, and the number of times the difference exceeds the corresponding threshold consecutively, it is determined whether to enter the corresponding fast response display mode; wherein, the fast response display mode includes a refueling fast response display mode and an oil leakage fast response display mode; When the corresponding fast-response display mode is entered, the fuel level is determined and displayed based on the instantaneous fuel level.
[0012] In some possible embodiments, when determining to enter the corresponding fast-response display mode, determining and displaying the fuel level based on the instantaneous fuel quantity includes: When the corresponding fast response display mode is entered, the instantaneous fuel quantity is approximated by a set fast step size to obtain the fast response display value; In the fast refueling display mode, the fast response display value is subjected to a one-way filter that only increases and never decreases, and the fast response display value is displayed as the fuel consumption value. In the oil leak fast response display mode, the fast response display value is subjected to a one-way filter that only decreases and does not increase, and the fast response display value is displayed as the fuel level external display value; Specifically, when the current scene is detected to change to the driving scene while in the fast response display mode, the fast response display mode is exited.
[0013] Secondly, embodiments of this application also provide a vehicle fuel level detection device, comprising: A first-order filtering module is used to obtain the instantaneous fuel quantity by performing a first-order low-pass filter on the raw signal collected by the liquid level sensor arranged in the fuel tank in each control cycle. The change direction determination module is used to obtain the current fuel internal display value, calculate the difference between the instantaneous fuel quantity and the current fuel internal display value, and determine the fuel quantity change direction and the corresponding number of consecutive changes based on the difference; The damping filter module is used to determine the current scenario of the vehicle based on the current vehicle speed and current rotation speed, determine the filter step size of the current control cycle based on the current scenario, the direction of fuel quantity change and the number of consecutive changes, and use the filter step size as the filter coefficient to perform variable step size damping filtering on the instantaneous fuel quantity to obtain the undetermined display value; The display module is used to determine and display the fuel consumption value based on the current scene and the pending display value.
[0014] Thirdly, embodiments of this application also propose an electronic device, including: a processor, a memory, and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the memory via the bus, and when the machine-readable instructions are executed by the processor, the steps of the vehicle fuel level detection method as described in any of the first aspects above are performed.
[0015] The vehicle fuel level detection method described in this application combines a first-order low-pass filter with a trend-adaptive variable-step damping filter, and dynamically determines the filter step size based on the scenario, direction of change, and number of consecutive changes. This achieves a balance between suppressing sudden changes in fuel level under bumpy road conditions and providing rapid response during refueling or fuel leaks, thereby improving the accuracy, stability, and real-time performance of fuel level display. Attached Figure Description
[0016] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 A flowchart of a vehicle fuel level detection method according to an embodiment of this application is shown; Figure 2 A comparative schematic diagram of rapid acceleration in an embodiment of this application is shown; Figure 3 A comparative schematic diagram of a bumpy road section is shown in the embodiments of this application; Figure 4 A comparative schematic diagram of a parking scenario on a slope is shown in the embodiments of this application; Figure 5 A flowchart illustrating the method for end alignment in an embodiment of this application is shown; Figure 6 A flowchart illustrating the method for implementing a fast-response display mode in an embodiment of this application is shown; Figure 7 A flowchart illustrating an example of oil quantity detection in an embodiment of this application is shown; Figure 8 A schematic diagram of a vehicle fuel level detection device according to an embodiment of this application is shown; Figure 9 A structural diagram of an electronic device according to an embodiment of this application is shown. Detailed Implementation
[0018] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the accompanying drawings in this application are for illustrative and descriptive purposes only and are not intended to limit the scope of protection of this application. Furthermore, it should be understood that the schematic drawings are not drawn to scale. The flowcharts used in this application illustrate operations implemented according to some embodiments of this application. It should be understood that the operations in the flowcharts may not be implemented in sequence, and steps without logical contextual relationships may be reversed or implemented simultaneously. In addition, those skilled in the art, guided by the content of this application, may add one or more other operations to the flowcharts, or remove one or more operations from the flowcharts.
[0019] Furthermore, the described embodiments are merely some, not all, of the embodiments of this application. The components of the embodiments of this application described and illustrated herein can typically 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 to illustrate selected embodiments of the 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.
[0020] It should be noted that the term "comprising" will be used in the embodiments of this application to indicate the presence of the features declared thereafter, but does not exclude the addition of other features.
[0021] Before describing the vehicle fuel level detection method, device, electronic device, computer-readable storage medium, and computer program product provided in the embodiments of this application, the technical background of the embodiments of this application will be described in detail below for ease of understanding.
[0022] Traditional fuel gauges use a pointer-type structure, displaying the fuel level by pointing the pointer to the fuel gauge scale. Their circuits are purely analog circuit designs, usually without an MCU chip. They generally consist of two sets of electromagnetic coils and a pointer with a permanent magnet, and the pointer moves between E and F by using changes in the strength of the magnetic field.
[0023] Traditional fuel gauges typically rely on sensors inside the fuel tank to collect fuel level signals, which are then used by a pointer with a permanent magnet driven by a magnetic field generated by an electromagnetic coil. However, the sensors inside the fuel tank are easily affected by vehicle bumps, inclines, and declines, leading to excessive detection errors. As a result, the pointer display does not match the actual fuel level, making it impossible to accurately determine the exact number of liters of fuel remaining in the tank.
[0024] In view of the technical problems in the prior art where fuel level detection is easily affected by vehicle bumps, uphill and downhill conditions, resulting in excessive detection errors and discrepancies between the displayed and actual fuel levels, this application proposes a vehicle fuel level detection method, such as... Figure 1 As shown, it includes the following steps: Step S101: In each control cycle, the raw signal is collected based on the liquid level sensor arranged in the fuel tank, and the instantaneous fuel quantity is obtained after the raw signal is subjected to a first-order low-pass filter. Step S102: Obtain the current fuel level display value, calculate the difference between the instantaneous fuel level and the current fuel level display value, and determine the direction of fuel level change and the corresponding number of consecutive changes based on the difference; Step S103: Determine the current scenario of the vehicle based on the current vehicle speed and current rotation speed; determine the filter step size of the current control cycle based on the current scenario, the direction of fuel quantity change and the number of consecutive changes; and use the filter step size as the filter coefficient to perform variable step size damping filtering on the instantaneous fuel quantity to obtain the undetermined display value. Step S104: Determine the fuel display value based on the current scenario and the pending display value, and then display it.
[0025] The above-described embodiments of this application combine first-order low-pass filtering with trend-adaptive variable step-size damping filtering, and dynamically adjust the filtering step size according to the scenario, direction of change, and number of consecutive changes. This can suppress fuel level fluctuations during bumpy or uphill / downhill driving, accelerate response during refueling or fuel leaks, and improve the accuracy, stability, and real-time performance of fuel level detection.
[0026] In step S101 of this application embodiment, the instantaneous fuel quantity is obtained by collecting the original signal based on the liquid level sensor arranged in the fuel tank and performing a first-order low-pass filter on the original signal. Specifically, this includes the following steps: The raw ADC resistance value is acquired based on the liquid level sensor placed inside the fuel tank; When the first-order low-pass preprocessing enable switch is turned on, the original ADC resistance value is subjected to first-order low-pass preprocessing based on the preset integer ratio filter coefficient to obtain the instantaneous oil quantity.
[0027] In some possible embodiments, the ADC (Analog-to-Digital Converter) signal output by the oil float sensor is acquired by the MCU as the original signal. In the embodiments of this application, the focus is on the subsequent filtering process, and the specific method of acquiring the original signal is not limited.
[0028] It should be noted that, to adapt to specific application scenarios, an enable switch can be set for this first-order low-pass preprocessing. This enable switch allows the first-order low-pass preprocessing function to be disabled in special scenarios requiring bypass filtering, such as short-circuit open circuits, to prevent filtering from masking hardware faults. In this embodiment, the first-order low-pass is optional and decoupled from the subsequent dynamic damping filter, facilitating adaptation to different platforms. Specifically, the implementation method of bypass filtering is not described in detail in this embodiment.
[0029] Specifically, the standard first-order low-pass recursive formula is shown in Formula 1 below; Formula 1 Among them, coefficient It is a constant. Increasing the size results in a faster response but also makes it more prone to jitter. Decreasing the coefficient results in a smoother ride but also a greater lag, making it unsuitable for simultaneously handling conflicting conditions such as bumpy roads and rapid refueling. Optionally, the coefficient is typically an integer ratio. The configuration is shown in Formula 2 below: Formula 2 Optional, It can be 1 / 8, and the function can be turned on or off as a whole by the above-mentioned enable switch.
[0030] Specifically, to support the aforementioned first-order low-pass preprocessing, a fixed-length integer data structure is defined in some possible embodiments, without dynamic memory allocation. The first-order low-pass configuration structure includes: a switch flag to indicate whether the first-order low-pass preprocessing is enabled or disabled; a numerator representing the numerator of the integer ratio filter coefficients; and a denominator representing the denominator of the integer ratio filter coefficients. Thus, the integer ratio is expressed... To avoid floating-point operations, it is controlled to be turned on or off via an independent switch.
[0031] In some possible embodiments, the first-order low-pass state structure includes: an initialization flag to indicate whether the first-order low-pass state has been initialized; a previous output value to store the filtered output value of the previous control cycle; and a remainder to store the truncated remainder of integer operations. Specifically, the integer truncation error is compensated by accumulating the remainders to ensure long-term unbiased filtering.
[0032] Below are some graphical comparisons of the original resistance values and the values after first-order low-pass filtering. Among them, Figure 2 The diagram shown illustrates the rapid acceleration. Figure 3 The diagram shown is a comparison of the effects of first-order low-pass filtering on bumpy road sections. Figure 4 The diagram shows a comparison in a sloping parking scenario. As can be seen from the diagram, adding a first-order low-pass filter algorithm makes the resistance value tend to be smoother and more stable.
[0033] In steps S102 and S103 of this application embodiment, it should be noted that the original sampled values are not directly processed. Instead, the difference between the instantaneous oil quantity and the internally displayed value, as well as its direction, are calculated in each control cycle, and the filtering step size for this cycle is dynamically calculated according to the scenario and the number of consecutive changes. Specifically, the larger the filtering step size, the larger the equivalent filtering coefficient and the faster the response; the smaller the filtering step size, the smaller the equivalent filtering coefficient and the stronger the smoothing.
[0034] Therefore, by making the filter coefficients a dynamic quantity that is continuously variable with the scene and changing trend, and whose upward and downward directions are independent, it is possible to achieve sensitive response during rapid changes and high smoothness in a stable state. This simultaneously takes into account the high smoothness required for bumpy road sections and the high responsiveness required for rapid refueling, and solves the problem that traditional fixed-coefficient first-order filters cannot adapt to complex working conditions due to the inherent contradiction between sensitivity and stability.
[0035] In step S102 above, the number of continuous changes includes the number of continuous upward changes and the number of continuous downward changes, wherein the number of continuous upward changes and the number of continuous downward changes can be the number of cycles of continuous increase and decrease in instantaneous oil volume, respectively. In this embodiment, this number is used to characterize the continuous trend of oil volume change and serves as the basis for dynamically adjusting the filter step size.
[0036] In some possible embodiments, the determination of the current scene of the vehicle based on the current vehicle speed and current rotation speed in step S103 above specifically includes the following situations: When the current vehicle speed is greater than the first threshold, the current scenario is determined to be a driving scenario; When the current vehicle speed is not greater than the first threshold and the current rotation speed is not less than the second threshold, the current scenario is determined to be a parking idling scenario. When the current vehicle speed is not greater than the first threshold and the current rotation speed is less than the second threshold, the current scenario is determined to be a parking and engine-off scenario.
[0037] In some possible embodiments, the first threshold can be 1 km / h, and the second threshold can be 300 rpm. Specifically, when the vehicle speed is greater than 1 km / h, it is determined to be a driving scenario; when the vehicle speed is not greater than 1 km / h and the engine speed is not less than 300 rpm, it is determined to be a parking idling scenario; and when the vehicle speed is not greater than 1 km / h and the engine speed is less than 300 rpm, it is determined to be a parking and engine-off scenario.
[0038] In step S103 of this application embodiment, determining the filter step size of the current control cycle based on the current scenario, the direction of oil quantity change, and the number of consecutive changes specifically includes: When the current scenario is a driving scenario and the direction of fuel quantity change is upward, the filter step size is determined by multiplying the initial filter rate and the upward step size acceleration by the number of consecutive upward changes. When the current scenario is a driving scenario and the direction of fuel quantity change is downward, the filter step size is determined by multiplying the initial filter rate and the downward step size acceleration by the number of consecutive downward changes; When the current scenario is a parking idling scenario and the direction of fuel quantity change is downward, the preset parking idling fixed step size is used to determine the filtering step size; When the current scenario is a parking and engine shutdown scenario and the direction of fuel quantity change is upward, keep the current internal fuel display value unchanged, skip the variable step size damping filter of the current control cycle, and use the current internal fuel display value as the pending display value. The filtering step size is not greater than the preset upper limit of the filtering rate.
[0039] Specifically, in this application embodiment, the above-mentioned variable step size damping filter algorithm is divided into four differentiated processing scenarios according to the combination of operating conditions and the direction of oil quantity change, including driving upward scenario, driving downward scenario, parking idling downward scenario, and parking and turning off upward scenario.
[0040] Scenario 1: Driving upward scenario. In this scenario, the current scenario is a driving scenario and the direction of the change in oil volume is upward.
[0041] Correspondingly, the filter step size can be determined by multiplying the initial filter rate and the step acceleration in the upward direction by the number of consecutive upward changes. When there is a continuous rise in the fuel level caused by refueling or going uphill during driving, the filter step size increases periodically by accumulating the number of consecutive rises, and the equivalent filter coefficient increases accordingly. This accelerates the internal display value's tracking response to the actual fuel level increase, eliminating the lag in the traditional fixed coefficient filter's "slow rise" of the fuel gauge after refueling.
[0042] Scenario 2: Driving and descending scenario. In this scenario, the current scenario is a driving scenario and the direction of the change in fuel quantity is the descending direction.
[0043] Correspondingly, the filtering step size can be determined by multiplying the initial filtering rate and the acceleration of the step size in the downward direction by the number of consecutive downward changes. It should be noted that if filtering is always performed with a small step size corresponding to the initial filtering rate, the cumulative lag between the internal fuel display value and the actual fuel quantity will gradually increase over time, causing the remaining fuel quantity displayed on the instrument panel to remain consistently high. In this case, the aforementioned instantaneous fuel quantity maintains a stable downward trend over multiple consecutive control cycles, and the corresponding number of consecutive downward changes continuously accumulates. The filtering step size increases smoothly, allowing the internal display value to gradually converge to the actual fuel quantity at an appropriate rate, thereby correcting the cumulative deviation and maintaining the timeliness of the display.
[0044] In some possible implementations, when the vehicle travels on a bumpy road, the impact causes the oil level to fluctuate briefly. Although the overall trend of oil level change remains downward, the bumps can cause the oil level to jump in the opposite direction momentarily, making it impossible to maintain a continuous decrease. The number of consecutive changes is reset to zero or becomes a smaller value. At this point, the determined filter step size automatically falls back to a smaller value. This allows for the use of a larger step size to accelerate convergence when the trend is reliable, and a smaller step size to suppress errors when the signal is disturbed and unreliable, thus improving the accuracy of oil level detection.
[0045] Scenario 3: Parking and idling speed decrease scenario. In this scenario, the current scenario is a parking and idling scenario and the direction of the fuel quantity change is downward.
[0046] Correspondingly, the preset fixed step size for idling speed is determined as the filtering step size. It should be noted that when the vehicle is idling slowly, there is no vibration or disturbance in the vehicle body, and the fuel level is basically stable. At this time, there is no need for scenario-based dynamic acceleration logic intervention. Using a preset, relatively small fixed step size allows the fuel consumption display at idle speed to show an extremely smooth and slow decrease, avoiding the acceleration mechanism triggered by occasional minor sensor fluctuations, and ensuring absolute stability of the fuel gauge display when stationary.
[0047] Scenario 4: Parking and engine off, rising scenario. In this scenario, the current scenario is parking and engine off, and the direction of the fuel change is upward.
[0048] Correspondingly, the current internal fuel level is kept unchanged, the variable-step damping filter of the current control cycle is skipped, and the current internal fuel level is used as the pending display value. At this time, refueling after stopping and turning off the engine will cause the fuel level in the tank to rise sharply in a short period. If the filtering algorithm continues to be executed at this time, even if the step size has been accelerated to the maximum, the internal display value will still need to go through several control cycles to approach the true value, resulting in a delayed change in the fuel gauge display after power-on. Here, by skipping the filtering and freezing the current display value, the final fuel level update of the refueling event can be handled uniformly by the refueling detection logic when the vehicle is powered back on, ensuring that when the user starts the vehicle after refueling, the fuel gauge can immediately and accurately change to the true fuel level, meeting the user expectation of "instant display after refueling".
[0049] It should be noted that the above filtering step size is less than the preset upper limit of the filtering rate, in order to prevent the step size from increasing infinitely when the number of continuous changes accumulates, causing the equivalent filtering coefficient to approach 1 and thus degrading the filtering function, resulting in unexpected jumps in the fuel internal display value.
[0050] In this embodiment, the parameters used to determine the filtering step size are only the initial filtering rate, the step acceleration in the downward direction, the step acceleration in the upward direction, the upper limit of the filtering rate, and the fixed step size for idle speed. The trend counting and decoupling state can include the number of consecutive descents, the number of consecutive ascents, the internal tracking display value, and the external display value. Specifically, only two counters and two scalars are needed to carry all the dynamic logic, without the need to save historical sampling sequences.
[0051] The parameters used to determine the filtering step size in this embodiment include only the initial filtering rate, the step acceleration in the downward direction, the step acceleration in the upward direction, the upper limit of the filtering rate, and the fixed step size for idle speed. Furthermore, by setting two counters—the number of consecutive upward changes and the number of consecutive downward changes—as trend criteria, and combining them with the two scalars—the internal fuel display value and the external fuel display value—the filtering calculation and the instrument display are decoupled. This allows the entire variable step size damping filtering algorithm to carry all dynamic logic with very few stored variables, eliminating the need to save historical sampling sequences. This significantly reduces the storage and computational resource overhead in embedded environments, making it particularly suitable for automotive instrument scenarios with limited MCU resources.
[0052] Therefore, the filter coefficient is no longer a constant written into the configuration, but a dynamic quantity that is equivalent to the filter step size calculated in real time by the current scenario, the direction of oil quantity change, and the number of consecutive changes. The high-frequency suppression capability for high-frequency vibrations on bumpy road sections is automatically obtained by the instantaneous reset of the number of consecutive changes when the direction is reversed.
[0053] Following step S103 above, this embodiment of the application will further describe end alignment. For example... Figure 5 As shown, in some possible embodiments, after determining the filter step size of the current control cycle based on the current scenario, the direction of oil quantity change, and the number of consecutive changes, the method further includes: Step S501: Determine whether the absolute value of the difference between the instantaneous fuel quantity and the current internal fuel display value is not greater than the filtering step size of the current control cycle; If so, in step S501a, the instantaneous fuel quantity is used as the current internal fuel display value, and the variable step size damping filter of the current control cycle is skipped, and the instantaneous fuel quantity is used as the pending display value. If not, in step S501b, the filtering step size is used as the filtering coefficient to perform variable step size damping filtering on the instantaneous oil quantity to obtain the undetermined display value, and step S104 above is executed.
[0054] Specifically, when the absolute value of the difference between the instantaneous fuel quantity and the internally displayed value is not greater than the current cycle filtering step size, the internally displayed value can be directly aligned to the instantaneous fuel quantity, thereby eliminating the end jitter caused by step size dispersion near the target value.
[0055] Based on the established variable step size damping filter framework and four scenario classifications, step S104 further transforms the undetermined display value output from step S103 into the final external display value presented on the instrument panel, specifically including: When the current scenario is the driving scenario and the direction of fuel quantity change is upward, the pending display value is used as the internal fuel display value, and the current external fuel display value is frozen. When the preset display conditions or thawing conditions are met, the pending display value is used as the internal display value of the fuel, and the pending display value is used as the current external display value of the fuel and displayed. The display conditions include the current scenario being a parking idling scenario or a parking and engine off scenario, or the current scenario being a driving scenario and the direction of fuel level change not being upward; the defrosting conditions include the direction of fuel level change being downward.
[0056] It should be noted that the pending display value output in step S103 is an internal intermediate result after filtering calculation. Its numerical update frequency is synchronized with the control cycle. If this pending display value is directly output to the instrument panel, the externally displayed value may experience slight visual jitter due to sudden changes in the step size during the aforementioned dynamic filtering step size change process. Therefore, this embodiment of the application also introduces a scene-adaptive display transition strategy between the pending display value and the externally displayed value to decouple the internal tracking calculation from the instrument display.
[0057] Specifically, when entering a driving uphill scenario, although the filter step size is accelerated to drive the internal display value to converge quickly, the external display value is not updated synchronously with the internal display value, but is frozen at the value at the moment before entering the scenario. This freezing of the external fuel display value means that the fuel level reading shown on the instrument panel remains static during this period, and the user will not see the numbers jumping continuously.
[0058] When preset display conditions are met, the external fuel display value is unfrozen and updated. Specifically, the update only occurs when the vehicle approaches a standstill or the fuel level stops rising, including when the vehicle enters a parking idling scenario or a parked and turned-off scenario, or when, although still in motion, the fuel level is no longer increasing. Furthermore, the unfreezing condition also includes the fuel level changing direction to decreasing. This means that when refueling is completed and the fuel level begins to decrease due to normal driving fuel consumption, the external fuel display value will be updated to the internal fuel display value at that moment.
[0059] Thus, by mapping the undetermined display value to the external display value in different scenarios through step S104, a complete filtering link from the original sampling to the instrument display is completed, so that the entire variable step size damping filtering algorithm can dynamically adjust the response speed internally while maintaining a consistent and stable oil quantity display experience externally.
[0060] In particular, when the oil level changes continuously in one direction, such as during refueling or oil leakage, if the variable step size damping filter mechanism described above is still used, even if the filter step size has been accelerated to the upper limit of the filter rate, the internal display value still needs to go through several control cycles to approach the real oil level. The response speed is still difficult to meet the timeliness requirements of fast refueling display or oil leakage alarm.
[0061] Therefore, in addition to the aforementioned variable step-size damping filter, this application further introduces a parking steady-state secondary filter and a fast-response display mode to achieve rapid identification and immediate response to continuous unidirectional changes in liquid level, such as refueling or oil leakage, while the vehicle is parked. Figure 6 As shown, the specific steps include: Step S601: In the parking idling scenario or parking and engine off scenario, the instantaneous fuel quantity is sampled using a dual-cycle sliding window. The first period includes at least a preset first number of samples, and the difference between the maximum and minimum values in the samples is not greater than a preset difference; the second period includes at least a preset second number of samples, and the preset second number is greater than the preset first number. Step S602: After removing extreme values from the samples in the two-period sliding window, calculate the average value to obtain the steady-state reference value; Step S603: Based on the difference between the current instantaneous oil volume and the steady-state reference value, the preset refueling threshold, the preset oil leakage threshold, and the number of times the difference exceeds the corresponding threshold consecutively, determine whether to enter the corresponding fast response display mode. The fast response display modes include a refueling fast response display mode and an oil leak fast response display mode; In step S604, when it is determined that the corresponding fast response display mode is entered, the fuel display value is determined based on the instantaneous fuel quantity and displayed.
[0062] Specifically, in some possible embodiments, the parking steady-state secondary filtering can be performed when the vehicle speed is no greater than 1 km / h, i.e., in parking idling scenarios or parking with the engine off. A dual-cycle sliding window sampling is then initiated. The first cycle may require sufficient effective samples and the difference between the maximum and minimum fuel levels within the window not exceeding 1L; the second cycle may only require sufficient samples. After removing extreme values from the samples within the window, the average is calculated to obtain the steady-state reference value. The criterion for refueling or leaking is that the difference between the instantaneous fuel level and the steady-state reference value is not less than a refueling or leaking threshold and occurs consecutively a set number of times. Thus, parking sway is absorbed through statistical averaging, and occasional fluctuations are filtered out through multiple consecutive determinations.
[0063] Specifically, based on the sign of the difference between the current instantaneous fuel level and the steady-state reference value, it is compared with a preset refueling threshold or a preset leak threshold. For example, if the difference is negative, it is compared with the preset leak threshold. When the absolute value of the difference is not less than the preset leak threshold, the number of times the leak threshold is exceeded consecutively in that direction is recorded. When this number accumulates to a preset number of consecutive confirmations, it is determined to enter the corresponding fast leak response display mode. Similarly, if the difference is positive and not less than the preset refueling threshold, the number of times the refueling threshold is exceeded consecutively is recorded. When this number accumulates to a preset number of consecutive confirmations, it is determined to enter the fast refueling response display mode. This will not be elaborated further here.
[0064] In the fast-response display mode described in the embodiments of this application, the instantaneous fuel quantity is approximated by a set fast step size to obtain a fast-response display value; In the fast refueling display mode, the fast response display value is subjected to a one-way filter that only increases and never decreases, and the fast response display value is displayed as the fuel consumption value. In the oil leak fast response display mode, the fast response display value is subjected to a one-way filter that only decreases and does not increase, and the fast response display value is displayed as the fuel level external display value; Specifically, when the current scene is detected to change to the driving scene while in the fast response display mode, the fast response display mode is exited.
[0065] In this embodiment, the filtering logic is divided into two processing channels: an ascending channel and a descending channel. When the fast-response display mode is confirmed, based on the specific refueling or leaking fast-response display mode, the system switches to rapidly approximating the target instantaneous fuel volume using a set rapid step size. For example, the rapid step size can be 2L / s. In the refueling fast-response display mode, a one-way filtering that only increases is performed; in the leaking fast-response display mode, a one-way filtering that only decreases is performed. This further shields against false signals caused by surface sloshing, preventing a temporary drop in the display value due to surface drop during refueling or a temporary rise due to surface rebound during leaking. When the vehicle speed exceeds the threshold again, i.e., after detecting a change from the current scenario to the driving scenario, the system automatically exits the fast-response display mode and resumes the normal logic of the aforementioned variable-step damping filter.
[0066] In this embodiment, only a few parameters are needed to dynamically adjust the filter step size according to the scenario and changing trend, achieving a smooth and even fuel level display effect. Furthermore, the filter result can be directly output within the current control cycle after each instantaneous fuel level is collected, without waiting for batch processing of multiple sampling points. It should be noted that the filtering delay in this embodiment is entirely determined by the filtering coefficient equivalent to the filter step size. A larger filter step size results in a faster response and smaller lag, while a smaller filter step size results in stronger smoothness and a slight increase in lag. Different step size accelerations can be set to flexibly balance response speed and display stability according to the actual needs of different operating conditions.
[0067] The following is a specific example of fuel quantity detection based on the above-mentioned vehicle fuel level detection method, such as... Figure 7 As shown, the control cycle is set to 100ms, and for each control cycle, the following steps are included: Step S701: Acquire the original signal, perform a first-order low-pass filter on the original signal to obtain the instantaneous fuel quantity, and obtain the current vehicle speed and current RPM to determine the current scene of the vehicle. Step S702: Determine whether to enter the corresponding fast response display mode; Step S703a: If yes, then determine the fuel display value based on the instantaneous fuel quantity according to the corresponding fast response display mode and display it. Step S703b: If not, obtain the current fuel level display value, calculate the difference between the instantaneous fuel level and the current fuel level display value, and determine the direction of fuel level change and the corresponding number of consecutive changes; based on the current scenario, the direction of fuel level change and the number of consecutive changes, determine the filter step size of the current control cycle; Step S704: Determine whether the absolute value of the difference between the instantaneous fuel quantity and the current internal fuel display value is not greater than the filtering step size of the current control cycle; If so, in step S705a, the instantaneous fuel quantity is used as the current internal fuel display value, and the variable step size damping filter of the current control cycle is skipped, and the instantaneous fuel quantity is used as the pending display value. Step S705b: If not, use the filter step size as the filter coefficient to perform variable step size damping filtering on the instantaneous oil quantity to obtain the undetermined display value. Step S706: Determine the fuel display value based on the current scenario and the pending display value, and then display it.
[0068] The vehicle fuel level detection method described in this application dynamically determines the filtering step size by combining the current vehicle scenario, the direction of fuel level change, and the number of consecutive changes, so that the filtering coefficient can be adaptively adjusted according to different scenarios and changing trends.
[0069] Specifically, in driving scenarios and when the fuel level is rising, the filter step size gradually increases with the number of consecutive increases, thereby accelerating the response under continuous rising conditions such as refueling; in driving scenarios and when the fuel level is falling, the filter step size gradually increases with the number of consecutive falls, thereby accelerating the response under continuous falling conditions such as oil leaks; when idling and the fuel level is falling, a preset fixed step size for idling is used for smooth filtering to suppress fluid level sloshing in the stationary state; when the engine is turned off and the fuel level is rising, the current internal fuel display value is kept unchanged to avoid false high fuel levels caused by fuel backflow.
[0070] Therefore, the vehicle fuel level detection method described above in this application can balance the smoothness of the display under bumpy road conditions with the real-time response under conditions such as refueling and oil leakage, thereby improving the accuracy and stability of the fuel level display.
[0071] Based on the same inventive concept, this application also proposes a vehicle fuel level detection device, such as... Figure 8 As shown, it includes: The first-order filter module 801 is used to obtain the instantaneous fuel quantity by performing a first-order low-pass filter on the raw signal collected by the liquid level sensor arranged in the fuel tank in each control cycle. The change direction determination module 802 is used to obtain the current fuel internal display value, calculate the difference between the instantaneous fuel quantity and the current fuel internal display value, and determine the fuel quantity change direction and the corresponding number of consecutive changes based on the difference; The damping filter module 803 is used to determine the current scenario of the vehicle based on the current vehicle speed and the current rotation speed, determine the filter step size of the current control cycle based on the current scenario, the direction of fuel quantity change and the number of consecutive changes, and use the filter step size as the filter coefficient to perform variable step size damping filtering on the instantaneous fuel quantity to obtain the undetermined display value. Display module 804 is used to determine and display the fuel consumption value based on the current scene and the pending display value.
[0072] The above-described device is used to execute the method provided in the foregoing embodiments, and its implementation principle and technical effect are similar, so they will not be described again here.
[0073] These modules can be one or more integrated circuits configured to implement the above methods, such as one or more Application Specific Integrated Circuits (ASICs), one or more digital signal processors (DSPs), or one or more Field Programmable Gate Arrays (FPGAs). Alternatively, when a module is implemented using processing element scheduler code, the processing element can be a general-purpose processor, such as a Central Processing Unit (CPU) or other processor capable of calling program code. Furthermore, these modules can be integrated together as a system-on-a-chip (SOC).
[0074] Based on the same inventive concept, this application also proposes an electronic device, including: a processor, a memory, and a bus. The memory stores machine-readable instructions that can be executed by the processor. When the electronic device is running, the processor communicates with the memory through the bus. When the machine-readable instructions are executed by the processor, the steps of the vehicle fuel level detection method as described in any of the first aspects above are performed.
[0075] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application, such as... Figure 9 As shown, the electronic device 900 includes a processor 901, a memory 902, and a bus 903, with the processor 901 and the memory 902 communicating via the bus 903.
[0076] The memory 902 is used to store executable machine-readable instructions. The processor 901 calls the machine-readable instructions stored in the memory 902 to execute the above method embodiment. The specific implementation and technical effects are similar, and will not be described again here.
[0077] Optionally, embodiments of this application also propose a storage medium storing a computer program, which, when read and executed, implements the vehicle fuel level detection method of any of the above embodiments.
[0078] In the several embodiments provided by this invention, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0079] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0080] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in the form of hardware plus software functional units.
[0081] The integrated units implemented as software functional units described above can be stored in a computer-readable storage medium. These software functional units, stored in a storage medium, include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute some steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0082] The above are merely specific embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A method for detecting vehicle fuel level, characterized in that, include: In each control cycle, the instantaneous fuel quantity is obtained by acquiring the raw signal based on the liquid level sensor arranged in the fuel tank and performing a first-order low-pass filter on the raw signal. Obtain the current fuel level display value, calculate the difference between the instantaneous fuel level and the current fuel level display value, and determine the direction of fuel level change and the corresponding number of consecutive changes based on the difference; The current scenario of the vehicle is determined based on the current vehicle speed and current rotation speed. Based on the current scenario, the direction of fuel quantity change and the number of consecutive changes, the filter step size of the current control cycle is determined. The filter step size is used as the filter coefficient to perform variable step size damping filtering on the instantaneous fuel quantity to obtain the undetermined display value. The fuel consumption value is determined and displayed based on the current scenario and the pending display value.
2. The method according to claim 1, characterized in that, The method of obtaining instantaneous fuel quantity by acquiring raw signals from a level sensor located in the fuel tank and performing a first-order low-pass filter on the raw signals includes: The original analog-to-digital converter (ADC) resistance value is acquired based on the liquid level sensor placed inside the fuel tank; When the first-order low-pass preprocessing enable switch is turned on, the original analog-to-digital converter (ADC) resistance value is subjected to first-order low-pass preprocessing based on a preset integer ratio filter coefficient to obtain the instantaneous oil quantity.
3. The method according to claim 1, characterized in that, Determining the current scenario of the vehicle based on the current vehicle speed and current engine speed includes: When the current vehicle speed is greater than the first threshold, the current scenario is determined to be a driving scenario; When the current vehicle speed is not greater than the first threshold and the current rotation speed is not less than the second threshold, the current scenario is determined to be a parking idling scenario. When the current vehicle speed is not greater than the first threshold and the current rotation speed is less than the second threshold, the current scenario is determined to be a parking and engine-off scenario.
4. The method according to claim 3, characterized in that, The number of consecutive changes includes the number of consecutive upward changes and the number of consecutive downward changes. Determining the filter step size for the current control cycle based on the current scenario, the direction of oil quantity change, and the number of consecutive changes includes: When the current scenario is a driving scenario and the direction of fuel quantity change is upward, the filter step size is determined by multiplying the initial filter rate and the upward step size acceleration by the number of consecutive upward changes. When the current scenario is a driving scenario and the direction of fuel quantity change is downward, the filter step size is determined by multiplying the initial filter rate and the downward step size acceleration by the number of consecutive downward changes; When the current scenario is a parking idling scenario and the direction of fuel quantity change is downward, the preset parking idling fixed step size is used to determine the filtering step size; When the current scenario is a parking and engine shutdown scenario and the direction of fuel quantity change is upward, keep the current internal fuel display value unchanged, skip the variable step size damping filter of the current control cycle, and use the current internal fuel display value as the pending display value. The filtering step size is not greater than the preset upper limit of the filtering rate.
5. The method according to claim 3, characterized in that, After determining the filter step size of the current control cycle based on the current scenario, the direction of oil quantity change, and the number of consecutive changes, the method further includes: Determine whether the absolute value of the difference between the instantaneous fuel quantity and the current internal fuel display value is not greater than the filter step size of the current control cycle; If the absolute value is not greater than the filter step size of the current control cycle, then the instantaneous fuel quantity is used as the current internal fuel display value, and the variable step size damping filter of the current control cycle is skipped, and the instantaneous fuel quantity is used as the pending display value.
6. The method according to claim 3, characterized in that, The process of determining and displaying the fuel consumption display value based on the current scenario and the pending display value includes: When the current scenario is the driving scenario and the direction of fuel quantity change is upward, the pending display value is used as the internal fuel display value, and the current external fuel display value is frozen. When the preset display conditions or thawing conditions are met, the pending display value is used as the internal display value of the fuel, and the pending display value is used as the current external display value of the fuel and displayed. The display conditions include the current scenario being a parking idling scenario or a parking and engine off scenario, or the current scenario being a driving scenario and the direction of fuel level change not being upward; the defrosting conditions include the direction of fuel level change being downward.
7. The method according to any one of claims 1 to 6, characterized in that, The method further includes: In the scenarios of idling or turning off the engine, the instantaneous fuel quantity is sampled using a dual-cycle sliding window. The first cycle includes at least a preset first number of samples, and the difference between the maximum and minimum values in the samples is not greater than a preset difference. The second cycle includes at least a preset second number of samples, and the preset second number is greater than the preset first number. After removing extreme values from the samples within the sliding window with two cycles, the average value is calculated to obtain the steady-state reference value; Based on the difference between the current instantaneous oil level and the steady-state reference value, the preset refueling threshold, the preset oil leakage threshold, and the number of times the difference exceeds the corresponding threshold consecutively, it is determined whether to enter the corresponding fast response display mode; wherein, the fast response display mode includes a refueling fast response display mode and an oil leakage fast response display mode; When the corresponding fast-response display mode is entered, the fuel level is determined and displayed based on the instantaneous fuel level.
8. The method according to claim 7, characterized in that, When determining to enter the corresponding fast-response display mode, the fuel level is determined and displayed based on the instantaneous fuel quantity, including: When the corresponding fast response display mode is entered, the instantaneous fuel quantity is approximated by a set fast step size to obtain the fast response display value; In the fast refueling display mode, the fast response display value is subjected to a one-way filter that only increases and never decreases, and the fast response display value is displayed as the fuel consumption value. In the oil leak fast response display mode, the fast response display value is subjected to a one-way filter that only decreases and does not increase, and the fast response display value is displayed as the fuel level external display value; Specifically, when the current scene is detected to change to a driving scene while in fast response display mode, the fast response display mode is exited.
9. A vehicle fuel level detection device, characterized in that, include: A first-order filtering module is used to obtain the instantaneous fuel quantity by performing a first-order low-pass filter on the raw signal collected by the liquid level sensor arranged in the fuel tank in each control cycle. The change direction determination module is used to obtain the current fuel internal display value, calculate the difference between the instantaneous fuel quantity and the current fuel internal display value, and determine the fuel quantity change direction and the corresponding number of consecutive changes based on the difference; The damping filter module is used to determine the current scenario of the vehicle based on the current vehicle speed and current rotation speed, determine the filter step size of the current control cycle based on the current scenario, the direction of fuel quantity change and the number of consecutive changes, and use the filter step size as the filter coefficient to perform variable step size damping filtering on the instantaneous fuel quantity to obtain the undetermined display value; The display module is used to determine and display the fuel consumption value based on the current scene and the pending display value.
10. An electronic device, characterized in that, include: The device includes a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory via the bus. When the machine-readable instructions are executed by the processor, they perform the steps of the vehicle fuel level detection method as described in any one of claims 1 to 8.
