A fuel tank liquid level monitoring method and device based on extended Kalman filtering
By fusing data from an extended Kalman filter and an ultrasonic level sensor and an IMU module, the problem of high accuracy in oil tank level measurement under swaying, tilting, and temperature drift was solved, realizing a low-cost level monitoring device, reducing errors and false alarm rates, and enhancing anti-interference capabilities.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- 浙江邦泰氢能科技有限公司
- Filing Date
- 2026-06-23
- Publication Date
- 2026-07-21
AI Technical Summary
Existing methods for measuring oil tank levels suffer from problems such as large errors, high costs, and difficult installation when faced with oil tank swaying, tilting, temperature drift, and sensor noise interference, making it difficult to achieve high-precision and low-cost level monitoring.
An extended Kalman filter-based method for monitoring tank level is adopted. By fusing data from ultrasonic level sensors, temperature sensors, and IMU modules, online estimation and compensation for swaying, tilting, and temperature drift are performed. Combined with adaptive observation noise suppression and dynamic threshold strategies, accurate calculation and alarm of tank level and remaining volume are achieved.
It achieves high-precision liquid level measurement under shaking and tilting conditions, with a steady-state error of less than 2mm, a false alarm rate of less than 0.3%, low installation and replacement costs, and strong resistance to contamination and bubble formation.
Smart Images

Figure CN122429892A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to online liquid level monitoring technology for fuel oil and other liquid storage tanks, and in particular to a method and device for monitoring the liquid level of fuel tanks based on extended Kalman filtering. It is applicable to vehicles, ships, construction machinery, generator sets and industrial pumping stations, as well as to high-precision and high-reliability liquid level measurement and remaining oil quantity calculation for enclosed irregularly shaped fuel tanks under conditions of shaking, tilting, temperature drift and sensor noise interference. Background Technology
[0002] A vehicle's or generator set's fuel tank is a specialized container for storing fuel for its power unit (such as a diesel engine or gasoline engine). It is not only a "fuel depot" but also a core component for the safe and stable operation of the fuel system, requiring a continuous, clean, and sufficient supply of fuel to the engine under various operating conditions. With the rapid development of technology, fuel tank level measurement and control has gradually become crucial in modern vehicle power management and safety monitoring. Real-time monitoring of the fuel level in the tank can prevent sudden engine stalling due to running out of fuel, which could lead to safety accidents during driving or operation. Especially when the fuel level is too low, sediment or air at the bottom of the tank may be drawn into the engine, causing unstable combustion, component damage, or power interruption.
[0003] Current fuel tank level measurement commonly employs float-sliding resistor, pressure, or conventional ultrasonic methods. The float-sliding resistor method suffers from complex mechanical structures, is susceptible to jamming due to sludge, and thus exhibits poor long-term reliability. The pressure method requires additional holes in the fuel tank or fuel line to install the sensor and is sensitive to changes in oil density, directly leading to fundamental errors. While conventional ultrasonic methods do not require direct contact with the fuel tank, they exhibit significant errors in certain situations. For example, the "false level" caused by oil surface sloshing during vehicle or ship operation can result in instantaneous echo jitter of ±15 mm. Fuel tanks are often irregularly shaped, leading to non-linear level-volume curves; simple linear conversion can easily introduce a 5%–12% volume error. Furthermore, temperature changes cause variations in sound velocity (≈0.17% / ℃), which, without compensation, introduces a 2–4 mm system bias. Additionally, ultrasonic sensors exhibit random noise and abnormal echoes (such as secondary echoes from side walls), which cannot be eliminated by traditional threshold filtering. Moreover, refueling or driving on steep slopes can cause temporary tilting, rendering static geometric algorithms ineffective.
[0004] Currently, some technologies have attempted to suppress sloshing using first-order inertial filtering or moving averages, but these suffer from significant hysteresis and phase delay. Other technologies have proposed multi-point ultrasonic arrays, but these lead to a substantial increase in cost and installation difficulties. Therefore, there is an urgent need for a fuel tank level monitoring method and device based on extended Kalman filtering to achieve high-precision, fast-response, low-cost, and maintenance-free fuel tank level monitoring. Summary of the Invention
[0005] The summary section of this application is intended to provide a brief overview of the concepts, which will be described in detail in the detailed description section below. This summary section is not intended to identify key or essential features of the claimed technical solutions, nor is it intended to limit the scope of the claimed technical solutions.
[0006] To address the problems and shortcomings of existing technologies, this invention aims to provide a fuel tank level monitoring method and device based on extended Kalman filtering. By fusing multi-source information from an ultrasonic level sensor, temperature sensor, and IMU module using the EKF level-volume fusion algorithm, it simultaneously estimates and compensates for swaying, tilting, and temperature drift online, significantly reducing steady-state errors. Furthermore, adaptive observation noise suppression reduces the weighting of abnormal echoes, providing strong resistance to contamination and bubble formation. The fuel tank level monitoring device in this invention is an integrated package with both CAN and analog interfaces, resulting in low installation and replacement costs. This addresses the problems mentioned in the background section.
[0007] To achieve the above objectives, the present invention provides the following technical solution:
[0008] As a first aspect of this application, the present invention discloses a method for monitoring the liquid level in an oil tank based on extended Kalman filtering, comprising the following steps:
[0009] Step 1: Obtain the raw time-of-flight value of the ultrasonic level sensor, the temperature output by the temperature sensor, and the raw six-axis data from the IMU module;
[0010] Step 2: After real-time compensation of the sound velocity using the output temperature of the temperature sensor, the original liquid level is calculated, and the tilt angle is estimated by performing tilt angle calculation.
[0011] Step 3: Construct the observation vector and state vector, execute the EKF level-volume fusion algorithm, and output the optimal level estimate.
[0012] Step 4: calibrate and construct a discrete table of liquid level and volume, and select the corresponding optimal remaining volume value based on the discrete table of liquid level and volume, and output it in the form of a CAN message signal;
[0013] Step 5: Verify the optimal liquid level estimate and the optimal remaining volume value using a dynamic threshold threshold SLA, and issue an alarm for low liquid level conditions;
[0014] Step 6: Repeat this process to monitor the optimal liquid level estimate and the optimal remaining volume in real time.
[0015] Preferably, the tilt angle calculation in step 2 is as follows: first, the tilt angle is calculated by the acceleration component to achieve a preliminary estimate; then, a high-pass filter is used to extract the high-frequency part of the gyroscope signal in the IMU module, and a low-pass filter is used to extract the low-frequency part of the accelerometer signal in the IMU module; the high-frequency part and the low-frequency part are combined with the tilt angle obtained from the preliminary estimate and subjected to complementary filtering to obtain the fused tilt angle estimate.
[0016] Preferably, step 3 further includes the following steps:
[0017] Step 3.1: Construct the state vector and observation vector, predict the state based on the optimal value of the state vector in the previous period, and construct the prior state.
[0018] Step 3.2: Obtain the observation matrix by linearizing the prior state through the construction of an observation function;
[0019] Step 3.3: Construct the observation noise covariance matrix, calculate the prior covariance matrix, and then construct the observation noise covariance matrix in combination with the observation matrix to calculate the innovation covariance matrix;
[0020] Step 3.4: Calculate the Kalman gain based on the prior covariance matrix, observation matrix, and innovation covariance matrix;
[0021] Step 3.5: Calculate the innovation vector to correct the predicted state, and take the first component of the updated state as the optimal liquid level estimate.
[0022] Step 3.6: Update the prior covariance matrix to obtain the covariance matrix for use in the next cycle.
[0023] Preferably, in step 4, the liquid level-volume discrete table is constructed by using a Coriolis mass flow meter as the volume reference and an electronic scale to assist in verifying the mass-volume conversion. The volume is recorded once every 0.5L is injected until the liquid level reaches the geometric highest point of the tank, resulting in multiple original points. The original points are preprocessed with static and dynamic calibration. After monotonicity verification of the original points at 1mm intervals, conformal segmented cubic Hermite interpolation resampling is used to obtain the liquid level-volume discrete table.
[0024] Preferably, step 4 further includes the following steps:
[0025] Step 4.1: Round down the optimal liquid level estimate to establish an index and calculate the locally normalized decimal.
[0026] Step 4.2: In the offline stage, the liquid level-volume discrete table is divided into segments of four points, and four Hermite interpolation parameters are stored according to the volume-liquid level mapping table.
[0027] Step 4.3: Calculate the optimal residual volume using the Hermite interpolation parameters combined with predefined Hermite basis functions;
[0028] Step 4.4: Linearly map the optimal remaining volume value to an integer value and send it to other control devices via the CAN bus in CAN format.
[0029] Preferably, after step 3, an adaptive observation noise covariance matrix update strategy is designed. First, a sliding window is used to save the most recent multiple innovations and define their innovation vectors. Then, the real-time variance of the innovation sequence is estimated based on the innovation vectors. The observation noise covariance matrix is dynamically adjusted and updated and the Kalman gain is updated based on the real-time variance of the innovation sequence. Finally, outlier transients are accelerated to converge. If an outlier is identified, the real-time variance of the innovation sequence is increased instantaneously. Otherwise, it gradually converges back to the initial value, so that occasional abnormal measurements such as sidewall echoes, bubbles, and oil splashes are automatically downweighted.
[0030] Preferably, in step 5, an alarm is triggered for low liquid level conditions using a dynamic threshold threshold SLA, and the input trigger signal includes the EKF optimal liquid level estimate obtained in step 3. EKF liquid surface vertical average velocity EKF tilt angle The tilt angle derivative directly output by the gyroscope The low liquid level alarm is achieved by defining a three-dimensional joint discrimination function combined with a state machine. The low liquid level alarm is only triggered when the static liquid level lasts for more than 3 seconds.
[0031] Preferably, if the oil tank has a "T"-shaped compartment or a stepped bottom in step 4, a sub-table of a multi-segment liquid level-volume discrete table is pre-established, and the sub-table number is obtained by looking up the "compartment boundary table" through the optimal liquid level estimate before executing steps 4.2 and 4.3.
[0032] Preferably, the CAN signal can be directly connected to the existing fuel tank monitoring system via a jumper and set to a 4–20 mA mode, linearly mapping the optimal remaining volume value so that 20 mA corresponds to a full tank of fuel and 4 mA corresponds to an empty tank of fuel.
[0033] As a second aspect of this application, the present invention discloses a fuel tank level monitoring device based on extended Kalman filtering, comprising:
[0034] The sensor data acquisition module is used to acquire data from the ultrasonic level sensor and the temperature sensor in real time. The ultrasonic level sensor is fixed to the bottom of the oil tank, and the temperature sensor is attached to the outer shell of the ultrasonic level sensor.
[0035] The IMU attitude module includes a three-axis accelerometer and a three-axis gyroscope for dynamically estimating the output tilt angle. The IMU attitude module can be installed on a flat area on top of the fuel tank.
[0036] The control module is used to receive data from the sensor data acquisition module and the IMU attitude module, execute and output the real-time optimal liquid level estimate and optimal remaining volume value, and issue an alarm when the liquid level is low.
[0037] The control module is connected to the CAN module and is used to output the analog signals output by the control module as CAN message signals.
[0038] The control module is connected to the interactive display module, which is used to display and view relevant data information in real time and select to interact with it;
[0039] The control module is connected to the power management module, which is used to supply power to the control module and clamp the entire monitoring device to a safe level;
[0040] The control module is connected to the storage module and is used to store the data collected by the liquid level-volume discrete table (VCM), the sensor data acquisition module, and the IMU attitude module.
[0041] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0042] This invention provides a fuel tank level monitoring method and device based on extended Kalman filtering. First, it acquires the raw time-of-flight value of the ultrasonic level sensor, the temperature output from the temperature sensor, and the six-axis raw data from the IMU module. The raw level is calculated by real-time compensation of the sound velocity using the output temperature of the temperature sensor, and an inclination angle estimate is obtained through inclination angle calculation. An observation vector and a state vector are constructed, and the EKF level-volume fusion algorithm is executed to output the optimal level estimate. A level-volume discrete table is calibrated and generated, and the corresponding optimal remaining volume value is selected based on the table and output as a CAN message signal. The optimal level estimate and optimal remaining volume value are verified using a dynamic threshold (SLA), and an alarm is triggered for low level conditions. This process is repeated cyclically to monitor the optimal level estimate and optimal remaining volume value in real time. This invention integrates multi-source information from the ultrasonic level sensor, temperature sensor, and IMU module using the EKF level-volume fusion algorithm, simultaneously estimating and compensating for swaying, tilting, and temperature drift online, achieving a steady-state error of less than 2 mm. Furthermore, the use of a dynamic SLA strategy reduces the false alarm rate from 5% to below 0.3%. This invention also features adaptive observation noise suppression to reduce the weighting of abnormal echoes, resulting in strong resistance to contamination and air bubbles. The oil tank level monitoring device in this invention is an integrated package with both CAN and analog interfaces, offering low installation and replacement costs, and can directly replace the original float sensor. Attached Figure Description
[0043] The accompanying drawings, which form part of this application, are used to provide a further understanding of the application and to make other features, objects, and advantages of the application more apparent. The illustrative embodiments and descriptions of this application are used to explain the application and do not constitute an undue limitation of the application.
[0044] In the attached diagram:
[0045] Figure 1 This is a general block diagram of the extended Kalman filter oil tank level monitoring method in an embodiment of the present invention;
[0046] Figure 2 The system topology and data flow diagram of the extended Kalman filter oil tank level monitoring method in this embodiment of the invention are shown below;
[0047] Figure 3 This is a flowchart of the EKF level-volume fusion algorithm for the extended Kalman filter-based oil tank level monitoring method in this embodiment of the invention.
[0048] Figure 4 This is a connection structure diagram of the extended Kalman filter oil tank level monitoring device in an embodiment of the present invention;
[0049] Figure 5 The VCM curve of the irregularly shaped oil tank in the oil tank level monitoring method of extended Kalman filtering in this embodiment of the invention;
[0050] Figure 6 This is a dynamic sloshing test comparison curve of the extended Kalman filter oil tank level monitoring method in this embodiment of the invention. Detailed Implementation
[0051] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.
[0052] It should also be noted that, for ease of description, only the parts relevant to the invention are shown in the accompanying drawings. Unless otherwise specified, the embodiments and features described in this disclosure can be combined with each other.
[0053] Example 1
[0054] In this embodiment of the invention, a method for monitoring oil tank level based on extended Kalman filtering is disclosed, referring to... Figure 1 As shown, the present invention includes the following steps:
[0055] Step 1: Obtain the raw time-of-flight value of the ultrasonic level sensor, the temperature output by the temperature sensor, and the raw six-axis data from the IMU module;
[0056] Step 2: After real-time compensation of the sound velocity using the output temperature of the temperature sensor, the original liquid level is calculated, and the tilt angle is estimated by performing tilt angle calculation.
[0057] Step 3: Construct the observation vector and state vector, execute the EKF level-volume fusion algorithm, and output the optimal level estimate.
[0058] Step 4: calibrate and construct a discrete table of liquid level and volume, and select the corresponding optimal remaining volume value based on the discrete table of liquid level and volume, and output it in the form of a CAN message signal;
[0059] Step 5: Verify the optimal liquid level estimate and the optimal remaining volume value using a dynamic threshold threshold SLA, and issue an alarm for low liquid level conditions;
[0060] Step 6: Repeat this process to monitor the optimal liquid level estimate and the optimal remaining volume in real time.
[0061] Specifically, the raw time-of-flight value of the ultrasonic level sensor is first obtained. The output temperature of the temperature sensor And the six-axis raw data of the IMU attitude module ( Furthermore, the ultrasonic level sensor is fixed at the center of the bottom of the fuel tank, while the temperature sensor is attached to the housing of the ultrasonic level sensor. The IMU attitude module can be installed at the center of the flat area on the top of the fuel tank. Then, the output temperature of the temperature sensor is used to... Real-time compensated sound speed, represented as Among them, 0 By using the output temperature of a temperature sensor to correct the sound velocity in real time, measurement errors caused by changes in ambient temperature are eliminated, thereby significantly improving the measurement accuracy of devices such as ultrasonic level gauges.
[0062] Reusing the corrected speed of sound The original liquid level from the ultrasonic level sensor to the liquid surface is calculated, i.e. Next, tilt angle calculation is performed on the IMU attitude module, represented as follows:
[0063] ;
[0064] ;
[0065] in, and This refers to the accelerometer in the IMU attitude module. The acceleration measurement along the axis reflects the magnitude of the object's acceleration along the corresponding axis. It is expressed as the tilt angle calculated from acceleration measurements and is used to estimate the attitude of an object in space. This represents the tilt angle output by the IMU attitude module at the previous moment. This indicates that the gyroscope in the IMU attitude module is... The angular velocity measurement along the axis reflects the object's rotation. The rotational speed of the shaft. The value represents the sampling time interval, while 0.98 and 0.02 represent the filter coefficients. In the above formula, the attitude angle is first estimated by calculating the acceleration component, and then complementary filtering is used to obtain the fused attitude angle. A high-pass filter is used to extract the high-frequency component of the gyroscope signal, and a low-pass filter is used to extract the low-frequency component of the accelerometer signal. The two are then added together to obtain a reliable tilt angle estimate across the entire frequency band.
[0066] like Figure 2 and Figure 3 As shown, step 3 involves executing the EKF level-volume fusion algorithm to construct the observation vector and state vector, and the output is obtained. Specifically, it also includes the following steps:
[0067] Step 3.1: Construct the state vector and observation vector, predict the state based on the optimal value of the state vector in the previous period, and construct the prior state.
[0068] Step 3.2: Obtain the observation matrix by performing linearization processing on the prior state of the observation function;
[0069] Step 3.3: Construct the observation noise covariance matrix to calculate the prior covariance matrix, and then construct the observation noise covariance matrix and combine it with the observation matrix to calculate the innovation covariance matrix;
[0070] Step 3.4: Calculate the Kalman gain based on the prior covariance matrix, the observation matrix, and the innovation covariance matrix;
[0071] Step 3.5: Calculate the innovation vector to correct the predicted state, and take the first component of the updated state as the optimal liquid level estimate.
[0072] Step 3.6: Update the prior covariance matrix to obtain the covariance matrix for use in the next cycle.
[0073] The core of this invention lies in the EKF level-volume fusion algorithm. Specifically, we first need to construct a state vector and an observation vector. The state vector is designed as follows: ,in Indicates the actual liquid level height. It represents the vertical average velocity of the liquid (characterizing the intensity of sloshing). Indicates liquid level acceleration. This represents the instantaneous tilt angle of the fuel tank. The observation vector is constructed as follows: ,in This indicates the original liquid level after temperature compensation. This represents the tilt angle obtained after complementary filtering by the IMU attitude module. Next, state prediction is performed, selecting the state vector. The optimal value of the previous period is expressed as The state at the current moment is predicted by optimizing the state vector at a fixed time interval using the optimal value of the previous cycle. The fixed time interval is expressed as... Therefore, the optimal state vector value of the previous cycle is expressed as: The prediction step is represented as follows:
[0074]
[0075]
[0076]
[0077]
[0078] in, Indicates the predicted liquid level height. This indicates the predicted vertical velocity of the liquid. This indicates the predicted liquid level acceleration. Indicates the predicted instantaneous pitch angle. and This indicates the damping of liquid sloshing and its natural frequency. Indicates that the gyroscope is in Angular velocity measurements in the axial direction, Indicates that the gyroscope is in Shaft offset error, This indicates the liquid level height in the previous cycle. This indicates the vertical velocity of the liquid in the previous cycle. This indicates the liquid level acceleration in the previous cycle. This represents the instantaneous pitch angle of the previous cycle. The prior state is represented as follows: .
[0079] The observation function is constructed as follows: The prior states are linearized to obtain the observation matrix, which is then used to estimate subsequent states. Represented as,
[0080] ;
[0081] ;
[0082] in, This indicates the predicted instantaneous pitch angle. This represents the predicted liquid level height. The above formula expresses the relationship between observed values and prior states. The observation matrix is obtained by taking the partial derivatives. The observation matrix For one The matrix describes the linear relationship between the observed values and the prior state variables. Then, the prior covariance matrix at the current time is calculated as follows: , Denotes the prior covariance matrix. Represents the state transition Jacobian matrix. Represents the process noise covariance matrix. This represents the posterior covariance at the next time step. Process noise covariance matrix. Represented as A process noise covariance matrix is constructed using a diagonal matrix. The innovation covariance matrix is then calculated based on the prior covariance matrix. .in, Represents the observation matrix. Denotes the prior covariance matrix. This represents the observation noise covariance matrix. The initial value of the observation noise covariance matrix is set to a diagonal matrix. Furthermore, adaptive corrections can be applied later. The new information covariance matrix is used to calculate parameters such as the Kalman gain, thereby adjusting the state estimation results. The new information covariance matrix measures the degree of difference between observed and predicted data, helping the algorithm determine the reliability of the observed data, thus more reasonably fusing predicted and observed values and improving the accuracy and reliability of state estimation. The Kalman gain is then calculated and expressed as follows: ,in Denotes the prior covariance matrix. It is represented as the transpose of the observation matrix. This represents the inverse of the new information covariance matrix.
[0083] Next, calculate the innovation vector. for New information vector Represents the observation vector With prior state The difference between predicted values reflects the portion of the observed vector that exceeds the prediction; that is, it uses the innovation vector. This represents the difference between the actual observed value and the predicted value. Combined with Kalman gain... For the new information vector After weighting, the updated estimated state is represented as follows: The predicted state is corrected using the innovation vector, i.e. The first component of the updated estimated state is represented as the optimal liquid level estimate. Simultaneously, the prior covariance matrix is updated to obtain a new covariance matrix for use in the next period, denoted as... ,in Represented as The identity matrix, Indicates Kalman gain, This is represented as the prior covariance matrix. Therefore, the updated covariance matrix can reflect the changes in uncertainty in the state estimate.
[0084] Then, as Figure 6 As shown, to prevent secondary echoes from the sidewall or transient bubbles from affecting the original liquid level of the ultrasonic level sensor, To address the anomaly, we design an adaptive observation noise covariance matrix. The update strategy involves dynamically adjusting the observation noise covariance based on the innovation sequence, with automatic downweighting of anomalous echoes. This is achieved by dynamically adjusting and updating the observation noise covariance matrix through online estimation of the real-time variance of the observation innovation sequence. This automatically reduces the weight of occasional abnormal measurements such as sidewall echoes, bubbles, and oil splashes, while maintaining optimal gain for normal measurements. Here, we choose the "Exponentially Weighted Moving Average (EWMA)-Innovation Variance Estimator," which has low computational cost, fixed memory usage, and fast response to sudden anomalies. First, a sliding window saves the most recent 50 innovations. Its innovation vector is defined as The new information vector The dimension is (Including ultrasound and tilt angle). The variance of the ultrasound channel is estimated separately as follows: ,in Indicates the first The latest information value related to the ultrasonic level sensor at all times. Represents the forgetting factor and [0.9, 0.98], Forgetting Factor The default value is 0.95, which corresponds to approximately 20 sample memories. Indicates the first The variance estimate of quantities related to the ultrasonic level sensor at any given time. To prevent variance... The extreme outlier caused by the skewed values is addressed by introducing upper and lower limit clamps. ,in This represents the factory-calibrated steady-state variance (4). ), This indicates the maximum allowable variance (corresponding to ±15mm of abnormal jitter). The following is based on adaptive... The matrix updates the observation noise covariance, denoted as... , Represent the noise covariance matrix associated with the IMU attitude module, and... Directly applied to the Kalman gain formula in section 3a .in, Represents the observation matrix. This represents the prior covariance. Finally, acceleration convergence is achieved for out-of-value transients. It was identified as an outlier, which instantly increased the variance. .otherwise Gradually converge back to the initial value. The channel remains fixed. Normal EWMA updates will resume in the next cycle. This strategy allows for normal EWMA updates during periods of abnormal echoes. The observation weights automatically decrease by 60%–80%, while maintaining the optimal gain during normal periods.
[0085] Furthermore, a level-volume discrete table (VCM) is constructed through factory calibration, and the corresponding remaining volume mapping is selected based on the VCM. The construction process of the level-volume discrete table involves using a Coriolis mass flow meter with ±0.1% accuracy as the volume reference under a steady-state environment at a standard temperature of 20℃, and verifying the mass-volume conversion with the assistance of an electronic scale (density corrected to 0.845 g / cm³ diesel). Recording is performed every 0.5L injected until the liquid level reaches 5 mm above the geometrically highest point of the tank, resulting in N sets of data. Initial points. Preprocessing of the initial points includes bubble removal and two calibrations: static and dynamic. Recording is paused when the flow rate exceeds 5 L / min during bubble removal. The liquid surface sloshing is calibrated twice, statically and dynamically. Static points are used to generate the main table, and dynamic points are used for later EKF sloshing model parameter fitting. The process of generating the level-volume discrete table involves calibrating the initial points at 1 mm intervals. After performing monotonicity verification, resampling using "conformal piecewise cubic Hermite interpolation (PCHIP)" yields the discrete table of liquid level and volume. ,in The generated level-volume discrete table has been guaranteed. Furthermore, the curvature is continuous, which can avoid the Runge phenomenon.
[0086] The optimal liquid level estimate can then be found by consulting the liquid level-volume discrete table (VCM). Quickly calculate the corresponding optimal remaining volume value Specifically, it also includes the following steps:
[0087] Step 4.1: Round down the optimal liquid level estimate to create an index and calculate the locally normalized decimal.
[0088] Step 4.2: In the offline stage, the liquid level-volume discrete table is divided into segments of four points, and four Hermite interpolation parameters are stored according to the volume-liquid level mapping table.
[0089] Step 4.3: Calculate the optimal residual volume using Hermite interpolation parameters combined with predefined Hermite basis functions;
[0090] Step 4.4: Linearly map the optimal remaining volume value to an integer value and send it to other control devices via the CAN bus in CAN format.
[0091] Specifically, the above steps construct a liquid level-volume discrete table with an interval of 1 mm. Total +1 decision point. The optimal liquid level estimate will be used. The index is created by rounding down to the nearest integer, and locally normalized decimals are calculated. The index creation is represented as follows: Then perform local normalization of the decimal. ,and In the offline phase, the liquid level-volume discrete table (VCM) was divided into segments of four decision points to ensure the monotonicity of each segment. The function values at both endpoints were then used. and derivative value It stores four Hermite interpolation parameters, represented as , , and The Flash storage space it occupies is Bytes. Specifically, , , , , where the interval length . Indicates the starting volume. Indicates the final volume. This represents the scaled starting derivative. This represents the scaled terminal derivative. The segment number is... This indicates that by using the index Divide by 3 to calculate the segment number and round down; this is the segment number to which the point belongs. The offset within the segment is... This indicates that by using the index The modulo-3 operation is used to calculate the intra-segment offset, which is the offset of the point within its segment. The coefficient address pointer is... This defines a coefficient address pointer that points to the array at index 0. The elements are used for subsequent operations on the response segment coefficients. Then, Hermite estimation is performed three times within each segment; here, we use four Hermite basis functions to achieve the optimal residual volume value. The estimate is expressed as:
[0092] ;
[0093] ;
[0094] ;
[0095] ;
[0096] ;
[0097] For a given optimal liquid level estimate Locate the corresponding segment, extract the Hermite interpolation parameters, and calculate the optimal residual volume using predefined Hermite basis functions. Optimal residual volume. The estimated computational complexity is 7 floating-point multiplications and 6 additions, with a time consumption of less than 1.8 µs. Additionally, if the fuel tank has a "T"-shaped compartment or a stepped bottom, a multi-segment level-volume discrete table is pre-established. Sub-table, and through the optimal liquid level estimate Find the sub-table number in the "Compartment Boundary Table", and then perform steps 4.2 and 4.3 to ensure that the full-range error is less than 1%.
[0098] Finally, a 16-bit unsigned integer is output in the form of a CAN message, ranging from 0x0000 to 0xFFFF (0 to 65535). The range mapping is represented as 0x0000 corresponding to 0 L (empty fuel tank), and 0xFFFF corresponding to... (Fuel tank at full capacity). Resolution: This indicates that if the total volume of the fuel tank is... Therefore, the resolution is approximately 0.0153 liters per step. The calculated optimal remaining volume value... A linear mapping is performed to a 16-bit integer value, which is then transmitted to other controllers via the CAN bus. The linear mapping relationship is represented as follows: The output range is between 4mA and 20mA. Taking a 60L irregularly shaped diesel tank as an example, fill with a standard volume of 30L at the 180mm level. Under static conditions... The error is −0.05L (−0.17%). During the 30 s operation of the 0.5Hz ±20 mm shaking stage, The maximum fluctuation is ±0.8 L, while the traditional moving average fluctuation is ±4.1 L. This completes the closed loop of the entire chain from "optimal liquid level estimation to remaining volume".
[0099] Finally, a dynamic threshold SLA is provided for low liquid level alarms. A low liquid level alarm is triggered when the liquid level is low. Specifically, when... and continued A low-level alarm is only triggered when the oil level is consistently low and both the sloshing intensity and the rate of change of tilt angle are below allowable values, thus reducing the false alarm rate from 5% to less than 0.3%. The input trigger signal includes the optimal EKF level estimate. Traditional static level thresholds generate numerous false alarms when the oil level is violently sloshed or the vehicle is climbing a hill. To address this, this invention proposes a dynamic threshold SLA based on EKF state variables. EKF liquid surface vertical average velocity EKF tilt angle and the differential of the tilt angle The first three terms are obtained from step 3, while the differential of the tilt angle... The output is directly from the gyroscope. A three-dimensional joint discriminant function is defined as follows:
[0100]
[0101]
[0102] }
[0103]
[0104] in, This indicates an indicator function (1 if the condition is true, 0 otherwise). This means that the value is 1 only if all conditions are met simultaneously. , This indicates the minimum safe height of the fuel tank (the liquid level corresponding to 15% of the rated volume can be found in the VCM table). , Indicates the slope of the tilt compensation ( ), Indicates the sway compensation slope ( ). Indicates the shaking speed threshold ( ), Indicates the maximum allowable steady-state tilt angle ( (Approximately equal to 8°) Indicates the maximum permissible angular velocity ( The corresponding value is approximately equal to 2. Ultimately, a low liquid level alarm is implemented through a state machine to detect whether the static liquid level is too low. If the liquid level is not too low, the corresponding input is sent to the display module and the CAN module, and the analog signal output is 4–20mA.
[0105] In this embodiment of the invention, a tank level monitoring device based on extended Kalman filtering is also included, such as... Figure 4 As shown, the system includes a sensor data acquisition module, an IMU attitude module, a control module, a power management module, an interactive display module, a CAN module, and a storage module. The sensor data acquisition module is used to acquire data from the ultrasonic level sensor and temperature sensor in real time. Specifically, the ultrasonic level sensor is fixed at the center of the bottom of the tank and transmits and receives ultrasonic waves at different times, outputting the raw Time of Flight (TOF) value (unit: seconds, resolution: 0.1 µs). Time of Flight (TOF) represents the time it takes for an ultrasonic pulse to travel from the transducer of the sensor probe to the surface of the measured liquid, and then reflect back to the sensor probe for reception. The temperature sensor is attached to the housing of the ultrasonic level sensor for real-time sound velocity compensation. The IMU attitude module consists of a three-axis accelerometer and a three-axis gyroscope, referred to as a six-axis IMU. The short-term high accuracy of the gyroscope compensates for acceleration jitter under dynamic conditions, while the long-term stability of the accelerometer corrects the integral drift of the gyroscope, for dynamically estimating the output attitude, i.e., the tilt angle. The IMU attitude module can be installed in the center of a flat area on top of the fuel tank. If there is no suitable space on top of the fuel tank, it can be installed on the upper side of the fuel tank, near the vehicle's longitudinal axis centerline. Raw data is acquired through the IMU attitude module. Its data precision is 16-bit ADC, which can provide a good signal-to-noise ratio.
[0106] The control module uses an ARM Cortex-M4 chip with a 72MHz clock speed, providing ample bandwidth for processing real-time operating systems, protocol stacks (such as Ethernet and CAN FD), GUI libraries, and complex state machines. It integrates single-cycle multiply-accumulate instructions, saturated arithmetic instructions, and SIMD instructions, resulting in a several-fold increase in efficiency for executing algorithms such as filtering, transformation, motor control, and audio encoding / decoding without increasing clock speed or power consumption. The oil tank level monitoring device in this invention is an integrated package; the sensor and main control board use a coaxial threaded structure, with an installation height ≤38 mm, compatible with φ75 mm flange holes, requiring no additional support. The power management module's input port accepts a DC voltage from 9V to 36V and outputs a stable DC voltage to power the control module. Furthermore, the power management module features reverse connection protection and surge protection, preventing internal damage when the module's positive and negative terminals are accidentally reversed, and withstanding brief periods of high voltage and large pulse current on the input line, clamping them to a safe level to protect subsequent circuits. Between the input and output terminals of the power management module, there exists a 2 kV AC-resistant barrier to ensure effective electrical isolation. An OLED touchscreen display is selected for the interactive display module, used to display and interact with real-time data information. A 128MB memory or Flash memory is used for the storage module, with an analog signal output of 4–20 mA / 0–5 V, for storing data acquired by the level-volume discrete meter (VCM), sensor data acquisition module, and IMU attitude module. The CAN module outputs the analog signals from the control module as CAN messages, which are then broadcast onto the CAN bus, enabling networking and intelligence of the device and laying the foundation for system integration and advanced functions.
[0107] Example 2
[0108] In this embodiment, taking a 5mm thick Q235 oil tank as an example, the ultrasonic sensor assembly is attached to the center of its bottom using epoxy resin damping pads to isolate 10 dB high-frequency vibration. Upon system power-on self-test, the CAN terminal resistor is checked to be 60Ω, and the liquid level-volume discrete table VCM (600 points per 1mm volume) in the Flash memory module is read. The oil tank is filled to 100%, and static calibration records are performed. and As a baseline, it runs dynamically in a 10 ms loop, acquiring raw six-axis data including TOF, temperature, and IMU, with temperature-compensated sound velocity. .calculate Call EKF to update and get , The liquid level-volume discrete table (VCM) is consulted to obtain the result. It broadcasts ID 0x18FF50E5 via CAN, with a period of 100ms. If and The SLA alarm position is set for 3 seconds. Calibration and verification are performed on a standard 6-axis oscillating stage with a sinusoidal sweep frequency of 0.1–3 Hz and an amplitude of ±20 mm. Compared with the traditional 30-point moving average, the steady-state error of the liquid level of this invention is reduced from ±8.3 mm to ±2.1 mm, and the volume error is reduced from 6.7% to 1.4%. In the 20° tilt refueling test, the volume error is only 1.1%.
[0109] Example 3
[0110] In this embodiment, for the case where the fuel tank is a "T"-shaped compartment, such as... Figure 5 As shown, "T-shaped compartment" refers to a fuel tank with a T-shaped internal structure, typically used in the design of fuel / liquid tanks in ships, large vehicles, or special equipment. This is an irregularly shaped fuel tank, which can cause nonlinear abrupt changes in the level-volume relationship. Therefore, a multi-segment level-volume discrete table needs to be pre-established. Sub-table, and through the optimal liquid level estimate The "Compartment Boundary Table" is consulted to determine the compartment to which the product belongs, and then the corresponding sub-table number is obtained. Steps 5.2 and 5.3 are then executed, which are the offline stages where the liquid level-volume discrete table (VCM) is divided into segments of four points each, and four Hermite interpolation parameters are stored in the volume-liquid level mapping table (VCM). The Hermite interpolation parameters are then used in conjunction with predefined Hermite basis functions to calculate the optimal remaining volume value to ensure that the full-range error is less than 1%.
[0111] Example 4
[0112] In this embodiment, for older fuel tank monitoring systems, the CAN signal output of this invention will cause the older fuel tank monitoring system to be unable to receive it. Therefore, we can use a jumper to set it to a 4–20 mA mode, meaning the original level gauge outputs 4–20 mA corresponding to a 0–100% fuel level height. Specifically, this invention switches to the 4–20 mA output mode via a hardware jumper, linearly mapping... 20 mA corresponds to a full tank of fuel, and 4 mA corresponds to an empty tank. Simply connect the jumper to the existing fuel tank monitoring system; no programming or debugging is required.
[0113] All technologies not described in detail in this invention are existing technologies. It should be understood that the indicated orientations or positional relationships in the description of this invention are based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the invention and simplifying the description, and are not intended to indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of this invention.
[0114] The above description is merely an explanation of some preferred embodiments of this disclosure and the technical principles employed. Those skilled in the art should understand that, in addition to the scope of the invention as described in the embodiments of this disclosure, the present invention may have other implementations. It is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described inventive concept. For example, technical solutions formed by substituting the above-described features with (but not limited to) technical features with similar functions disclosed in the embodiments of this disclosure. For those skilled in the art, any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this invention should be included within the protection scope of this invention.
Claims
1. A method for monitoring oil tank level based on extended Kalman filtering, characterized in that, Includes the following steps: Step 1: Obtain the raw time-of-flight value of the ultrasonic level sensor, the temperature output by the temperature sensor, and the raw six-axis data from the IMU module; Step 2: The original liquid level is calculated by real-time compensation of the sound velocity using the output temperature of the temperature sensor, and the tilt angle is estimated by performing tilt angle calculation. Step 3: Construct the observation vector and state vector, execute the EKF level-volume fusion algorithm, and output the optimal level estimate. Step 4: calibrate and construct a discrete table of liquid level and volume, and select the corresponding optimal remaining volume value based on the discrete table of liquid level and volume, and output it in the form of a CAN message signal; Step 5: Verify the optimal liquid level estimate and the optimal remaining volume value using a dynamic threshold threshold (SLA), and issue an alarm for low liquid level conditions. Step 6: Repeat this process to monitor the optimal liquid level estimate and the optimal remaining volume value in real time.
2. The method for monitoring oil tank level based on extended Kalman filtering according to claim 1, characterized in that: The tilt angle calculation in step 2 is as follows: first, the tilt angle is calculated by the acceleration component to achieve a preliminary estimate; then, a high-pass filter is used to extract the high-frequency part of the gyroscope signal in the IMU module, and a low-pass filter is used to extract the low-frequency part of the accelerometer signal in the IMU module; the high-frequency part and the low-frequency part are combined with the tilt angle obtained from the preliminary estimate and then filtered to obtain the fused tilt angle estimate.
3. The method for monitoring oil tank level based on extended Kalman filtering according to claim 2, characterized in that, Step 3 also includes the following steps: Step 3.1: Construct the state vector and observation vector, predict the state based on the optimal value of the state vector in the previous period, and construct the prior state. Step 3.2: Obtain the observation matrix by linearizing the prior state through the construction of an observation function; Step 3.3: Construct the observation noise covariance matrix, calculate the prior covariance matrix, and then construct the observation noise covariance matrix in combination with the observation matrix to calculate the innovation covariance matrix; Step 3.4: Calculate the Kalman gain based on the prior covariance matrix, observation matrix, and innovation covariance matrix; Step 3.5: Calculate the innovation vector to correct the predicted state, and take the first component of the updated state as the optimal liquid level estimate. Step 3.6: Update the prior covariance matrix to obtain the covariance matrix for use in the next cycle.
4. The method for monitoring oil tank level based on extended Kalman filtering according to claim 3, characterized in that: In step 4, the liquid level-volume discrete table is constructed by using a Coriolis mass flow meter as the volume reference and an electronic scale to assist in verifying the mass-volume conversion. The volume is recorded once every 0.5L is injected until the liquid level reaches the geometric highest point of the tank, resulting in multiple original points. The original points are preprocessed with static and dynamic calibration. After monotonicity verification of the original points at 1mm intervals, conformal segmented cubic Hermite interpolation resampling is used to obtain the liquid level-volume discrete table.
5. The method for monitoring oil tank level based on extended Kalman filtering according to claim 4, characterized in that, Step 4 also includes the following steps: Step 4.1: Round down the optimal liquid level estimate to establish an index and calculate the locally normalized decimal. Step 4.2: In the offline stage, the liquid level-volume discrete table is divided into segments of four points, and four Hermite interpolation parameters are stored according to the volume-liquid level mapping table. Step 4.3: Calculate the optimal residual volume using the Hermite interpolation parameters combined with predefined Hermite basis functions; Step 4.4: Linearly map the optimal remaining volume value to an integer value and send it to other control devices via the CAN bus in CAN format.
6. The method for monitoring oil tank level based on extended Kalman filtering according to claim 5, characterized in that: Following step 3, an adaptive observation noise covariance matrix update strategy is designed. First, a sliding window is used to save the most recent multiple innovations and define their innovation vectors. Then, the real-time variance of the innovation sequence is estimated based on the innovation vectors. The observation noise covariance matrix is dynamically adjusted and updated based on the real-time variance of the innovation sequence, and the Kalman gain is updated. Finally, outlier transients are accelerated to converge. If an outlier is identified, the real-time variance of the innovation sequence is instantaneously increased. Otherwise, it gradually converges back to the initial value, so that occasional abnormal measurements such as sidewall secondary echoes, bubbles, and oil splashes are automatically downweighted.
7. The method for monitoring oil tank level based on extended Kalman filtering according to claim 6, characterized in that: In step 5, an alarm is triggered for low liquid level conditions using a dynamic threshold threshold SLA. The input trigger signal includes the EKF optimal liquid level estimate obtained in step 3. EKF liquid surface vertical average velocity EKF tilt angle The tilt angle derivative directly output by the gyroscope The low liquid level alarm is achieved by defining a three-dimensional joint discrimination function combined with a state machine. The low liquid level alarm is only triggered when the static liquid level lasts for more than 3 seconds.
8. The method for monitoring oil tank level based on extended Kalman filtering according to claim 5, characterized in that: If the oil tank has a "T"-shaped compartment or a stepped bottom in step 4, a sub-table of a multi-segment liquid level-volume discrete table is pre-established. After obtaining the sub-table number by looking up the "compartment boundary table" through the optimal liquid level estimate, steps 4.2 and 4.3 are then executed.
9. The method for monitoring oil tank level based on extended Kalman filtering according to claim 5, characterized in that: The CAN signal can be directly connected to the existing fuel tank monitoring system via a jumper and set to 4–20 mA mode. The optimal remaining volume value is linearly mapped so that 20 mA corresponds to a full tank of fuel and 4 mA corresponds to an empty tank of fuel.
10. A tank level monitoring device based on extended Kalman filtering, characterized in that, include: The sensor data acquisition module is used to acquire data from the ultrasonic level sensor and the temperature sensor in real time. The ultrasonic level sensor is fixed to the bottom of the oil tank, and the temperature sensor is attached to the outer shell of the ultrasonic level sensor. The IMU attitude module includes a three-axis accelerometer and a three-axis gyroscope for dynamically estimating the output tilt angle. The IMU attitude module can be installed on a flat area on top of the fuel tank. The control module is used to receive data from the sensor data acquisition module and the IMU attitude module, execute and output the real-time optimal liquid level estimate and optimal remaining volume value, and issue an alarm when the liquid level is low. The control module is connected to the CAN module and is used to output the analog signals output by the control module as CAN message signals. The control module is connected to the interactive display module, which is used to display and view relevant data information in real time and select to interact with it; The control module is connected to the power management module, which is used to supply power to the control module and clamp the entire monitoring device to a safe level; The control module is connected to the storage module and is used to store the data collected by the liquid level-volume discrete table (VCM), the sensor data acquisition module, and the IMU attitude module.