NB-IoT-based ultrasonic gas flowmeter remote data transmission system
The remote data transmission system for ultrasonic gas flow meters using NB-IoT solves the problems of metering errors and safety hazards caused by aging and tampering, and enables real-time monitoring and early warning of signal quality and equipment status, thereby improving the accuracy and safety of gas metering.
Patent Information
- Application Number
- CN202511624266.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-07
- Publication Date
- 2026-02-13
AI Technical Summary
Existing ultrasonic gas flow meters cannot provide early warnings when they are aging, scaling, or damp, leading to signal quality degradation, decreased metering accuracy, and difficulty in monitoring changes in installation posture and identifying physical tampering, resulting in metering errors and safety hazards.
An NB-IoT-based remote data transmission system for ultrasonic gas flow meters is adopted. Through a multi-source signal synchronous acquisition module, a transducer status feature analysis module, and an IoT data encapsulation and reporting module, quantitative analysis of signal amplitude, energy, and signal-to-noise ratio is achieved. Combined with a triaxial accelerometer to monitor attitude and dynamic disturbances, a device health status code is generated and the data is encrypted and transmitted.
It has enabled a shift from passive fault response to proactive early warning, monitoring for decreased metering accuracy and physical tampering, providing accurate data support for gas flow values and equipment health status, and improving gas pipeline network management and safety.
Smart Images

Figure CN121521217A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of ultrasonic gas flow meter technology, and more particularly to a remote data transmission system for ultrasonic gas flow meters based on NB-IoT. Background Technology
[0002] Ultrasonic gas flow meters are mainly based on the principle of sound waves for fluid measurement. They calculate the gas flow rate by measuring the time difference between the propagation of ultrasonic pulses in the gas medium in the downstream and upstream directions, and then convert the gas flow rate into the volumetric flow rate.
[0003] In existing ultrasonic gas flow meters, when the transducer ages due to long-term operation, develops scale on the pipe wall, or becomes damp internally, its transmission and reception efficiency gradually decreases, leading to signal quality degradation. However, before the signal is completely lost and metering is interrupted, the flow meter itself cannot issue any warning, and measurement accuracy may have already shifted imperceptibly, causing long-term, subtle metering errors that affect settlement accuracy. Furthermore, it lacks the ability to detect external physical environment and human intervention. The flow meter's installation standardization, such as levelness, relies solely on a single operation by the installer; subsequent changes in posture due to foundation settlement cannot be monitored, potentially leading to condensation buildup and equipment damage. Additionally, physical tampering such as flipping the instrument or malicious knocking is difficult to record and identify, leaving hidden dangers for gas theft and safety accountability. Therefore, improvements are needed. Summary of the Invention
[0004] The purpose of this invention is to overcome the shortcomings of existing technologies and propose a remote data transmission system for ultrasonic gas flow meters based on NB-IoT.
[0005] To achieve the above objectives, the present invention adopts the following technical solution: A remote data transmission system for ultrasonic gas flow meters based on NB-IoT includes: The multi-source signal synchronous acquisition module is used to synchronously start the ultrasonic transducer pulse emission circuit and the triaxial accelerometer data acquisition according to the internal clock of the MCU. It continuously samples the waveform of the returned signal from the receiving transducer within a preset time window, converts the analog voltage value of each sampling point into a digital quantized value, and records the static gravity component and dynamic AC component of the triaxial accelerometer to obtain the original sensing data set. The transducer status feature analysis module is used to locate the maximum value as the signal amplitude by traversing the digital quantization value sequence from the ultrasonic signal waveform according to the original sensing data set, calculate the sum of squares of all quantization values below the waveform envelope to obtain the signal energy, calculate the ratio of the signal peak value to the root mean square of the noise sample during the silent period before measurement to obtain the signal-to-noise ratio, and then compare the signal amplitude, signal energy and signal-to-noise ratio with the first-level threshold and the second-level threshold of the stored health baseline item by item to establish the transducer performance status code.
[0006] Preferably, the system further includes: The device attitude disturbance identification module is used to calculate the spatial angle between the current attitude and the zero-point attitude reference based on the original sensor data set and the transducer performance status code, using the projection of the static gravity component on the three axes, and setting an acceleration threshold. When the instantaneous impact amplitude of the dynamic AC component exceeds the acceleration threshold, the transducer performance status code under the same timestamp is retrieved. If the status code indication signal is lost, a valid associated event is determined and a physical abnormal event flag is generated. The IoT data encapsulation and reporting module is used to calculate the gas flow rate value, fill the gas flow rate value, transducer performance status code and physical abnormal event flag into the target field of the data frame in a predetermined protocol format, and attach the device unique identifier code and timestamp. The filled data frame is encrypted, and the encrypted data packet is scheduled to be sent to the gas pipeline network data center via the narrowband IoT network to establish the gas metering ciphertext to be sent.
[0007] Preferably, the multi-source signal synchronous acquisition module includes: The clock synchronization trigger submodule is used to generate a common start pulse based on the internal clock of the MCU using a timer interrupt, and simultaneously send it to the ultrasonic transducer pulse transmitting circuit and the triaxial accelerometer data acquisition unit to obtain a synchronous sampling trigger signal; The sensor signal digitization submodule is used to drive the analog-to-digital converter at a preset sampling frequency according to the synchronous sampling trigger signal, quantize the waveform of the signal returned by the receiving transducer point by point, write the converted digital quantized value into the first data buffer, and store the static gravity component and dynamic AC component readings of the triaxial accelerometer into the second data buffer to establish a discrete time-series data stream. The multidimensional data integration submodule is used to read all the data in the first data buffer and the second data buffer according to the discrete time-series data stream, mark the data set with a unified collection timestamp, and organize multiple data into a complete data packet according to a preset data structure format to obtain the original sensor data set.
[0008] Preferably, the transducer state feature parsing module includes: The signal feature parameter extraction submodule is used to obtain the signal amplitude by searching for the maximum value in the digital quantization value sequence based on the original sensing data set, squaring each value in the sequence and summing them to calculate the signal energy, extracting noise samples from the silent period before measurement to calculate the root mean square, dividing the signal peak value by the root mean square to obtain the signal-to-noise ratio, and generating a quantization feature parameter vector. The preliminary comparison submodule of the health baseline is used to compare the signal amplitude and signal-to-noise ratio in the quantized feature parameter vector with the first-level attenuation threshold and the first-level signal-to-noise ratio threshold stored in the health baseline. If any parameter is worse than the threshold, an internal flag is set to establish a first-level early warning judgment identifier. The status level determination submodule is used to continue comparing the signal amplitude and signal-to-noise ratio with the second-level threshold in the health baseline based on the quantized feature parameter vector and the first-level early warning judgment identifier. Based on the combination of the results of the two comparisons, a unique digital code is assigned to the current status to establish the transducer performance status code.
[0009] Preferably, the device attitude disturbance discrimination module includes: The static attitude deviation calculation submodule is used to extract the projection values of the static gravity component on the three coordinate axes based on the original sensor data set, perform vector dot product operation by combining the projection values with the projection values of the zero-point attitude reference, and then calculate the angle between the two vectors to obtain the device space deflection angle. The instantaneous dynamic impact detection submodule is used to scan the time series data of the dynamic AC component point by point according to the original sensing data set, calculate the absolute value of the instantaneous amplitude, and compare the absolute value with the preset acceleration threshold in real time. When the amplitude exceeds the limit, the timestamp of the current moment is recorded and a high amplitude impact signal is generated.
[0010] Preferably, the device attitude disturbance discrimination module further includes: The multi-source information association decision submodule is used to retrieve the transducer performance status code within a time window before and after the timestamp of the high-amplitude impact signal based on the high-amplitude impact signal and the transducer performance status code, check whether the status code is in a signal unlock state, and if they match in time, it is determined to be a valid association event and a physical abnormal event flag is generated.
[0011] Preferably, the IoT data encapsulation and reporting module includes: The metering information integration submodule is used to calculate the gas flow rate value, and combine the calculated gas flow rate value, the transducer performance status code and the physical abnormal event flag into a temporary information set to obtain aggregated metering information. The standard protocol encapsulation submodule is used to create a data frame structure with a predetermined protocol format based on the aggregated metering information. It fills the data in the aggregated metering information into the target field of the data frame in a specified order and length, and adds the device unique identifier and the current timestamp to generate a standard format data frame.
[0012] Preferably, the IoT data encapsulation and reporting module further includes: The ciphertext generation submodule is used to generate a fixed-length encrypted data packet by calling a key preset in the secure storage area according to the standard format data frame, and to establish the ciphertext for gas metering to be issued.
[0013] Compared with the prior art, the advantages and positive effects of the present invention are as follows: In this invention, by simultaneously acquiring the ultrasonic return signal waveform and the dynamic and static components of a triaxial accelerometer, the ultrasonic signal is feature-extracted, and the signal amplitude, energy, and signal-to-noise ratio are quantitatively analyzed. Multi-threshold comparisons are then performed with a health baseline, enabling a shift from passive fault response to proactive status warning. This anticipates the decrease in metering accuracy caused by aging and scaling. Furthermore, the triaxial accelerometer data not only monitors static deviations in installation posture but also captures instantaneous dynamic disturbances such as impacts and vibrations. Crucially, the dynamic disturbance events are time-stamped and correlated with ultrasonic signal lock-out phenomena to distinguish between environmental interference and malicious physical tampering. This solves the problem of traditional flowmeters being unable to detect and verify external physical attacks. Finally, the precise gas flow value, equipment health status code, and physical anomaly event markers are integrated into a single data package and encrypted for remote transmission, providing data support for the management, maintenance, and safety of gas pipeline networks. Attached Figure Description
[0014] Figure 1 This is a system flowchart of the present invention. Detailed Implementation
[0015] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0016] Please see Figure 1 The present invention provides a technical solution: a remote data transmission system for ultrasonic gas flow meters based on NB-IoT, comprising: The multi-source signal synchronous acquisition module is used to synchronously start the ultrasonic transducer pulse emission circuit and the triaxial accelerometer data acquisition according to the internal clock of the MCU. It continuously samples the waveform of the returned signal from the receiving transducer within a preset time window, converts the analog voltage value of each sampling point into a digital quantized value, and records the static gravity component and dynamic AC component of the triaxial accelerometer to obtain the original sensing data set. The transducer status feature analysis module is used to locate the maximum value as the signal amplitude by traversing the digital quantization value sequence from the ultrasonic signal waveform according to the original sensor data set, calculate the sum of squares of all quantization values below the waveform envelope to obtain the signal energy, calculate the ratio of the signal peak value to the root mean square of the noise sample during the silent period before measurement to obtain the signal-to-noise ratio, and then compare the signal amplitude, signal energy and signal-to-noise ratio with the first-level threshold and the second-level threshold of the stored health baseline item by item to establish the transducer performance status code; The device attitude disturbance identification module is used to calculate the spatial angle between the current attitude and the zero-point attitude reference based on the original sensor data set and the transducer performance status code, using the projection of the static gravity component on the three axes, and setting an acceleration threshold. When the instantaneous impact amplitude of the dynamic AC component exceeds the acceleration threshold, the transducer performance status code under the same timestamp is retrieved. If the status code indication signal is lost, a valid associated event is determined and a physical abnormal event flag is generated. The IoT data encapsulation and reporting module is used to calculate the gas flow rate value. It fills the gas flow rate value, transducer performance status code and physical abnormal event flag into the target field of the data frame in a predetermined protocol format, and adds the device unique identifier code and timestamp. The filled data frame is encrypted and the encrypted data packet is scheduled to be sent to the gas pipeline network data center through the narrowband IoT network to establish the gas metering ciphertext to be sent.
[0017] The multi-source signal synchronous acquisition module includes: The clock synchronization trigger submodule is used to generate a common start pulse based on the internal clock of the MCU using a timer interrupt, and simultaneously send it to the ultrasonic transducer pulse transmitting circuit and the triaxial accelerometer data acquisition unit to obtain a synchronous sampling trigger signal; The sensor signal digitization submodule is used to drive the analog-to-digital converter at a preset sampling frequency according to the synchronous sampling trigger signal, quantize the waveform of the signal returned by the receiving transducer point by point, write the converted digital quantized value into the first data buffer, and store the static gravity component and dynamic AC component readings of the triaxial accelerometer into the second data buffer to establish a discrete time-series data stream. The multidimensional data integration submodule is used to read all the data in the first and second data buffers according to the discrete time-series data stream, mark the data set with a unified collection timestamp, and organize multiple data into a complete data packet according to a preset data structure format to obtain the original sensor data set.
[0018] Specifically, based on the MCU's internal clock, the internal timer module (e.g., Timer1) is first configured to operate in CTC mode, and a suitable clock prescaler coefficient is selected, for example, set to 64, to balance timing accuracy and interrupt frequency. Next, the count value of the output comparator register (OCR1A) is calculated and set according to the target synchronous sampling frequency. The process for setting this count value is as follows: for example, if the MCU's main clock frequency is 16MHz and the desired synchronous sampling trigger frequency is 2kHz, then the OCR1A count value is calculated using the formula (MCU clock frequency / prescaler coefficient) / target frequency - 1. Substituting the values, we get (16,000,000 / 64) / 2000 - 1. 1. The count value is 124. This value is written to the OCR1A register. When the counter value inside the timer increments from 0 to 124, the timer hardware will generate an interrupt request. In the corresponding interrupt service routine (ISR), a common start pulse is generated by programming the level state of a general-purpose input / output (GPIO) pin. Specifically, the GPIO pin is pulled high for a very short time (e.g., 5 clock cycles) and then immediately pulled low to form a narrow pulse. The physical output of this GPIO pin is simultaneously connected to the trigger input of the ultrasonic transducer pulse transmission circuit and the synchronous acquisition control pin of the triaxial accelerometer data acquisition unit. By using the rising or falling edge of the same pulse signal, the signal transmission and data acquisition of the two different sensors are strictly aligned in time to obtain a synchronous sampling trigger signal.
[0019] Based on the synchronous sampling trigger signal, a data acquisition process is triggered on the effective edge (e.g., rising edge) of each pulse. This signal first drives the analog-to-digital converter (ADC) to start high-speed sampling of the analog signal waveform returned by the receiving transducer at a preset sampling frequency. The preset sampling frequency must satisfy the Nyquist theorem and is usually set to more than 4 times the center frequency of the ultrasonic wave. For example, if the ultrasonic frequency is 1MHz, the sampling frequency can be set to 4MHz. At each sampling point, a 12-bit ADC converts the input analog voltage into a digital quantization value between 0 and 4095. To avoid consuming the MCU's CPU time, a direct memory access (DMA) controller is configured to automatically and continuously transmit and write the digital quantization value after each ADC conversion to a pre-allocated first data buffer. The size of this buffer is set to be able to hold one... All waveform data within the complete measurement cycle, such as 4096 sampling points, are simultaneously processed. At the same time, a synchronous sampling trigger signal sends a data read command to the triaxial accelerometer via SPI or I2C bus to obtain the raw acceleration readings of the X, Y, and Z axes stored in its internal registers. A low-pass digital filter, such as a first-order infinite impulse response (IIR) filter with a cutoff frequency set to 1Hz, is applied to the obtained raw acceleration readings to filter out high-frequency vibration components and extract the static gravity component representing the static tilt angle of the equipment. Subsequently, the calculated static gravity component is subtracted from the corresponding raw acceleration reading, and the result is the dynamic AC component reflecting the instantaneous vibration and impact of the equipment. These six floating-point values, including the static gravity component and the dynamic AC component of the three axes, are stored in the second data buffer. Through this parallel acquisition and processing method, a discrete time-series data stream is established.
[0020] Based on the discrete-time data stream, after a complete acquisition cycle, for example, when the first data buffer is filled with 4096 sampling points, the DMA controller generates a transfer completion interrupt as the start signal for data integration. In the interrupt service routine, all data from both data buffers is first read: an ultrasonic data sequence containing 4096 unsigned 16-bit integers is retrieved from the first data buffer, and six 32-bit floating-point numbers containing static gravity components and dynamic AC components along the X, Y, and Z axes are retrieved from the second data buffer. To ensure data traceability, a unified acquisition timestamp is assigned to this entire batch of acquired data. This timestamp is generated the instant each acquisition process is initiated by a common start pulse, by reading a continuously running real-time clock (RTC) module. The current count value of the block is obtained, accurate to the millisecond level. Then, these multi-source, heterogeneous data are organized into a structured, complete data packet according to a preset data structure format. This data structure can be defined as a composite type containing multiple members, such as a C language struct. Its internal members are as follows: a 64-bit unsigned integer timestamp, a 16-bit unsigned integer array of length 4096 for storing ultrasonic data, and six 32-bit floating-point numbers for storing the static gravity component and dynamic AC component of the three axes, respectively. The read timestamp, ultrasonic data, and six accelerometer component data are sequentially filled into the corresponding member variables of the structure instance. The final data packet is the original sensor data set containing all sensor information at a specific moment.
[0021] The transducer state characteristic analysis module includes: The signal feature parameter extraction submodule is used to search for the maximum value in the digital quantization value sequence based on the original sensor data set to obtain the signal amplitude, perform a square operation on each value in the sequence and sum them to calculate the signal energy, extract noise samples from the silent period before measurement to calculate the root mean square, divide the signal peak value by the root mean square to obtain the signal-to-noise ratio, and generate a quantization feature parameter vector. The preliminary comparison submodule of the health baseline is used to compare the signal amplitude and signal-to-noise ratio in the quantized feature parameter vector with the first-level attenuation threshold and the first-level signal-to-noise ratio threshold stored in the health baseline. If any parameter is worse than the threshold, an internal flag is set to establish a first-level early warning judgment mark. The status level determination submodule is used to continue comparing the signal amplitude and signal-to-noise ratio with the second-level threshold in the health baseline based on the quantized feature parameter vector and the first-level warning judgment identifier. Based on the combination of the results of the two comparisons, a unique digital code is assigned to the current status to establish the transducer performance status code.
[0022] Specifically, based on the original sensor data set, signal features are first extracted from its contained digital quantized value sequence (i.e., the ultrasonic waveform data array). By iterating through all 4096 values in the sequence, the maximum value is located and recorded; this maximum value is determined as the signal amplitude. Next, to calculate the signal energy, a 64-bit unsigned integer variable is initialized to zero. The sequence is iterated again, and the value of each sampling point is squared. The squared results are accumulated into this variable. The final sum represents the energy of the entire signal waveform. Furthermore, to calculate the signal-to-noise ratio, it is necessary to first evaluate... To determine the background noise level, the specific operation involves extracting noise samples from the silent period before measurement. This silent period is defined as the initial part of the ultrasonic data sequence, such as the first 512 sampling points, because the ultrasonic signal has not yet reached the receiving transducer at this time. Then, the root mean square (RMS) value of these 512 noise samples is calculated. The calculation process is as follows: first, the sum of the squares of these 512 sample values is calculated, then the sum is divided by the number of samples, 512, to obtain the average power. Finally, the square root of the average power is taken to obtain the RMS value of the noise. Finally, the previously obtained signal amplitude (as the signal peak value) is divided by the calculated RMS value of the noise, and the result is converted to decibels (dB) using the formula 20 * log10(signal amplitude / noise RMS) to obtain the signal-to-noise ratio (SNR). The three values of signal amplitude, signal energy, and SNR obtained in this way are combined into an ordered array or structure to generate a quantized feature parameter vector.
[0023] Based on the quantized feature parameter vector, a tiered diagnostic process is initiated to assess the transducer's health status. The first step of this process involves comparing the signal amplitude and signal-to-noise ratio (SNR), two key indicators from the parameter vector, with the first-level threshold of the health baseline pre-stored in the device's non-volatile memory. This health baseline and related thresholds are established during the calibration phase before the device leaves the factory. Specifically, the setting process involves performing 100 consecutive measurements under standard test conditions (e.g., 20°C, standard atmospheric pressure, no external vibration), calculating the average of the signal amplitude and SNR obtained from these 100 measurements, and recording these as the baseline amplitude and baseline SNR, respectively. The first-level attenuation threshold is set to 75% of the baseline amplitude. For example, if the baseline amplitude is 3200 quantization units, the first-level attenuation threshold is 3200 * 0.75 = 2400. Similarly, the first-level SNR threshold is set to 80% of the baseline SNR. For example, if the baseline SNR is 45 dB, the first-level SNR threshold is 45 * 0.8. =36dB. After each real-time measurement, the currently calculated signal amplitude is compared with 2400, and the signal-to-noise ratio is compared with 36dB. If the value of any one or both of them is lower than the corresponding first-level threshold (i.e., the signal amplitude is less than 2400 or the signal-to-noise ratio is less than 36dB), an internal Boolean flag variable is immediately set, for example, its value is changed from 0 to 1, so as to establish a first-level warning judgment indicator.
[0024] Based on the quantized feature parameter vector and the first-level warning indicator, subsequent refined state level determination is performed. If the first-level warning indicator is not set (i.e., its value is 0), it indicates that both the signal amplitude and signal-to-noise ratio (SNR) are better than their respective first-level thresholds, and the transducer is directly determined to be "healthy" and assigned a state code of 0. If the first-level warning indicator is set (i.e., its value is 1), further comparison is needed to distinguish the severity of the fault. At this time, the signal amplitude and SNR in the quantized feature parameter vector are compared with the second-level thresholds stored in the healthy baseline. The second-level thresholds are set to identify more severe performance degradation. The setting process is similar to the first-level thresholds, but with a lower scaling factor. For example, the second-level attenuation threshold is set to 40% of the baseline amplitude, which in the previous example is 3200 * 0.4 = 1280. The second-level SNR threshold is set to 50% of the baseline SNR, which is 45 * 0.5 = 1280. The final status code is assigned based on the combination of the results of these two comparisons. The specific judgment logic is as follows: if the signal amplitude is lower than 1280 or the signal-to-noise ratio is lower than 22.5dB, the transducer status is judged as "severe attenuation or signal loss", and status code 2 is assigned. If the signal parameters are worse than the first threshold but better than or equal to the second threshold (i.e., the amplitude is between 1280 and 2400, and the signal-to-noise ratio is between 22.5dB and 36dB), the status is judged as "slight attenuation", and status code 1 is assigned. Through this series of condition judgments, a unique digital code (0, 1, or 2) is assigned to the current performance status of the transducer, and the transducer performance status code is established.
[0025] The device attitude disturbance identification module includes: The static attitude deviation calculation submodule is used to extract the projection values of the static gravity components on the three coordinate axes based on the original sensor data set, perform vector dot product operation between the projection values and the projection values of the zero-point attitude reference, and then calculate the angle between the two vectors to obtain the device space deflection angle. The instantaneous dynamic impact detection submodule is used to scan the time series data of the dynamic AC component point by point according to the original sensor data set, calculate the absolute value of the instantaneous amplitude, and compare the absolute value with the preset acceleration threshold in real time. When the amplitude exceeds the limit, the timestamp of the current moment is recorded and a high amplitude impact signal is generated. The multi-source information association decision submodule is used to retrieve the transducer performance status code within a time window before and after the timestamp of the high-amplitude impact signal based on the high-amplitude impact signal and the transducer performance status code. It checks whether the status code is in a signal unlock state. If they match in time, it is determined to be a valid association event and a physical anomaly event flag is generated.
[0026] Specifically, based on the original sensor data set, the projection values of the static gravity component obtained after processing by the low-pass filter onto the X, Y, and Z coordinate axes are extracted and denoted as vectors. This vector represents the current static attitude of the device. Simultaneously, a pre-stored zero-point attitude reference vector is read from the device's non-volatile memory, denoted as... This reference vector is a set of gravity component readings collected and fixed when the equipment is first installed and calibrated to a standard horizontal position. For example, in an ideal horizontal installation state, its value might be (0, 0, -1), representing that gravity acts entirely in the negative Z-axis direction. Subsequently, the calculation formula is obtained by performing a vector dot product operation on these two three-dimensional vectors. ,in For the dot product result, Let be the gravitational component at the current orientation. Let the gravity component be the zero-point attitude reference. Then, calculate the magnitudes of the current attitude vector and the zero-point attitude reference vector, respectively, using the following formula: ,get and Finally, the spatial angle between the two vectors is calculated using the inverse cosine function. Its calculation formula is The calculated angle Convert to degrees to obtain the device space deflection angle.
[0027] Based on the original sensor data set, the time series data of the three-axis dynamic AC components contained therein are extracted, i.e. The time series data was scanned point by point, at each sampling time point. Calculate the composite instantaneous amplitude of the dynamic AC components at that moment. The calculation method is to solve for the square root of the sum of squares of the three-axis components, i.e. ,in For at a certain point in time The instantaneous impact amplitude, since the calculation result itself is non-negative, does not need to be taken as an absolute value. Then, the calculated instantaneous amplitude... The acceleration is compared in real time with a preset acceleration threshold, which is set based on statistical analysis of the vibration experienced by the equipment under normal operating conditions. The specific setting process is as follows: In a laboratory environment, the typical vibration spectrum and amplitude of a gas pipeline network are simulated, and the equipment undergoes a continuous 24-hour vibration test. The maximum instantaneous amplitude of the dynamic AC component synthesis during this period is recorded and denoted as [value missing]. The preset acceleration threshold is set to three times this maximum value. For example, if the maximum normal vibration amplitude recorded during the test is 0.8g, then the acceleration threshold is set to 0.8g * 3 = 2.4g. During the point-by-point scanning process, once the instantaneous amplitude at a certain moment is detected... If the amplitude exceeds 2.4g, the unified acquisition timestamp corresponding to that moment is immediately recorded, and the timestamp is packaged with the amplitude information exceeding the limit to generate a high-amplitude impact signal.
[0028] Based on the high-amplitude impact signal and the transducer performance status code, the timestamp of the impact event is first extracted from the high-amplitude impact signal and denoted as . Next, a symmetrical time window is defined around this timestamp for correlation analysis. The width of this time window needs to cover the response time that the impact event may cause signal anomalies; it is set to 4 seconds, meaning the time window range is... Then, the system retrieves a historical list of transducer performance status codes stored in the device's memory. This list contains the transducer performance status codes generated for each measurement within a past period and their corresponding timestamps. The system iterates through this list, filtering out all timestamps that fall within the specified range. For each transducer performance status code record within the interval, check whether its value is a specific code representing the signal loss state. According to the aforementioned definition, the signal loss state code is 2. Therefore, the judgment condition is to check whether the status code is equal to 2. If at least one record with a transducer performance status code of 2 is found within the time window, it is determined that this high-amplitude impact event and the signal loss are closely related in time, constituting a valid correlation event. At this time, a Boolean physical anomaly event flag is generated and its value is set to true.
[0029] The IoT data encapsulation and reporting module includes: The metering information integration submodule is used to calculate the gas flow rate value, and combine the calculated gas flow rate value, the transducer performance status code and the physical abnormal event flag into a temporary information set to obtain aggregated metering information. The standard protocol encapsulation submodule is used to create a data frame structure with a predetermined protocol format based on the aggregated metering information. It fills the data in the aggregated metering information into the target field of the data frame in a specified order and length, and adds the device unique identifier and the current timestamp to generate a standard format data frame. The ciphertext generation submodule is used to generate a fixed-length encrypted data packet by calling a key preset in the secure storage area according to the standard format data frame, and to establish the ciphertext for gas metering to be issued.
[0030] Specifically, the gas flow rate is first calculated based on the time difference between the downstream and upstream propagation of ultrasound in the gas medium. The specific calculation process is as follows: the downstream propagation time of the ultrasound is read. and the time of reverse propagation Calculate the time difference Then, based on the flow meter's geometric parameters (such as channel length) Angle between the vocal tract and the airflow direction ) and preset calibration coefficients Through formula Calculate the instantaneous volumetric flow rate This is the gas flow rate value. Then, this calculated floating-point gas flow rate value is combined with the integer transducer performance status code generated within the current cycle (its value is 0, 1, or 2), and the Boolean physical anomaly event flag (its value is true or false). These three different types of data are combined into a temporary, structured information set. This set can be represented in memory as a structure containing three member variables. For example, at the end of a measurement cycle, the data that might be generated is: gas flow rate value 1.58 m³ / s. 3 / h, transducer performance status code 0, physical abnormal event flag is false. Fill these three data items into the corresponding fields of this structure to obtain aggregated metering information.
[0031] Based on the aggregated metering information, the data frame encapsulation process is initiated. First, a fixed-size byte array is created in memory as the skeleton of the data frame according to a predetermined proprietary communication protocol format. This protocol format specifies the position, length, and data type of each field in the data frame. For example, a data frame structure with a total length of 32 bytes is defined as follows: a start character occupies 2 bytes (fixed at 0xFEFF), a unique device identifier occupies 8 bytes, a timestamp occupies 4 bytes (Unix time), a gas flow value occupies 4 bytes (32-bit floating-point number), a transducer performance status code occupies 1 byte, a physical anomaly event flag occupies 1 byte, a data checksum (such as CRC16) occupies 2 bytes, and the remaining bytes are reserved fields. Then… The process involves filling each data point in the aggregated metering information into the target field of this byte array one by one according to the order and length specified in the protocol. Specifically, the process is as follows: read the 16-bit unique device identifier from the device information storage area and fill it into the corresponding position; call the real-time clock to obtain the current Unix timestamp and fill it in; then, perform type conversion and byte order alignment (such as converting to network byte order) on the gas flow value, transducer performance status code, and physical abnormal event flag in the aggregated metering information, and fill them into their respective fields; finally, perform CRC16 algorithm calculation on all bytes of the filled data frame (except for the checksum field) and fill the resulting 16-bit checksum into the end of the data frame to generate a standard format data frame.
[0032] Based on the standard format data frame, the device-unique key, pre-stored in the MCU's internal secure storage area (such as OTP or protected Flash area), is invoked to perform data encryption. The AES-128 symmetric encryption algorithm is selected, and the CBC (Cryptbook Linked) working mode is employed. This mode requires a 16-byte key and a 16-byte initialization vector (IV). The key is written once during device manufacturing and cannot be read externally. The initialization vector is dynamically generated before each encryption operation by calling the MCU's built-in hardware true random number generator (TRNG) to ensure that the ciphertext is different each time. Before the process begins, the standard format data frame is padded. Because the AES-128 algorithm requires the length of the data to be encrypted to be an integer multiple of 16 bytes, the PKCS7 padding standard is used to add several bytes to the end of the data frame to make the total length meet the requirement. Then, the padded standard format data frame is used as plaintext, along with the key read from the secure area and the newly generated initialization vector, and sent to the AES-128 encryption engine for processing. After the processing is completed, the generated initialization vector (16 bytes) is concatenated with the encrypted ciphertext data to form a final data packet, which is the gas metering ciphertext to be issued.
Claims
1. A remote data transmission system for an ultrasonic gas flow meter based on NB-IoT, characterized in that, The system includes: The multi-source signal synchronous acquisition module is used to synchronously start the ultrasonic transducer pulse emission circuit and the triaxial accelerometer data acquisition according to the internal clock of the MCU. It continuously samples the waveform of the returned signal from the receiving transducer within a preset time window, converts the analog voltage value of each sampling point into a digital quantized value, and records the static gravity component and dynamic AC component of the triaxial accelerometer to obtain the original sensing data set. The transducer status feature analysis module is used to locate the maximum value as the signal amplitude by traversing the digital quantization value sequence from the ultrasonic signal waveform according to the original sensing data set, calculate the sum of squares of all quantization values below the waveform envelope to obtain the signal energy, calculate the ratio of the signal peak value to the root mean square of the noise sample during the silent period before measurement to obtain the signal-to-noise ratio, and then compare the signal amplitude, signal energy and signal-to-noise ratio with the first-level threshold and the second-level threshold of the stored health baseline item by item to establish the transducer performance status code.
2. The remote data transmission system for ultrasonic gas flow meters based on NB-IoT according to claim 1, characterized in that, The system also includes: The device attitude disturbance identification module is used to calculate the spatial angle between the current attitude and the zero-point attitude reference based on the original sensor data set and the transducer performance status code, using the projection of the static gravity component on the three axes, and setting an acceleration threshold. When the instantaneous impact amplitude of the dynamic AC component exceeds the acceleration threshold, the transducer performance status code under the same timestamp is retrieved. If the status code indication signal is lost, a valid associated event is determined and a physical abnormal event flag is generated. The IoT data encapsulation and reporting module is used to calculate the gas flow rate value, fill the gas flow rate value, transducer performance status code and physical abnormal event flag into the target field of the data frame in a predetermined protocol format, and attach the device unique identifier code and timestamp. The filled data frame is encrypted, and the encrypted data packet is scheduled to be sent to the gas pipeline network data center via the narrowband IoT network to establish the gas metering ciphertext to be sent.
3. The remote data transmission system for ultrasonic gas flow meters based on NB-IoT according to claim 1, characterized in that, The multi-source signal synchronous acquisition module includes: The clock synchronization trigger submodule is used to generate a common start pulse based on the internal clock of the MCU using a timer interrupt, and simultaneously send it to the ultrasonic transducer pulse transmitting circuit and the triaxial accelerometer data acquisition unit to obtain a synchronous sampling trigger signal; The sensor signal digitization submodule is used to drive the analog-to-digital converter at a preset sampling frequency according to the synchronous sampling trigger signal, quantize the waveform of the signal returned by the receiving transducer point by point, write the converted digital quantized value into the first data buffer, and store the static gravity component and dynamic AC component readings of the triaxial accelerometer into the second data buffer to establish a discrete time-series data stream. The multidimensional data integration submodule is used to read all the data in the first data buffer and the second data buffer according to the discrete time-series data stream, mark the data set with a unified collection timestamp, and organize multiple data into a complete data packet according to a preset data structure format to obtain the original sensor data set.
4. The remote data transmission system for ultrasonic gas flow meters based on NB-IoT according to claim 1, characterized in that, The transducer state feature analysis module includes: The signal feature parameter extraction submodule is used to obtain the signal amplitude by searching for the maximum value in the digital quantization value sequence based on the original sensing data set, squaring each value in the sequence and summing them to calculate the signal energy, extracting noise samples from the silent period before measurement to calculate the root mean square, dividing the signal peak value by the root mean square to obtain the signal-to-noise ratio, and generating a quantization feature parameter vector. The preliminary comparison submodule of the health baseline is used to compare the signal amplitude and signal-to-noise ratio in the quantized feature parameter vector with the first-level attenuation threshold and the first-level signal-to-noise ratio threshold stored in the health baseline. If any parameter is worse than the threshold, an internal flag is set to establish a first-level early warning judgment identifier. The status level determination submodule is used to continue comparing the signal amplitude and signal-to-noise ratio with the second-level threshold in the health baseline based on the quantized feature parameter vector and the first-level early warning judgment identifier. Based on the combination of the results of the two comparisons, a unique digital code is assigned to the current status to establish the transducer performance status code.
5. The remote data transmission system for ultrasonic gas flow meters based on NB-IoT according to claim 2, characterized in that, The device attitude disturbance discrimination module includes: The static attitude deviation calculation submodule is used to extract the projection values of the static gravity component on the three coordinate axes based on the original sensor data set, perform vector dot product operation by combining the projection values with the projection values of the zero-point attitude reference, and then calculate the angle between the two vectors to obtain the device space deflection angle. The instantaneous dynamic impact detection submodule is used to scan the time series data of the dynamic AC component point by point according to the original sensing data set, calculate the absolute value of the instantaneous amplitude, and compare the absolute value with the preset acceleration threshold in real time. When the amplitude exceeds the limit, the timestamp of the current moment is recorded and a high amplitude impact signal is generated.
6. The remote data transmission system for ultrasonic gas flow meters based on NB-IoT according to claim 5, characterized in that, The device attitude disturbance identification module also includes: The multi-source information association decision submodule is used to retrieve the transducer performance status code within a time window before and after the timestamp of the high-amplitude impact signal based on the high-amplitude impact signal and the transducer performance status code, check whether the status code is in a signal unlock state, and if they match in time, it is determined to be a valid association event and a physical abnormal event flag is generated.
7. The remote data transmission system for ultrasonic gas flow meters based on NB-IoT according to claim 2, characterized in that, The IoT data encapsulation and reporting module includes: The metering information integration submodule is used to calculate the gas flow rate value, and combine the calculated gas flow rate value, the transducer performance status code and the physical abnormal event flag into a temporary information set to obtain aggregated metering information. The standard protocol encapsulation submodule is used to create a data frame structure with a predetermined protocol format based on the aggregated metering information. It fills the data in the aggregated metering information into the target field of the data frame in a specified order and length, and adds the device unique identifier and the current timestamp to generate a standard format data frame.
8. The remote data transmission system for ultrasonic gas flow meters based on NB-IoT according to claim 7, characterized in that, The IoT data encapsulation and reporting module also includes: The ciphertext generation submodule is used to generate a fixed-length encrypted data packet by calling a key preset in the secure storage area according to the standard format data frame, and to establish the ciphertext for gas metering to be issued.