An internet of things-oriented low-power gas meter self-adaptive metering calibration method
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- 清丰县公共检验检测中心
- Filing Date
- 2026-05-29
- Publication Date
- 2026-08-07
AI Technical Summary
[0006]针对现有技术的不足,本发明提供了一种面向物联网的低功耗燃气表自适应计量校准方法,解决了现有物联网燃气表在唤醒延迟期存在流体漏计量,以及环境噪声干扰导致系统频繁无效唤醒从而增加电池功耗的问题
[0049] 1. This invention sets up a coprocessor to monitor the rate of change of pipeline pressure and triggers the microcontroller to perform error feedforward compensation. It also executes a closed-loop adjustment mechanism based on the feedforward threshold of pressure drop mutation based on the integral volume. When the pipeline pressure changes suddenly, the pressure drop difference is used to calculate the volume increment, which makes up for the non-steady-state missed measurement caused by hardware wake-up and sensor start-up delay. After identifying false triggers caused by mechanical noise, the detection benchmark is automatically corrected, avoiding the power consumption loss caused by the main control system being frequently and invalidally woken up.
Smart Images

Figure CN122524218A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of Internet of Things (IoT) gas metering technology, specifically to an adaptive metering calibration method for low-power gas meters oriented towards IoT. Background Technology
[0002] Low-power gas meters designed for the Internet of Things (IoT) are core terminal nodes in smart gas pipeline systems. These devices are equipped with gas flow measurement, data storage, and remote communication functions. To meet long-term operational needs, these gas meters are mostly powered by internal batteries and run a low-power sleep mechanism at the system's underlying layer.
[0003] The existing gas metering control logic relies on the microcontroller switching between sleep and wake-up states. In low-frequency monitoring state, the microcontroller or coprocessor detects flow data at fixed intervals. Once the detected flow value exceeds the set judgment threshold, the system generates a wake-up signal to trigger the microcontroller to enter high-frequency sampling mode to perform continuous metering operation. After the gas consumption behavior ends, it returns to low-power monitoring state to maintain the energy balance of the entire hardware system.
[0004] In practical applications, the existing working mechanism has a time lag between the hardware system waking up from sleep mode and the flow sensor stabilizing and outputting data. This response delay can lead to fluid volume leakage measurement in the early stages of non-steady-state conditions, causing overall measurement deviation. Mechanical vibrations or transient airflow fluctuations within the pipeline environment can frequently trigger wake-up logic based on fixed thresholds, causing the microcontroller to fall into a useless high-frequency sampling mode and exacerbating the consumption of internal battery power. In addition, facing continuous strong noise interference and long-term changes in the operating environment, the fixed anti-interference parameters built into traditional devices cannot match complex field conditions, and cannot control the power consumption of the entire device while ensuring detection sensitivity. Furthermore, since IoT gas meters are powered by batteries for a long time, the voltage drop at the battery end will cause gain drift in the analog front-end circuit of the flow sensor as the service life increases and extreme low temperatures in winter affect it. At the same time, gas temperature and pressure fluctuations in the actual pipeline environment will also directly change the gas density. Traditional metering control logic usually ignores the effects of the coupling of the above electrical and physical parameters, resulting in significant metering drift errors under complex operating conditions.
[0005] Therefore, the purpose of this invention is to provide an adaptive metering calibration method for low-power gas meters for the Internet of Things, in order to overcome the shortcomings of the prior art. Summary of the Invention
[0006] To address the shortcomings of existing technologies, this invention provides an adaptive metering calibration method for low-power gas meters for the Internet of Things (IoT). This method solves the problems of fluid leakage during the wake-up delay period and increased battery power consumption caused by frequent invalid wake-ups due to environmental noise interference in existing IoT gas meters.
[0007] To achieve the above objectives, the present invention provides the following technical solution:
[0008] This invention provides an adaptive metering calibration method for low-power gas meters for the Internet of Things, comprising the following steps:
[0009] The coprocessor drives the pressure sensor to collect gas pipeline pressure data in low-frequency monitoring mode and calculates the time-domain rate of change of the gas pipeline pressure data.
[0010] When the calculated rate of change in the time domain is greater than the set voltage drop abrupt change feedforward threshold, the coprocessor outputs a hardware interrupt signal to trigger the microcontroller to switch to high-frequency sampling mode.
[0011] The microcontroller drives the flow sensor to acquire instantaneous flow data, and uses the gas pipeline pressure data at the moment of the hardware interrupt signal trigger to perform error feedforward compensation to obtain transient compensation volume.
[0012] The microcontroller performs discrete integration on the acquired instantaneous flow data to obtain the actual gas consumption volume within a preset verification time, and compares the actual gas consumption volume within the verification time with a set effective judgment threshold.
[0013] When the actual gas consumption volume within the verification time is less than or equal to the set effective judgment threshold, the microcontroller performs closed-loop adjustment on the set pressure drop sudden change feedforward threshold.
[0014] This invention utilizes a coprocessor to monitor changes in pipeline pressure during sleep mode, constructing a pre-sensing mechanism independent of the flow sensor. When a sudden change occurs in the pipeline pressure, the microcontroller is woken up in advance, and volume compensation is performed using the pressure drop difference, eliminating measurement errors caused by hardware warm-up and sensor response delays.
[0015] By integrating and verifying the actual traffic after wake-up, the system can proactively identify false triggering events caused by environmental mechanical noise, and perform closed-loop adjustment on the feedforward detection benchmark based on the judgment result, thereby reducing the power consumption loss caused by the system falling into high-frequency invalid wake-up while maintaining high sensitivity.
[0016] Preferably, the step of calculating the time-domain rate of change of the gas pipeline network pressure data specifically includes:
[0017] The coprocessor calls a moving average filter to perform discrete smoothing calculations on the acquired gas pipeline pressure data to obtain smoothed pressure values.
[0018] The coprocessor extracts the smoothing filter pressure value of the current sampling period and the smoothing filter pressure value of the previous adjacent sampling period, and calculates the absolute value of the difference between the smoothing filter pressure value of the current sampling period and the smoothing filter pressure value of the previous adjacent sampling period.
[0019] The coprocessor divides the absolute value of the difference by a set sampling interval to obtain the time-domain rate of change of the gas pipeline pressure data.
[0020] Preferably, the step of using the gas pipeline pressure data at the moment of the hardware interrupt signal trigger to perform error feedforward compensation and obtain the transient compensation volume specifically includes:
[0021] The microcontroller extracts the smoothing filter pressure value of the current sampling period corresponding to the trigger time of the hardware interrupt signal, as well as the smoothing filter pressure value of the previous adjacent sampling period.
[0022] The microcontroller calculates the difference between the smoothing filter pressure value of the previous adjacent sampling period and the smoothing filter pressure value of the current sampling period as the initial voltage drop difference value.
[0023] The microcontroller multiplies the initial pressure drop difference by a set volume conversion factor to obtain the transient compensation volume, and accumulates the transient compensation volume in the total standard volume register inside the microcontroller. The aforementioned steps map the pressure drop gradient detected by the sensor into a fluid volume increment through a physical volume conversion relationship, thereby filling in the missing measurement data during the non-steady-state phase.
[0024] Preferably, the step of the microcontroller performing closed-loop adjustment on the set voltage drop abrupt change feedforward threshold specifically includes:
[0025] If the actual gas consumption volume within the verification time is less than or equal to the set valid judgment threshold, the microcontroller controls the pre-allocated invalid wake-up counter inside the microcontroller to perform an increment operation;
[0026] If the incremented value of the invalid wake-up counter is less than or equal to the set number of deadlock trigger tolerances, the microcontroller reads the current value of the set voltage drop mutation feedforward threshold and adds the current value to the set threshold adjustment step size to obtain the updated feedforward threshold.
[0027] The microcontroller compares the updated feedforward threshold with the set upper limit of the feedforward threshold, and obtains the final write value based on the comparison result to overwrite the set voltage drop mutation feedforward threshold.
[0028] Preferably, the step of the microcontroller performing closed-loop adjustment on the set voltage drop abrupt change feedforward threshold further includes:
[0029] When the incremented invalid wake-up counter value exceeds the set deadlock trigger tolerance number, the microcontroller triggers an abnormal interrupt and executes a preset time window exponential backoff procedure; the microcontroller uses the exponential backoff algorithm to calculate the backoff masking time and compares the backoff masking time with the set maximum masking time threshold to determine the actual backoff masking time executed.
[0030] The microcontroller activates its internal exponential backoff masking timer and sends a latching control command to the coprocessor via a preset internal integrated circuit bus. This activates the backoff masking flag within the coprocessor, blocking the path for the hardware interrupt signal to be output to the microcontroller. This step, through an exponentially extended sleep masking window, cuts off the wake-up path from persistent high-noise environments, reducing battery consumption.
[0031] Preferably, while the backoff shielding flag is active to block the output of the hardware interrupt signal, the method further includes:
[0032] When the instantaneous flow data output by the flow sensor is greater than the set high-frequency trigger flow threshold, the coprocessor sends a forced wake-up signal to the microcontroller via the spare wake-up pin through the parallel bypass detection logic configured inside the coprocessor.
[0033] After responding to the forced wake-up signal, the microcontroller forcibly terminates the exponential backoff mask timer, clears the value of the invalid wake-up counter to zero, and switches back to the high-frequency sampling mode.
[0034] Preferably, after the microcontroller performs discrete integral calculations on the acquired instantaneous flow data to obtain the actual gas consumption volume within the verification time, it further includes performing comprehensive compensation calculations coupling electrical and physical parameters, specifically including:
[0035] The microcontroller obtains the uncompensated basic gas volume by accumulating the transient compensation volume and the actual gas consumption volume within the verification time, and simultaneously obtains the real-time battery voltage, real-time pipeline absolute pressure, and real-time gas absolute temperature.
[0036] The microcontroller uses a set voltage drift compensation coefficient to linearly calibrate the electrical error of the flow sensor, and calculates the physical parameters such as the real-time pipeline absolute pressure and real-time gas absolute temperature according to the ideal gas state equation to obtain the standard gas volume after comprehensive compensation.
[0037] The microcontroller adds the accumulated standard gas consumption after comprehensive compensation to the non-volatile memory inside the microcontroller to update the total accumulated gas consumption.
[0038] Preferably, after the microcontroller switches to high-frequency sampling mode and enters a preset transient time window, the process further includes:
[0039] The microcontroller calculates the fluctuation variance of multiple consecutive instantaneous flow data, and controls the switching from high-frequency sampling mode to steady-state low-frequency sampling mode when the fluctuation variance is less than the set steady-state determination threshold.
[0040] The microcontroller loads a set high-frequency trigger flow threshold and a set frequency reduction exit dead zone flow threshold to construct a flow hysteresis bandwidth. When the instantaneous flow data fluctuates within the flow hysteresis bandwidth, the state machine control logic inside the microcontroller maintains the current sampling mode. The aforementioned setting utilizes an asymmetric dual-threshold interval to shield critical transitions caused by fluid pulsation, eliminating power consumption losses caused by frequent switching of the underlying state machine.
[0041] Preferably, the step of maintaining the current sampling mode unchanged by the state machine control logic inside the microcontroller further includes:
[0042] When the steady-state instantaneous flow data acquired in the steady-state low-frequency sampling mode is less than the set frequency reduction exit dead zone flow threshold for the first time, the microcontroller starts the internal delayed exit timer and loads the preset delayed exit time window value.
[0043] If, within the preset delayed exit time window, the steady-state instantaneous flow rate data remains below the set frequency reduction exit dead zone flow rate threshold, the microcontroller confirms the end of the gas consumption behavior, performs a data saving operation, and then switches from the steady-state low-frequency sampling mode back to the low-frequency monitoring state.
[0044] Preferably, the step of the microcontroller executing the time window exponential backoff procedure further includes environmental noise feature extraction and cloud parameter reconstruction:
[0045] Within a set environmental statistics period, the microcontroller extracts the backoff trigger frequency and calculates the threshold drift range through the backoff count accumulator configured inside the microcontroller, splices them together to generate an environmental feature data payload, and sends it to a remote server through the configured communication module.
[0046] The microcontroller receives a downlink command frame for parameter reconstruction generated by the remote server based on the environmental feature data payload using a preset parameter reconstruction algorithm, and extracts the updated basic backoff time and the updated threshold adjustment step size.
[0047] The microcontroller overwrites the set base backoff time constant with the updated base backoff time and overwrites the set threshold adjustment step size with the updated threshold adjustment step size to establish a closed loop for anti-interference parameter reconstruction. This step achieves adaptive replacement of local anti-interference model parameters through long-term environmental statistics and cloud interaction.
[0048] This invention provides a low-power adaptive metering calibration method for gas meters for the Internet of Things (IoT). It offers the following advantages:
[0049] 1. This invention sets up a coprocessor to monitor the rate of change of pipeline pressure and triggers the microcontroller to perform error feedforward compensation. It also executes a closed-loop adjustment mechanism based on the feedforward threshold of pressure drop mutation based on the integral volume. When the pipeline pressure changes suddenly, the pressure drop difference is used to calculate the volume increment, which makes up for the non-steady-state missed measurement caused by hardware wake-up and sensor start-up delay. After identifying false triggers caused by mechanical noise, the detection benchmark is automatically corrected, avoiding the power consumption loss caused by the main control system being frequently and invalidally woken up.
[0050] 2. This invention sets up an exponential backoff procedure with a time window and parallel bypass detection logic to cut off the hardware interrupt signal output path when the number of invalid wake-ups exceeds the limit, while maintaining the forced wake-up channel of the spare pin. By using an exponentially extended sleep shielding window, it blocks the interference wake-up of the hardware device by continuous strong external noise, reduces the invalid consumption of internal battery power, and relies on bypass monitoring logic to prevent missing real large-flow gas consumption events.
[0051] 3. This invention sets up an environmental noise feature extraction and cloud parameter reconstruction mechanism, uses a microcontroller to extract the device backoff trigger frequency and range data and upload it to a remote server, and receives updated parameters from the server. By using a closed loop of long-term feature data interaction between the device and the cloud, the basic backoff time and threshold adjustment step size of the local anti-interference algorithm are periodically overwritten, thereby improving the adaptive matching capability of IoT meters to changes in complex operating environments.
[0052] 4. This invention performs comprehensive compensation calculations by coupling electrical and physical parameters, synchronously collecting battery voltage, pipeline absolute pressure, and gas temperature in real time. It uses voltage drift compensation coefficients to correct sensor electrical errors and combines them with the ideal gas state equation for conversion, eliminating metering drift errors caused by battery aging and drops and extreme temperature and pressure changes throughout the entire life cycle of IoT gas meters, ensuring high-precision metering of total cumulative gas consumption under complex operating conditions. Attached Figure Description
[0053] Figure 1 This is a flowchart illustrating the overall process of the method of the present invention.
[0054] Figure 2 This is a system architecture diagram of the present invention;
[0055] Figure 3 This is a line graph showing the relationship between the anti-deadlock index backoff time and the number of consecutive triggers of environmental noise according to the present invention.
[0056] Figure 4 This is a bar chart comparing the relative measurement errors before and after comprehensive compensation under the combined working conditions of the present invention. Detailed Implementation
[0057] The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0058] See attached document Figure 1 With appendix Figure 2 This invention provides a low-power adaptive metering calibration system for gas meters for the Internet of Things, including a pressure sensor, a flow sensor, a coprocessor, a microcontroller, a temperature sensor, a communication module, and a power module.
[0059] Pressure sensors are used to collect gas pipeline pressure data, flow sensors are used to collect gas pipeline flow data, temperature sensors are used to collect gas temperature data, coprocessors are used to perform data filtering and interrupt determination, microcontrollers are used to perform metering compensation and status control, communication modules are used to establish data transmission links, and power modules are used to provide working power and output battery voltage status.
[0060] The power module is electrically connected to the rest of the hardware structure inside the system. The signal output terminal of the pressure sensor is connected to the signal input terminal of the coprocessor. The signal output terminal of the flow sensor is connected to the signal input terminal of the microcontroller. The signal output terminal of the temperature sensor is connected to the signal input terminal of the microcontroller. The interrupt output pin of the coprocessor is connected to the external wake-up interrupt pin of the microcontroller. The communication module is connected to the serial communication interface of the microcontroller.
[0061] See attached document Figure 1 This invention provides an adaptive metering calibration method for low-power gas meters for the Internet of Things, comprising the following steps:
[0062] After the system is powered on and reset, the microcontroller completes the system initialization operation and loads the asymmetric hysteresis state machine control parameters, the deadlock prevention mechanism backoff parameters, and the environmental model calibration parameters.
[0063] Under low flow conditions, the system enters a low-frequency monitoring state. At this time, the microcontroller enters a sleep mode, and the coprocessor drives the pressure sensor to collect gas pipeline pressure data at a set frequency. The coprocessor performs frequency domain decoupling preprocessing on the collected gas pipeline pressure data and calculates the time domain change rate of the gas pipeline pressure data.
[0064] When the calculated pressure change rate is greater than the set pressure drop abrupt change feedforward threshold, and the system is not in a backoff shielded state, the coprocessor outputs a hardware interrupt signal. The hardware interrupt signal triggers the microcontroller to exit the sleep mode and enter the high-frequency sampling mode.
[0065] After the microcontroller enters the high-frequency sampling mode, it drives the flow sensor to acquire flow data. The microcontroller uses the pressure parameter at the time of interrupt triggering to perform error feedforward compensation and performs time integration on the acquired flow data to obtain the gas volume. The microcontroller compares the gas volume with the effective judgment threshold. Based on the comparison result, the microcontroller performs step adjustment operation of the pressure drop change feedforward threshold, or activates the exponential backoff mask timer to mask the interrupt output signal of the coprocessor.
[0066] After passing through a preset transient time window, the system enters a high-flow steady-state operating condition. The microcontroller synchronously collects the flow data output by the flow sensor, the gas pipeline pressure output by the pressure sensor, the gas temperature output by the temperature sensor, and the battery voltage output by the power module. The microcontroller inputs the aforementioned gas pipeline pressure, flow data, gas temperature, and battery voltage into a multi-factor coupled error compensation model to perform calculations and generate calibrated cumulative gas volume parameters.
[0067] During steady-state metering, the microcontroller continuously monitors the calibrated flow data. When the calibrated flow rate is lower than the set threshold for exiting the dead zone and the state of maintaining the calibrated flow rate lower than the set threshold for exiting the dead zone exceeds the preset delay time window, the microcontroller performs a data saving operation, stops the high-frequency sampling mode, and switches back to the low-frequency monitoring state.
[0068] The microcontroller activates the communication module according to the set communication cycle. The microcontroller uploads local operating environment characteristic parameters to the remote server through the communication module. The microcontroller receives anti-interference reconstruction parameters sent by the remote server and updates the locally stored control thresholds and filtering parameters. After the parameter update is completed, the microcontroller shuts down the communication module.
[0069] The frequency domain decoupling preprocessing and hardware interrupt triggering process performed in the low-frequency monitoring state of this invention specifically includes the following steps:
[0070] The coprocessor periodically drives the pressure sensor according to the set sampling interval. The set sampling interval is determined by comprehensively evaluating the duration of the gas pipeline pressure drop waveform and the power consumption budget of the coprocessor. The set sampling interval is between 250ms and 500ms.
[0071] The coprocessor integrates a low-power timer and an analog-to-digital converter (ADC). The low-power timer runs continuously when the microcontroller is in sleep mode. When the low-power timer reaches the set sampling interval, it outputs a trigger level to the ADC. After receiving the trigger level, the ADC samples the analog voltage signal output by the pressure sensor. The ADC then stores the converted raw absolute pressure data of the pipeline network into the circular data buffer inside the coprocessor.
[0072] The coprocessor reads the raw absolute pressure data of the pipeline network from the circular data buffer and performs frequency domain decoupling preprocessing on the raw absolute pressure data of the pipeline network. Specifically, the frequency domain decoupling preprocessing refers to the coprocessor using a digital filtering algorithm to filter out the high-frequency noise components caused by mechanical vibration of the gas pipeline network, while retaining the low-frequency slowly changing pressure drop waveform components caused by the opening of the gas valve. For the physical source characteristics of the high-frequency noise components of the gas pipeline network and the specific setting principles of the cutoff frequency of the digital filtering algorithm, those skilled in the art can perform conventional environmental waveform measurement and operating parameter configuration based on the actual pipeline network material size and deployment environment.
[0073] The specific logic of the coprocessor performing frequency domain decoupling preprocessing involves calling a moving average filter to perform discrete smoothing operations on the raw absolute pressure data of the pipeline network. The discrete domain calculation formula for the moving average filter is as follows:
[0074] ;
[0075] in, For the first The smoothing filter pressure value for each sampling period; The set filter window length is calculated based on the expected high-frequency noise frequency in the gas pipeline network and the set sampling interval. The filter window length is an integer from 4 to 8. For the first time in history The original absolute pressure value of the pipeline network for each sampling period; This is the discrete time series index number for the current sampling period; As a delay period variable in the sliding calculation process, the coprocessor stores the obtained smoothing filter pressure value into the specified calculation result register.
[0076] The coprocessor calculates the time-domain rate of change of the pipeline pressure data based on the smoothed filter pressure value. The coprocessor extracts the smoothed filter pressure value of the current sampling period and the smoothed filter pressure value of the previous adjacent sampling period. The coprocessor calculates the absolute value of the difference between the smoothed filter pressure value of the current sampling period and the smoothed filter pressure value of the previous adjacent sampling period. The coprocessor divides the absolute value of the aforementioned difference by the set sampling interval to obtain the time-domain rate of change of the pipeline pressure data.
[0077] The coprocessor compares the time-domain rate of change of the pipeline pressure data with the set pressure drop abrupt change feedforward threshold. The initial value of the set pressure drop abrupt change feedforward threshold is pre-written into the non-volatile memory inside the microcontroller. During the system power-on initialization phase, the microcontroller loads the initial value into the comparison register inside the coprocessor. The initial value of the set pressure drop abrupt change feedforward threshold is determined by offline extraction and statistical analysis of the average pressure drop slope per unit time under the standard opening conditions of the same type of gas valve.
[0078] When the time-domain change rate of the pipeline pressure data is greater than the set pressure drop abrupt change feedforward threshold, and the backoff shielding flag bit inside the coprocessor is inactive, the output level of the external wake-up interrupt pin controlled by the coprocessor is flipped. The coprocessor outputs a hardware interrupt signal to the microcontroller through the external wake-up interrupt pin. After the microcontroller captures the hardware interrupt signal, it forcibly terminates the sleep state and starts the main frequency clock source.
[0079] The micro-voltage drop derivative calculation and feedforward wake-up logic of this invention specifically includes the following steps:
[0080] The coprocessor performs discrete difference operations using the smoothed filtered pressure values from adjacent sampling periods to calculate the time-domain rate of change of the pipeline pressure data. The formula for calculating the time-domain rate of change of the pipeline pressure data is as follows:
[0081] ;
[0082] in, This represents the time-domain rate of change of the pipeline pressure data for the current sampling period; For the first The smoothing filter pressure value for each sampling period; This is the smoothing filter pressure value of the previous adjacent sampling period; To set the sampling interval; This is the discrete time series index number for the current sampling period.
[0083] The coprocessor acquires instantaneous flow data output by the flow sensor in parallel. The coprocessor compares the instantaneous flow data with the set high-frequency trigger flow threshold. The set high-frequency trigger flow threshold is calibrated based on the minimum start-up flow characteristics of the gas terminal equipment connected to the gas meter. The set high-frequency trigger flow threshold ranges from 2 liters / hour to 5 liters / hour.
[0084] The hardware logic unit inside the coprocessor performs OR operation logic to determine the feedforward trigger condition. When the gas valve is opened, the negative pressure wave generated inside the pipeline propagates to the pressure sensor at the speed of sound. The physical propagation speed of the negative pressure wave is greater than the acceleration of the gas fluid flow in the pipeline.
[0085] The coprocessor captures negative pressure waves by detecting the time-domain change rate of pipeline pressure data, forming a feedforward triggering mechanism that is earlier in time than the flow sensor detects the actual flow change. When the time-domain change rate of pipeline pressure data is greater than the set pressure drop change feedforward threshold, or the instantaneous flow data is greater than the set high-frequency trigger flow threshold, the coprocessor determines that the feedforward triggering condition is met.
[0086] When the feedforward trigger condition is met, the coprocessor outputs a hardware interrupt signal to the microcontroller through the external wake-up interrupt pin. The interrupt controller inside the microcontroller captures the hardware interrupt signal, and the microcontroller responds to the hardware interrupt signal. The microcontroller closes the phase-locked loop control circuit of the internal main frequency clock source, so that the microcontroller switches from sleep mode to run mode.
[0087] After the microcontroller enters the running mode, it modifies the current state variables of the system state machine within the interrupt service routine. The microcontroller overwrites the current state variables of the system state machine from the low-frequency monitoring state to the high-frequency sampling state. Based on the updated high-frequency sampling state, the microcontroller outputs the high-frequency drive control timing sequence to the flow sensor, and the flow sensor enters the continuous sampling measurement mode.
[0088] The time-domain change rate of pipeline pressure data triggers the microcontroller to wake up, enabling the system to complete state machine switching and hardware circuit preheating before the gas reaches the flow sensor. For the specific code implementation of the microcontroller's interrupt vector table configuration, interrupt priority allocation, and clock tree initialization, those skilled in the art can consult the datasheet of the corresponding chip model to configure register read and write. The aforementioned register configuration methods are well-known technologies in this field.
[0089] The transient compensation and post-flow integration verification process of this invention specifically includes the following steps:
[0090] After the microcontroller responds to the hardware interrupt signal and enters the high-frequency sampling mode, the system enters a preset transient time window, the duration of which ranges from 500ms to 2000ms. Within the preset transient time window, the microcontroller performs error feedforward compensation and post-flow integration verification of actual gas consumption behavior.
[0091] The microcontroller reads the pressure data stored in the register by the coprocessor at the time of hardware interrupt triggering to perform error feedforward compensation. The microcontroller extracts the smoothed filter pressure value of the current sampling period and the smoothed filter pressure value of the previous adjacent sampling period corresponding to the time of hardware interrupt triggering. The microcontroller calculates the difference between the smoothed filter pressure value of the previous adjacent sampling period and the smoothed filter pressure value of the current sampling period. The microcontroller uses the aforementioned difference as the initial voltage drop difference value.
[0092] The microcontroller substitutes the initial pressure drop difference into the transient compensation algorithm to calculate the transient compensation volume. The transient compensation algorithm multiplies the initial pressure drop difference by a set volume conversion factor to obtain the transient compensation volume. The set volume conversion factor is pre-calibrated based on the inner diameter of the gas pipeline and the fluid density. According to the standard pipe diameter of the household gas pipeline, the set volume conversion factor ranges from 0.05°L / Pa to 0.2°L / Pa. The microcontroller accumulates the transient compensation volume into the total standard volume register inside the microcontroller to correct the leakage measurement error caused by the response delay of the flow sensor during the transient phase of gas valve opening.
[0093] While performing error feedforward compensation, the microcontroller outputs continuous high-frequency acquisition commands to the flow sensor. The flow sensor outputs instantaneous flow data at a set high-frequency sampling time interval. The set high-frequency sampling time interval is determined based on the hardware conversion rate of the flow sensor and the system power consumption requirements, and its value ranges from 10ms to 50ms. Within a preset transient time window, the microcontroller performs discrete integration on the acquired instantaneous flow data to obtain the actual gas consumption volume within a preset verification time. The formula for calculating the actual gas consumption volume within the verification time is:
[0094] ;
[0095] in, To verify the actual gas volume consumed within the specified time; To verify the total number of high-frequency sampling points within the window, the total number of high-frequency sampling points within the window is equal to the duration of the preset transient time window divided by the high-frequency sampling time interval. For the first Instantaneous flow data acquired through sub-high frequency sampling; This is the high-frequency sampling time interval; This is the index number of the discrete sequence in the high-frequency sampling process.
[0096] After the microcontroller completes the calculation of the actual gas volume during the verification period, it compares the actual gas volume during the verification period with the set effective judgment threshold. The set effective judgment threshold is used to distinguish between real gas consumption behavior and false triggering state caused by high frequency noise of gas pipeline. The set effective judgment threshold ranges from 0.5L to 2.0L.
[0097] When the actual gas consumption volume within the verification period is greater than the set effective judgment threshold, the microcontroller determines that the feedforward wake-up is a real and valid gas consumption event and maintains the system in high-frequency sampling mode. When the actual gas consumption volume within the verification period is less than or equal to the set effective judgment threshold, the microcontroller determines that the feedforward wake-up is an invalid wake-up caused by environmental noise. Based on the judgment result, the microcontroller calls the preset closed-loop defense adjustment program to correct the detection benchmark of the pressure sensor. For the specific underlying machine code implementation of the microcontroller's internal register addressing accumulation and floating-point multiplication and addition operations, those skilled in the art can use a standard C language compiler to compile and generate it.
[0098] The threshold adaptive closed-loop adjustment mechanism specifically includes the following steps:
[0099] The microcontroller's internal static random access memory is pre-allocated with an invalid wake-up counter and a threshold step adjustment variable. The invalid wake-up counter is used to record the number of hardware interrupts falsely triggered by environmental noise such as mechanical vibration of the gas pipeline. Based on the numerical comparison results of the transient compensation and the post-flow integral verification stage, the microcontroller performs a closed-loop update operation on the value of the invalid wake-up counter and the set pressure drop mutation feedforward threshold.
[0100] When the actual gas consumption volume within the verification period exceeds the set effective judgment threshold, the microcontroller determines that the hardware interrupt wake-up is a real and valid gas consumption event. The microcontroller performs a memory write operation to clear the current value of the invalid wake-up counter. In order to maintain the high detection sensitivity of the system in a low-noise environment, the microcontroller performs a step-down operation on the set pressure drop change feedforward threshold.
[0101] The microcontroller reads the current value of the set voltage drop mutation feedforward threshold. The microcontroller subtracts the set threshold adjustment step size from the current value of the set voltage drop mutation feedforward threshold to obtain the updated feedforward threshold. The microcontroller compares the updated feedforward threshold with the set feedforward threshold lower limit. If the updated feedforward threshold is less than the set feedforward threshold lower limit, the microcontroller uses the set feedforward threshold lower limit as the final write value; if the updated feedforward threshold is greater than or equal to the set feedforward threshold lower limit, the microcontroller uses the updated feedforward threshold as the final write value.
[0102] When the actual gas consumption volume within the verification period is less than or equal to the set effective judgment threshold, the microcontroller determines that the hardware interrupt wake-up is a false trigger event caused by environmental noise. The microcontroller increments the current value of the invalid wake-up counter by one. The microcontroller compares the incremented value of the invalid wake-up counter with the set deadlock trigger tolerance number. If the incremented value of the invalid wake-up counter is greater than the set deadlock trigger tolerance number, the microcontroller triggers an abnormal interrupt and jumps to execute the time window exponential backoff procedure to suspend the coprocessor's wake-up privileges. If the incremented value of the invalid wake-up counter is less than or equal to the set deadlock trigger tolerance number, the microcontroller performs a step-up adjustment operation on the set voltage drop change feedforward threshold to reduce the frequency of frequent false triggers caused by subsequent environmental noise.
[0103] The microcontroller reads the current value of the set voltage drop mutation feedforward threshold. The microcontroller adds the set threshold adjustment step size to the current value of the set voltage drop mutation feedforward threshold to obtain the updated feedforward threshold. The microcontroller compares the updated feedforward threshold with the set feedforward threshold upper limit. If the updated feedforward threshold is greater than the set feedforward threshold upper limit, the microcontroller uses the set feedforward threshold upper limit as the final write value; if the updated feedforward threshold is less than or equal to the set feedforward threshold upper limit, the microcontroller uses the updated feedforward threshold as the final write value.
[0104] The threshold adjustment step size is preset based on the pressure fluctuation gradient of the gas pipeline caused by common mechanical vibration noise. The threshold adjustment step size ranges from 5 Pa / s to 15 Pa / s. The lower limit of the feedforward threshold is determined based on the background thermal noise of the pressure sensor and the quantization error characteristics of the analog-to-digital conversion unit. The lower limit of the feedforward threshold ranges from 10 Pa / s to 20 Pa / s. The upper limit of the feedforward threshold is determined based on the minimum real pipeline pressure drop slope caused by the opening of a conventional gas valve. The upper limit of the feedforward threshold ranges from 80 Pa / s to 120 Pa / s.
[0105] The set number of deadlock trigger tolerances is calibrated based on the transient discharge capability of the system power module and the power consumption safety benchmark of the microcontroller. The set number of deadlock trigger tolerances is 3 to 5 times. The specific parameter range can avoid excessive divergence of the set voltage drop change feedforward threshold under extreme operating conditions.
[0106] After the microcontroller completes the calculation of the final write value, it sends a data update instruction to the coprocessor through the internal integrated circuit bus. The microcontroller writes the final write value into the comparison register inside the coprocessor to overwrite the historically set voltage drop mutation feedforward threshold. For the specific code configuration of the internal integrated circuit bus communication timing, addressing mode and data verification and confirmation mechanism between the microcontroller and the coprocessor, those skilled in the art can use the standard internal integrated circuit bus protocol specification for engineering implementation.
[0107] The time window exponential backoff and deadlock prevention mechanism specifically includes the following steps:
[0108] When the incremented invalid wake-up counter value exceeds the set deadlock trigger tolerance number, the microcontroller determines that the system is in a deadlock risk condition due to continuous high-frequency noise interference. The microcontroller triggers a system abnormal interrupt and executes a time-window exponential backoff procedure. The microcontroller uses an exponential backoff algorithm to calculate the backoff masking time. The formula for calculating the backoff masking time is:
[0109] ;
[0110] in, To avoid the blocking time; This is the set basic retreat time constant; This is the incremented value of the invalid wake-up counter; The set number of times to prevent deadlock triggers.
[0111] The set basic backoff time constant is determined based on the continuous mechanical vibration cycle caused by conventional construction operations of gas pipelines. The set basic backoff time constant is between 10s and 30s. In order to prevent the backoff shielding time from increasing indefinitely and causing the low-power gas meter adaptive metering calibration system for the Internet of Things to be unable to respond to the actual gas demand for a long time, the microcontroller compares the backoff shielding time with the set maximum shielding time threshold.
[0112] If the backoff shielding time is greater than the set maximum shielding time threshold, the microcontroller will use the set maximum shielding time threshold as the actual backoff shielding time; if the backoff shielding time is less than or equal to the set maximum shielding time threshold, the microcontroller will use the backoff shielding time as the actual backoff shielding time. The set maximum shielding time threshold is calibrated according to the maximum response delay requirement allowed in the gas appliance safety specifications, and the set maximum shielding time threshold is between 300s and 600s.
[0113] After the microcontroller confirms the actual backoff masking time, it writes the actual backoff masking time into the overload register of the internal exponential backoff masking timer and starts the exponential backoff masking timer. At the same time, the microcontroller sends a latching control instruction to the coprocessor through the preset internal integrated circuit bus, and the microcontroller sets the backoff masking flag in the coprocessor to the active state.
[0114] While the backoff shielding flag is active, even if the time-domain change rate of the pipeline pressure data is greater than the set pressure drop abrupt change feedforward threshold, the hardware control logic inside the coprocessor will forcibly disconnect the level toggling path of the external wake-up interrupt pin, thereby blocking the path to output hardware interrupt signals to the microcontroller. This allows the microcontroller to maintain sleep mode to reduce overall power consumption and prevent the system from falling into a deadlock state due to frequent wake-ups and battery depletion.
[0115] To ensure the system still has the ability to capture real high-flow gas consumption events during the shielding period of the exponential backoff shielding timer, the coprocessor is equipped with parallel bypass detection logic. When the backoff shielding flag is active, if the instantaneous flow data output by the flow sensor exceeds the set high-frequency trigger flow threshold, the coprocessor sends a non-maskable forced wake-up signal to the microcontroller through the backup wake-up pin. After responding to the forced wake-up signal, the microcontroller forcibly stops the countdown process of the exponential backoff shielding timer, clears the value of the invalid wake-up counter to zero, and switches back to the high-frequency sampling mode to perform flow integration calculation.
[0116] When the exponential backoff mask timer inside the microcontroller counts down to zero, it generates a timer interrupt. The microcontroller responds to the timer interrupt in sleep mode and resumes operation. The microcontroller clears the backoff mask flag inside the coprocessor to an inactive state through the internal integrated circuit bus, thereby restoring the coprocessor's interrupt wake-up privileges over the microcontroller.
[0117] The microcontroller resets the invalid wake-up counter to the value obtained by subtracting 1 from the set number of deadlock trigger tolerances. By resetting the invalid wake-up counter, the system can quickly return to the normal feedforward wake-up detection state after the continuous noise environment disappears. At the same time, it can quickly trigger the next backoff when the noise is not completely eliminated. After the microcontroller completes the reset operation, it clears the timer interrupt flag and the microcontroller re-enters sleep mode.
[0118] For details regarding the specific hardware layer configuration of the clock source division factor setting of the microcontroller's internal timer, the read and write operations of the interrupt priority mask register, and the coprocessor pin multiplexing function, those skilled in the art can refer to the register programming guide provided by the relevant control chip manufacturer for code writing and debugging.
[0119] The comprehensive compensation calculation for the coupling of electrical and physical parameters in this invention specifically includes the following steps:
[0120] After completing transient compensation and post-flow integration verification, the microcontroller obtains the uncompensated basic gas volume by accumulating the transient compensation volume and the actual gas consumption volume during the verification period. Since low-power gas meters for the Internet of Things are powered by batteries for a long time, the battery voltage drops with the years of use, and the gas temperature and pipeline pressure in the actual gas supply environment fluctuate in real time.
[0121] Voltage drops can cause gain drift in the analog front-end amplifier circuit inside the flow sensor. Fluctuations in gas temperature and pressure can directly change the actual density of the gas. To eliminate the metering deviation caused by the above-mentioned parameter coupling, the microcontroller performs a comprehensive compensation calculation for the coupling of electrical and physical parameters.
[0122] The microcontroller samples the output voltage of the system power module through its internally integrated analog-to-digital converter to obtain the real-time battery voltage. The real-time battery voltage reflects the actual power supply electrical characteristics of the current hardware circuit. At the same time, the microcontroller reads the real-time absolute pressure of the pipeline network output by the pressure sensor through its internal integrated circuit bus, and reads the real-time absolute gas temperature output by the temperature measurement circuit integrated inside the flow sensor.
[0123] The floating-point arithmetic unit inside the microcontroller calls the comprehensive compensation algorithm to couple the uncompensated basic gas volume, real-time battery voltage, real-time pipeline absolute pressure, and real-time gas absolute temperature. The comprehensive compensation algorithm uses a set voltage drift compensation coefficient to linearly calibrate the electrical error of the flow sensor and converts the physical parameters according to the ideal gas law. The mathematical expression of the comprehensive compensation algorithm is as follows:
[0124] ;
[0125] in, This is the standard gas volume after comprehensive compensation; This represents the uncompensated basic gas consumption volume; The set voltage drift compensation coefficient; The set reference calibration voltage; Real-time battery voltage; This refers to the real-time absolute pressure of the pipeline network. The standard atmospheric pressure constant is set. This is the standard absolute temperature constant. This represents the real-time absolute temperature of the gas.
[0126] For each set parameter in the comprehensive compensation algorithm, the set reference calibration voltage is determined based on the output voltage of the regulated power supply during the system's factory calibration, and the set reference calibration voltage is 3.6V. The set voltage drift compensation coefficient is extracted by offline least squares fitting based on the gain deviation curve of the flow sensor under different voltage gradients, and the set voltage drift compensation coefficient is between 0.002 and 0.008.
[0127] The standard atmospheric pressure constant is determined according to the national gas metering standard, and the set value of the standard atmospheric pressure constant is 101.325 kPa. The standard absolute temperature constant is determined according to the standard operating condition reference temperature, and the set value of the standard absolute temperature constant is 293.15 K.
[0128] After the microcontroller completes the calculation of the standard gas consumption volume after comprehensive compensation, it accumulates the comprehensive compensation standard gas consumption volume into the non-volatile memory inside the microcontroller according to the set storage alignment format to update the total cumulative gas consumption.
[0129] The non-volatile memory uses ferroelectric random access memory or electrically erasable read-only memory to ensure that the measurement data is not lost when the system loses power or a hardware reset operation is triggered. For the pin configuration of the analog-to-digital conversion channel inside the microcontroller, the sampling resolution setting, and the underlying read / write driver timing logic of the non-volatile memory, those skilled in the art can refer to the datasheets provided by the relevant control chip manufacturers for conventional firmware development. The aforementioned peripheral driver and hardware communication operation methods are well-known technologies in this field.
[0130] The steady-state high-precision flow accumulation execution process specifically includes the following steps:
[0131] After the preset transient time window ends, the microcontroller continuously monitors the instantaneous flow data output by the flow sensor. The microcontroller calculates the fluctuation variance of multiple consecutive instantaneous flow data. When the fluctuation variance of multiple consecutive instantaneous flow data is less than the set steady-state judgment threshold, the microcontroller determines that the system has entered the steady-state gas consumption stage from the transient gas consumption stage. The microcontroller controls the system to switch from high-frequency sampling mode to steady-state low-frequency sampling mode. Switching to steady-state low-frequency sampling mode can reduce the operating power consumption of the microcontroller and flow sensor during long-term gas supply.
[0132] The set steady-state low-frequency sampling time interval is greater than the set high-frequency sampling time interval. The set steady-state low-frequency sampling time interval is between 500ms and 1000ms. The set steady-state judgment threshold is calibrated based on the background measurement noise of the flow sensor. The set steady-state judgment threshold is 0.01 (L / h). 2 Up to 0.05 (L / h) 2 .
[0133] During the steady-state gas consumption phase, the microcontroller acquires steady-state instantaneous flow data through the flow sensor at a set steady-state low-frequency sampling time interval. The microcontroller then uses a discrete-time integral algorithm to accumulate and calculate the steady-state instantaneous flow data to obtain the steady-state basic gas consumption volume. The formula for calculating the steady-state basic gas consumption volume is as follows:
[0134] ;
[0135] in, The volume of gas used for steady-state operation; This represents the total number of sampling points during the steady-state gas consumption phase. For the first Steady-state instantaneous flow data obtained from substeady-state low-frequency sampling; This is the set steady-state low-frequency sampling time interval; This is the index number of the discrete sequence during the steady-state low-frequency sampling process.
[0136] After obtaining the steady-state basic gas volume, the microcontroller calls the aforementioned comprehensive compensation algorithm. The microcontroller inputs the steady-state basic gas volume as the uncompensated basic gas volume into the comprehensive compensation algorithm. The microcontroller combines the real-time battery voltage, real-time pipeline absolute pressure, and real-time gas absolute temperature to calculate the steady-state standard gas volume through the comprehensive compensation algorithm.
[0137] The microcontroller accumulates the steady-state standard gas into the total standard volume register inside the microcontroller. By combining steady-state high-precision flow accumulation with electrical and physical parameter coupling compensation, the microcontroller can eliminate sensor drift error during long-term steady-state gas consumption and ensure the accuracy of total cumulative gas consumption measurement.
[0138] During the steady-state high-precision flow accumulation process, the microcontroller monitors the steady-state instantaneous flow data in real time. When the steady-state instantaneous flow data is found to be less than the set frequency reduction exit dead zone flow threshold, the microcontroller triggers and starts the dual-threshold physical dead zone and state machine degradation judgment logic to confirm whether the actual gas consumption behavior has ended.
[0139] For the specific underlying driver timing logic of the microcontroller's internal multi-task scheduling mechanism, floating-point precision truncation processing, and flow sensor analog-to-digital conversion interface, those skilled in the art can refer to the corresponding microcontroller's hardware reference manual for conventional code writing.
[0140] The microcontroller's internal non-volatile memory is pre-configured with a set high-frequency trigger flow threshold and a set frequency reduction exit dead zone flow threshold. During the system initialization phase, the microcontroller loads the set high-frequency trigger flow threshold and the set frequency reduction exit dead zone flow threshold into its internal static random access memory to construct an asymmetric hysteresis debouncing mechanism. The set high-frequency trigger flow threshold is used to determine whether the system needs to switch from sleep mode to running mode and start high-frequency sampling. The set frequency reduction exit dead zone flow threshold is used to determine whether the system meets the flow conditions for stopping the current metering mode and switching back to sleep mode.
[0141] To achieve stable state switching, the high-frequency trigger traffic threshold is set to be greater than the set frequency reduction exit dead zone traffic threshold through parameter constraints. The difference between the two constitutes a traffic hysteresis bandwidth, i.e., the physical dead zone. The mathematical expression for the traffic hysteresis bandwidth is as follows:
[0142] ;
[0143] in: For traffic hysteresis bandwidth; The set high-frequency triggering traffic threshold; The threshold for the frequency reduction exit dead zone is set.
[0144] By establishing a flow hysteresis bandwidth, the microcontroller enables the adaptive metering calibration system for low-power gas meters geared towards the Internet of Things to maintain the current state of the system state machine when the gas flow rate is within a small fluctuation range. In a real-world gas supply network environment, when the gas valve is in a critically closed state or there is pressure disturbance at the end of the network, the fluid will produce a small pulsation phenomenon. When the instantaneous flow data output by the flow sensor fluctuates between the set high-frequency trigger flow threshold and the set frequency reduction exit dead zone flow threshold, the state machine control logic inside the microcontroller maintains the current sampling mode unchanged.
[0145] By shielding the flow over-limit signal within the dead zone, the microcontroller avoids high-frequency alternating switching between sleep mode and running mode caused by fluid pulsation, thereby eliminating the system power consumption loss and metering data fragmentation caused by repeated charging and discharging of the underlying hardware circuit.
[0146] For the parameter configuration in the dual-threshold physical dead zone, the set high-frequency trigger flow threshold is calibrated based on the minimum start-up flow characteristics of the gas terminal equipment, and the set high-frequency trigger flow threshold ranges from 2L / h to 5L / h. The set frequency reduction exit dead zone flow threshold is calibrated based on the physical superposition value of the zero-point drift extreme value of the flow sensor and the static background noise flow of the gas pipeline network, and the set frequency reduction exit dead zone flow threshold ranges from 0.5L / h to 1.5L / h. By limiting the upper limit of the set frequency reduction exit dead zone flow threshold, it is ensured that the microcontroller will only allow the subsequent degradation exit operation after the actual gas consumption behavior has completely stopped and the gas flow state in the pipeline has completely become still.
[0147] When executing mode switching judgment, the state machine control program inside the microcontroller reads the instantaneous flow data output by the flow sensor in real time. When the microcontroller is in sleep mode, if the instantaneous flow data is greater than or equal to the set high-frequency trigger flow threshold, the microcontroller responds to the wake-up event and enters the high-frequency sampling state. When the microcontroller is in running mode, if the instantaneous flow data is less than the set frequency reduction exit dead zone flow threshold, the microcontroller determines that the system initially meets the lower bound condition for exiting the metering mode and starts the subsequent delayed confirmation logic.
[0148] For the enumeration type definition of the internal state machine variables of the microcontroller, the clock enable configuration of the comparator module, and the data addressing and reading operation logic of the static random access memory, those skilled in the art can refer to the underlying firmware programming manual of the corresponding microcontroller chip for register bit band configuration.
[0149] When the microcontroller detects that the steady-state instantaneous flow rate data is lower than the set dead zone exit flow rate threshold for the first time during steady-state metering, the microcontroller does not immediately perform state degradation operation. Instead, it activates a delayed time window judgment mechanism. The delayed time window judgment mechanism aims to further confirm whether the gas consumption behavior has truly and stably ended, thereby filtering out the false signals of temporary flow rate drop caused by instantaneous fluctuations in pipeline pressure or vibrations of gas appliance valves near the critical point, and preventing the system state machine from oscillating frequently switching at the fluid critical point.
[0150] The specific implementation logic of the microcontroller is as follows: when the steady-state instantaneous flow data is triggered by crossing the set frequency reduction exit dead zone flow threshold, the microcontroller initializes and starts the internal hardware timer as a delayed exit timer. The microcontroller loads the preset delayed exit time window value into the overload register of the delayed exit timer. The preset delayed exit time window value is determined based on the physical statistical characteristics of the fluid pulsation cycle in a typical gas pipeline network. The preset delayed exit time window value is 2s to 5s.
[0151] During the countdown of the delayed exit timer, the microcontroller continues to acquire flow data and perform comprehensive compensation calculations in steady-state low-frequency sampling mode. The microcontroller compares and monitors the calibrated flow obtained from each sampling within the preset delayed exit time window.
[0152] If, at any sampling moment before the end of the preset delayed exit time window, the steady-state instantaneous flow rate data rebounds and is greater than or equal to the set frequency reduction exit dead zone flow rate threshold, the microcontroller determines that this flow rate drop is a temporary fluid pulsation. In response to the determination result, the microcontroller immediately writes a reset instruction to the control register of the delayed exit timer. The microcontroller clears the current count value of the delayed exit timer and turns off the delayed exit timer. The microcontroller maintains the current operating mode and continues to perform the flow accumulation operation.
[0153] Only when the steady-state instantaneous flow rate data remains below the set frequency reduction exit dead zone flow rate threshold throughout the entire preset delay exit time window, until the delay exit timer counts down and generates a timer interrupt, will the microcontroller confirm that the gas consumption behavior has ended.
[0154] After responding to the interrupt signal of the delayed exit timer, the microcontroller executes the state machine degradation control program and performs a data saving operation. The microcontroller writes the total cumulative gas consumption and operating status log currently cached in memory to its internal non-volatile memory. After the data saving operation is complete, the microcontroller stops outputting drive control timing to the flow sensor, updates its internal state machine variables, switches the current state variable of the system state machine from operating mode back to low-frequency monitoring mode, shuts down the main frequency clock source and related peripheral modules, and enters sleep mode. The coprocessor maintains the low-frequency monitoring state, waiting for the next feedforward wake-up condition to be triggered.
[0155] For the selection of clock sources, configuration of frequency division coefficients, writing of interrupt service routines, and control of the erase and write timing of non-volatile memory for the internal timers of microcontrollers, those skilled in the art can refer to the official technical manual of the corresponding chip model for standardized firmware development.
[0156] The microcontroller's internal real-time clock module maintains the system's absolute time. The microcontroller uses this real-time clock to define a set environmental statistics period, which is used to periodically extract features of the underlying environmental noise of the gas pipeline network. The set environmental statistics period ranges from 24 hours to 168 hours. Within this set period, the microcontroller extracts and records in real-time in its local memory the backoff trigger frequency (reflecting the intensity of the underlying environmental noise) and the threshold drift range (reflecting background noise fluctuations).
[0157] The microcontroller allocates a backoff count accumulator in its internal non-volatile memory. Each time the system triggers and executes the time-window exponential backoff procedure to suspend the coprocessor's wake-up privileges, the microcontroller increments the backoff count accumulator by one. When the real-time clock module's runtime reaches the set environmental statistics period, the microcontroller reads the accumulated value from the backoff count accumulator. The microcontroller uses its floating-point arithmetic unit to calculate the backoff trigger frequency. The formula for calculating the backoff trigger frequency is:
[0158] ;
[0159] in, To avoid triggering frequency; The cumulative value of the retreat count accumulator within the set environmental statistics period; The environmental statistics period is defined. The backoff trigger frequency physically quantifies the frequency at which the low-power gas meter adaptive metering calibration system for the Internet of Things encounters continuous high-frequency false triggering interference from the pipeline network.
[0160] During the execution of the threshold adaptive closed-loop adjustment mechanism, the microcontroller continuously adjusts the set voltage drop mutation feedforward threshold step by step according to the judgment result. The microcontroller synchronously configures a maximum threshold register and a minimum threshold register in non-volatile memory.
[0161] At the start of the set environmental statistics cycle, the microcontroller writes the current value of the set voltage drop mutation feedforward threshold into the maximum threshold register and the minimum threshold register, respectively, as the initial comparison benchmark for this cycle. After each update of the set voltage drop mutation feedforward threshold, the microcontroller compares the updated feedforward threshold with the values stored in the maximum threshold register and the minimum threshold register, respectively.
[0162] If the updated feedforward threshold is greater than the value stored in the maximum threshold register, the microcontroller overwrites the maximum threshold register with the updated feedforward threshold; if the updated feedforward threshold is less than the value stored in the minimum threshold register, the microcontroller overwrites the minimum threshold register with the updated feedforward threshold. When the real-time clock module's runtime reaches the set environmental statistics period, the microcontroller extracts the threshold drift range of the pipeline background noise. The formula for calculating the threshold drift range is:
[0163] ;
[0164] in, This represents the threshold drift range. The value recorded by the register for the maximum extreme value of the threshold within the set environmental statistical period; The threshold minimum extreme value register records the value within the set environmental statistical period. The threshold drift range reflects the basic fluctuation amplitude of background noise caused by factors such as mechanical vibration in the gas pipeline network at different time periods.
[0165] After the microcontroller completes the calculation of the backoff trigger frequency and the threshold drift range, it splices the backoff trigger frequency, the threshold drift range, the system's device identification serial number, and the real-time battery voltage output by the power module to generate an environmental feature data payload. The microcontroller then encapsulates the environmental feature data payload into a data packet to be sent according to the set byte alignment format.
[0166] The microcontroller controls the power enable pin of the communication module to output a high level to activate the communication module and put it into working state. The microcontroller sends a network attach command to the communication module through the serial communication interface to control the communication module to establish a wireless data transmission link with the remote server. After the data transmission link is successfully established, the microcontroller transmits the data packet to be sent to the communication module and the communication module sends it to the remote server.
[0167] After receiving the successful transmission confirmation frame from the communication module, the microcontroller clears the backoff count accumulator and reinitializes the maximum and minimum threshold registers using the currently set voltage drop jump feedforward threshold. The microcontroller then controls the power enable pin of the communication module to output a low level to shut down the communication module, and the system enters the next set environmental statistics cycle.
[0168] For the specific code implementation of the serial communication baud rate configuration between the microcontroller and the communication module, the transmission and parsing timing of the standard control instruction set, and the data packet cyclic redundancy check algorithm, those skilled in the art can refer to the software programming guides provided by the communication module manufacturer for conventional development.
[0169] After receiving the data packet to be sent uploaded by the communication module, the remote server parses the data packet and extracts the environmental feature data payload. The remote server obtains the backoff trigger frequency and threshold drift range calculated by the microcontroller within the set environmental statistical period. Based on the backoff trigger frequency and threshold drift range, the remote server calculates the underlying anti-interference parameters used to adjust the system operating state. The underlying anti-interference parameters specifically include the updated basic backoff time and the updated threshold adjustment step size.
[0170] The remote server is internally configured with a parameter reconstruction algorithm. When the backoff trigger frequency increases, it indicates the presence of high-frequency physical interference in the gas pipeline network. The remote server extends the system's sleep waiting time by increasing the basic backoff duration to reduce the number of invalid system wake-ups. When the threshold drift range increases, it indicates severe fluctuations in the pipeline network background pressure. The remote server increases the threshold adjustment step size to improve the convergence speed of the set pressure drop mutation feedforward threshold. The calculation formulas for the basic backoff duration and the threshold adjustment step size are as follows:
[0171] ;
[0172] ;
[0173] in, The updated base backoff duration; The initial value of the basic backoff time constant is set when the microcontroller is factory-fixed. The initial value of the basic backoff time constant is between 10s and 30s. This is the first reconstruction scaling factor; To avoid triggering frequency; Adjust the step size for the updated threshold; The initial value of the threshold adjustment step size is set when the microcontroller is factory-preset. The initial value of the threshold adjustment step size ranges from 5 Pa / s to 15 Pa / s. This is the second reconstruction scaling factor; This represents the threshold drift range.
[0174] The first and second reconstruction ratios are constants. The specific values of the first and second reconstruction ratios are determined by the remote server through least squares fitting based on the historical noise data of a typical gas pipeline network and the equipment sleep power consumption model. The value of the first reconstruction ratio is 0.1 to 0.5, and the value of the second reconstruction ratio is 0.05 to 0.2.
[0175] After the remote server completes the calculation, it encapsulates the updated base backoff time and the updated threshold adjustment step size into a parameter reconstruction downlink command frame according to the application layer communication protocol. The remote server then sends the parameter reconstruction downlink command frame to the communication module in the communication active state through the mobile cellular network.
[0176] The microcontroller receives the parameter reconstruction downlink command frame forwarded by the communication module through the serial communication interface. The microcontroller uses its internal logic unit to perform cyclic redundancy check on the parameter reconstruction downlink command frame. If the check result is correct, the microcontroller decomposes the parameter reconstruction downlink command frame and extracts the updated basic backoff time and the updated threshold adjustment step size.
[0177] To ensure that the reconfiguration parameters are not lost after the system is powered off or reset, the microcontroller performs a memory page erase / write operation. The microcontroller writes the updated base backoff time and the updated threshold adjustment step size into the designated anti-interference parameter configuration area of the internal non-volatile memory.
[0178] The microcontroller overwrites the system's set basic backoff time constant with the updated basic backoff time, and overwrites the system's set threshold adjustment step size with the updated threshold adjustment step size. In subsequent metering and monitoring, when the coprocessor triggers a wake-up event again, the microcontroller calls the updated anti-interference parameters to execute the exponential backoff time calculation and threshold step adjustment logic. The microcontroller and the remote server jointly establish an anti-interference parameter reconstruction closed loop for the long-term evolution of noise in the underlying pipeline network.
[0179] For the transmission control protocol and Internet Protocol stack data packet encapsulation between the remote server and the communication module, the encrypted transmission of messages at the system application layer, and the address mapping planning of non-volatile memory, those skilled in the art can consult network communication standard documents and memory datasheets for program design.
[0180] Specific application examples:
[0181] To verify the effectiveness of the proposed low-power adaptive metering calibration method for gas meters for the Internet of Things in handling high-frequency mechanical vibration noise interference in pipeline networks, extreme temperature and pressure conditions, battery aging, and other combined operating conditions, as well as the problems of frequent false wake-ups leading to battery depletion and deadlock, and metering drift errors caused by multi-dimensional physical parameter coupling, this embodiment is based on a batch upgrade and replacement application scenario of gas meters in a complex pipeline network environment of an old residential area in a certain city, and combined with the attached... Figure 3 and attached Figure 4 The data shown will be explained in detail.
[0182] Appendix Figure 3 and attached Figure 4 The data in this paper are all data characteristics obtained by real-time collection and calculation during the actual operation of the pipeline network, and are compared with traditional data without adaptive backoff and multi-source parameter comprehensive compensation mechanism.
[0183] In this application scenario, the low-power gas meter for the Internet of Things is deployed in a ground-floor apartment near a road construction site. The system is subjected to long-term, intense vibrations from heavy machinery. Simultaneously, due to the onset of winter, the pipeline ambient temperature drops significantly, and the battery voltage decreases due to low temperature and aging. The goal is to enable the system to filter high-frequency noise wake-up and output a high-precision standard gas volume without sacrificing sensitivity in capturing real gas consumption events.
[0184] Micro-voltage drop derivative calculation and feedforward wake-up control implementation: When the system is in low-frequency monitoring state, the coprocessor performs sampling at a set interval. (i.e., every 250ms) the pipeline pressure is collected. During monitoring, the coprocessor's internal loop data buffer records the smoothed and filtered pressure value from the previous adjacent sampling period. The smoothing filter pressure value of the current sampling period The system calculates the rate of change of pipeline pressure data based on the following formula: The time-domain change rate of pipeline pressure in the current sampling period is calculated. .
[0185] At this point, the preset voltage drop surge feedforward threshold inside the microcontroller is 50 Pa / s, due to the calculated... Furthermore, the system was not in a backoff shielded state. The coprocessor accurately captured the front negative voltage wave and immediately flipped the level of the external wake-up interrupt pin. The microcontroller responded to the interrupt and entered the high-frequency sampling mode in advance, reserving a hardware warm-up time window for subsequent real traffic verification.
[0186] Time window exponential backoff and deadlock prevention implementation: After the above wake-up, the microcontroller enters high-frequency sampling and performs post-flow integration verification. If the actual gas volume... If the value is less than the set effective threshold of 0.5L, it is determined to be a false trigger caused by construction vibration, and the system control will ineffectively wake up the counter. To verify the effectiveness of the deadlock prevention backoff mechanism, incremental operations were performed, and the system's backoff response parameters under continuous high-frequency construction noise were extracted.
[0187] Actual conditions: The basic backoff time constant is preset at the factory of the microcontroller. The set number of deadlock trigger tolerances The maximum shielding time threshold is set to 300 seconds.
[0188] Data analysis: combined with appendix Figure 3 From the characteristic curve, we can see that, Figure 3 The middle horizontal axis represents the number of consecutive invalid wake-up triggers. (times), the vertical axis represents the actual backoff and shielding time (seconds), when the system just encounters noise, The system does not trigger suspension when continuous false triggers occur. At that time, the system calls the formula for calculating the backoff shielding time: The backoff shielding time was calculated. At this point, the coprocessor is forcibly suspended for 20 seconds, preventing it from waking up.
[0189] As mechanical vibration continues, when When the number of times reaches 6 and 7 respectively, the backoff shielding time increases exponentially, calculated to be 10.2. 6-3 =80s and 10.2 7-3 =160s, such as Figure 3 As shown by the dark gray curve, the present invention employs an exponential backoff algorithm, which enables the system to quickly open the hibernation shielding window when faced with continuous and severe background noise, thereby reducing the frequency of invalid wake-up of the microcontroller.
[0190] when When the calculated theoretical backoff time is 320s, which is greater than the set maximum shielding time threshold of 300s, the microcontroller forcibly truncates and clamps the backoff time to 300s (e.g., Figure 3 The flat-top segment data ensures that the system will not fall into permanent deadlock under extreme noise, and still retains the macroscopic response capability to real large-flow gas consumption events. Compared with the traditional linear backoff scheme (light gray solid line), this scheme has good advantages in deadlock defense response speed and power consumption control.
[0191] Implementation of integrated compensation calculation for electrical and physical parameter coupling: After the system eliminates interference and enters the steady-state high-flow gas consumption stage, parameter coupling compensation is implemented to solve the metering inaccuracies caused by battery drops and severe cold weather.
[0192] Actual conditions: Real-time battery voltage sampled by the microcontroller's analog-to-digital converter unit under winter operating conditions. (Severe drop), set reference calibration voltage Flow sensor voltage drift compensation coefficient Meanwhile, the real-time absolute temperature of the gas was measured internally. (Converted to 5°C), the set standard absolute temperature constant Real-time absolute pressure of the pipeline network The set standard atmospheric pressure constant Assuming the system's cumulative uncompensated basic gas consumption volume .
[0193] System call comprehensive compensation algorithm formula: The system calculates the standard gas volume after comprehensive compensation. .
[0194] Data Analysis: From Appendix Figure 4 The bar chart in the figure shows that... Figure 4 The relative metering error rates of traditional uncompensated meters and the adaptive comprehensive compensation meter of this invention were compared under three different typical application conditions (standard condition, slight disturbance condition, and extreme drop condition). Under the extreme drop condition (i.e., the winter drop scenario calculated above), without compensation, the gas meter output volume is 100L, while the actual gas mass under standard conditions corresponds to a volume as high as 107.86L, resulting in a metering leakage error of up to -7.28% for the gas supplier (as shown in the attached figure). Figure 4 (As shown in the light gray columnar extreme values), and after adopting the comprehensive compensation mechanism of the present invention ( Figure 4 (Medium-dark gray column), the system automatically combines battery voltage and temperature and pressure parameters for correction, and accumulates the final standard volume into non-volatile memory, so that the relative error is suppressed within ±0.5%, eliminating the measurement risks caused by changes in the external operating environment and the aging of the equipment itself.
[0195] Summary of application examples:
[0196] This embodiment demonstrates the industrial-grade practicality of a low-power gas meter adaptive metering calibration system and method for the Internet of Things (IoT). On one hand, by calculating the pressure time-domain change rate and exponential backoff shielding time, it captures micro-pressure drop signals and uses a nonlinear decay model to isolate environmental mechanical vibrations, thus solving the power overload problem caused by frequent alternation of sleep modes. On the other hand, it deeply integrates electrical drift with the ideal gas state equation using a multi-factor coupling formula, ensuring high metering accuracy throughout the entire lifecycle of IoT meters (especially in the low-pressure state of the battery at the end), providing highly reliable underlying data support for the digital and refined operation of gas pipeline networks.
Claims
1. A low-power adaptive metering calibration method for gas meters for the Internet of Things, characterized in that, Includes the following steps: The coprocessor drives the pressure sensor to collect gas pipeline pressure data in low-frequency monitoring mode and calculates the time-domain rate of change of the gas pipeline pressure data. When the calculated rate of change in the time domain is greater than the set voltage drop abrupt change feedforward threshold, the coprocessor outputs a hardware interrupt signal to trigger the microcontroller to switch to high-frequency sampling mode. The microcontroller drives the flow sensor to acquire instantaneous flow data, and uses the gas pipeline pressure data at the moment of the hardware interrupt signal trigger to perform error feedforward compensation to obtain transient compensation volume. The microcontroller performs discrete integration on the acquired instantaneous flow data to obtain the actual gas consumption volume within a preset verification time, and compares the actual gas consumption volume within the verification time with a set effective judgment threshold. When the actual gas consumption volume within the verification time is less than or equal to the set effective judgment threshold, the microcontroller performs closed-loop adjustment on the set pressure drop sudden change feedforward threshold.
2. The adaptive metering calibration method for low-power gas meters for the Internet of Things according to claim 1, characterized in that, The step of calculating the time-domain rate of change of the gas pipeline network pressure data specifically includes: The coprocessor calls a moving average filter to perform discrete smoothing calculations on the acquired gas pipeline pressure data to obtain smoothed and filtered pressure values. The coprocessor extracts the smoothing filter pressure value of the current sampling period and the smoothing filter pressure value of the previous adjacent sampling period, and calculates the absolute value of the difference between the smoothing filter pressure value of the current sampling period and the smoothing filter pressure value of the previous adjacent sampling period. The coprocessor divides the absolute value of the difference by a set sampling interval to obtain the time-domain rate of change of the gas pipeline pressure data.
3. The adaptive metering calibration method for a low-power gas meter for the Internet of Things according to claim 2, characterized in that, The steps for obtaining transient compensation volume by performing error feedforward compensation using the gas pipeline pressure data triggered by the hardware interrupt signal specifically include: The microcontroller extracts the smoothing filter pressure value of the current sampling period corresponding to the trigger time of the hardware interrupt signal, as well as the smoothing filter pressure value of the previous adjacent sampling period. The microcontroller calculates the difference between the smoothing filter pressure value of the previous adjacent sampling period and the smoothing filter pressure value of the current sampling period as the initial voltage drop difference value. The microcontroller multiplies the initial voltage drop difference with a set volume conversion factor to obtain the transient compensation volume, and accumulates the transient compensation volume in the total standard volume register inside the microcontroller.
4. The adaptive metering calibration method for a low-power gas meter for the Internet of Things according to claim 1, characterized in that, The specific steps of the microcontroller performing closed-loop adjustment on the set voltage drop abrupt change feedforward threshold include: If the actual gas consumption volume within the verification time is less than or equal to the set valid judgment threshold, the microcontroller controls the pre-allocated invalid wake-up counter inside the microcontroller to perform an increment operation; If the incremented value of the invalid wake-up counter is less than or equal to the set number of deadlock trigger tolerances, the microcontroller reads the current value of the set voltage drop mutation feedforward threshold and adds the current value to the set threshold adjustment step size to obtain the updated feedforward threshold. The microcontroller compares the updated feedforward threshold with the set upper limit of the feedforward threshold, and obtains the final write value based on the comparison result to overwrite the set voltage drop mutation feedforward threshold.
5. The adaptive metering calibration method for a low-power gas meter for the Internet of Things according to claim 4, characterized in that, The step of the microcontroller performing closed-loop adjustment on the set voltage drop abrupt change feedforward threshold further includes: When the incremented invalid wake-up counter value exceeds the set deadlock trigger tolerance number, the microcontroller triggers an abnormal interrupt and executes a preset time window exponential backoff procedure. The microcontroller uses an exponential backoff algorithm to calculate the backoff shielding time and compares the backoff shielding time with a set maximum shielding time threshold to determine the actual backoff shielding time. The microcontroller starts the exponential backoff mask timer inside the microcontroller and sends a latching control instruction to the coprocessor through a preset internal integrated circuit bus to activate the backoff mask flag inside the coprocessor, thereby blocking the path to output the hardware interrupt signal to the microcontroller.
6. The adaptive metering calibration method for a low-power gas meter for the Internet of Things according to claim 5, characterized in that, During the period when the backoff shielding flag is active to block the output of the hardware interrupt signal, the following is also included: When the instantaneous flow data output by the flow sensor is greater than the set high-frequency trigger flow threshold, the coprocessor sends a forced wake-up signal to the microcontroller via the spare wake-up pin through the parallel bypass detection logic configured inside the coprocessor. After responding to the forced wake-up signal, the microcontroller forcibly terminates the exponential backoff mask timer, clears the value of the invalid wake-up counter to zero, and switches back to the high-frequency sampling mode.
7. The adaptive metering calibration method for a low-power gas meter for the Internet of Things according to claim 1, characterized in that, After the microcontroller performs discrete integral calculations on the acquired instantaneous flow data to obtain the actual gas consumption volume within the verification time, it also performs comprehensive compensation calculations coupling electrical and physical parameters, specifically including: The microcontroller obtains the uncompensated basic gas volume by accumulating the transient compensation volume and the actual gas consumption volume within the verification time, and simultaneously obtains the real-time battery voltage, real-time pipeline absolute pressure, and real-time gas absolute temperature. The microcontroller uses a set voltage drift compensation coefficient to linearly calibrate the electrical error of the flow sensor, and calculates the physical parameters such as the real-time pipeline absolute pressure and real-time gas absolute temperature according to the ideal gas state equation to obtain the standard gas volume after comprehensive compensation. The microcontroller adds the accumulated standard gas consumption after comprehensive compensation to the non-volatile memory inside the microcontroller to update the total accumulated gas consumption.
8. The adaptive metering calibration method for a low-power gas meter for the Internet of Things according to claim 1, characterized in that, After the microcontroller switches to high-frequency sampling mode and enters the preset transient time window, the following steps are also included: The microcontroller calculates the fluctuation variance of multiple consecutive instantaneous flow data, and controls the switching from high-frequency sampling mode to steady-state low-frequency sampling mode when the fluctuation variance is less than the set steady-state determination threshold. The microcontroller loads a set high-frequency trigger flow threshold and a set frequency reduction exit dead zone flow threshold to construct a flow hysteresis bandwidth. When the instantaneous flow data fluctuates within the flow hysteresis bandwidth, the state machine control logic inside the microcontroller maintains the current sampling mode unchanged.
9. The adaptive metering calibration method for a low-power gas meter for the Internet of Things according to claim 8, characterized in that, The steps for maintaining the current sampling mode in the state machine control logic inside the microcontroller also include: When the steady-state instantaneous flow data acquired in the steady-state low-frequency sampling mode is less than the set frequency reduction exit dead zone flow threshold for the first time, the microcontroller starts the internal delayed exit timer and loads the preset delayed exit time window value. If, within the preset delayed exit time window, the steady-state instantaneous flow rate data remains below the set frequency reduction exit dead zone flow rate threshold, the microcontroller confirms the end of the gas consumption behavior, performs a data saving operation, and then switches from the steady-state low-frequency sampling mode back to the low-frequency monitoring state.
10. The adaptive metering calibration method for a low-power gas meter for the Internet of Things according to claim 5, characterized in that, The steps of the microcontroller executing the time window exponential backoff procedure also include environmental noise feature extraction and cloud parameter reconstruction: Within a set environmental statistics period, the microcontroller extracts the backoff trigger frequency and calculates the threshold drift range through the backoff count accumulator configured inside the microcontroller, splices them together to generate an environmental feature data payload, and sends it to a remote server through the configured communication module. The microcontroller receives a downlink command frame for parameter reconstruction generated by the remote server based on the environmental feature data payload using a preset parameter reconstruction algorithm, and extracts the updated basic backoff time and the updated threshold adjustment step size. The microcontroller uses the updated base backoff time to overwrite the set base backoff time constant, and uses the updated threshold adjustment step size to overwrite the set threshold adjustment step size, so as to establish an anti-interference parameter reconstruction closed loop.