Intelligent electric meter sensor sensing control method and system based on improved algorithm

By improving the algorithm configuration of the MCU and ADC, and combining adaptive filtering and Kalman prediction, the sampling parameters are dynamically adjusted, solving the sampling problem of smart meter sensors under load fluctuations, and achieving efficient balance between accuracy and power consumption and fast response.

CN120951207AInactive Publication Date: 2025-11-14CHANGCHUN VOCATIONAL INST OF TECH
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202511047957.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-29
Publication Date
2025-11-14
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing smart meter sensors struggle to adaptively optimize sampling resolution and bandwidth under fluctuating load conditions, leading to resource waste and slow response.

Method used

An improved algorithm is used to configure the MCU timer to automatic reload mode. Through DMA acquisition and adaptive low-pass filtering, combined with lightweight Kalman prediction and correction, the ADC resolution and analog bandwidth are dynamically adjusted to achieve adaptive sampling and closed-loop parameter adjustment.

Benefits of technology

It achieves high-quality sampling under different load conditions, balances accuracy and power consumption, improves the stability and robustness of sensing and control, and adapts to the complex power environment on campus.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120951207A_ABST
    Figure CN120951207A_ABST
Patent Text Reader

Abstract

The invention discloses an intelligent electric meter sensor sensing control method and system based on an improved algorithm, and relates to the technical field of intelligent electric meter sensor sensing control, and the method comprises the steps: setting an MCU timer to be in an automatic heavy load mode, starting interruption, carrying out the dual-channel scanning of CT / PT, taking a mean value as static bias, and presetting a spine elimination threshold value. And correcting the fluctuation threshold in real time, adaptively switching the resolution according to the interference intensity, and synchronously collecting data and storing the data in an annular buffer area. And performing single-frame median rejection, resampling when the deviation of continuous frames exceeds the limit, and accumulating residual energy in a sliding window through median filtering and self-adaptive low-pass filtering. And dynamically adjusting the noise covariance based on residual statistics, and outputting a high-confidence current / voltage estimated value through lightweight Kalman filtering. And mapping the normalized error energy into a perception behavior of CT / PT. According to the invention, adaptive optimization can be realized under different load conditions in an environment with static resolution and bandwidth setting.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of electricity meter sensing and control technology, and in particular to a smart meter sensor sensing and control method and system based on an improved algorithm. Background Technology

[0002] In smart campus management platforms, smart meter sensors typically employ a method of fixed-time interval sampling, preset threshold judgment, and centralized backend processing to acquire and monitor current and voltage signals. This approach usually involves pre-calibrating hardware bias at the terminal, configuring a single-resolution ADC and analog front-end bandwidth, then performing dual-channel synchronous acquisition via timed triggering. The sampled data is then buffered in a ring and uploaded to the cloud, where it is finally processed on the server using standard filtering and statistical algorithms. This process is characterized by its simplicity, ease of deployment, and mature algorithms, and has been widely applied in campus electricity monitoring systems.

[0003] However, the aforementioned conventional methods have two shortcomings: First, the parameter configuration is too static, making it difficult to automatically adjust the sampling resolution and front-end bandwidth according to load fluctuations, resulting in wasted resources during stable operation and slow response during sudden changes. Second, the lack of effective integration between edge measurement and estimation, and the separation of filtering and state estimation, increases the overall system latency and computational burden. In particular, static parameter configuration limits the terminal's ability to coordinate and optimize sampling accuracy and power consumption, making it difficult to balance energy saving and high accuracy requirements. Summary of the Invention

[0004] In view of the aforementioned existing problems, the present invention is proposed.

[0005] Therefore, this invention provides a smart meter sensor sensing and control method and system based on an improved algorithm, which solves the problem that existing smart meter sensor control technologies are difficult to achieve adaptive optimization under different load conditions due to static resolution and bandwidth settings.

[0006] The technical solution is as follows: In a first aspect, the present invention provides a smart meter sensor sensing control method based on an improved algorithm, which includes: configuring the MCU timer to automatic reload mode and enabling update interrupt, configuring the ADC to perform DMA acquisition and setting static bias and spike rejection threshold.

[0007] After the MCU completes its self-test and starts the timer to enter real-time monitoring, a sliding window is constructed to correct the interference rejection threshold in real time. The ADC resolution is selected according to the interference rejection threshold, and dual-channel synchronous acquisition is performed.

[0008] Perform single-frame median culling on newly sampled data in the buffer, and automatically trigger resampling when the deviation of consecutive frames exceeds the limit.

[0009] The measurement data after rejection are first subjected to median filtering, then adaptive low-pass filtering, while the measurement residual energy is accumulated within the sliding time window.

[0010] Based on the residual statistical index, the measurement noise covariance is adjusted in real time, and lightweight Kalman prediction and correction are performed at the MCU to output high-confidence state estimates of current and voltage.

[0011] The normalized error energy is mapped to the perceptual behavior of CT and PT.

[0012] As a preferred embodiment of the smart meter sensor sensing and control method based on the improved algorithm described in this invention, the step of configuring the ADC for DMA acquisition and setting the static bias and spike rejection threshold includes, under no-load conditions, acquiring ADC values ​​for the CT and PT channels, and calculating the arithmetic mean of the sampled values ​​of each channel as the current and voltage bias, respectively.

[0013] The spike rejection threshold is set by the transient spike amplitude.

[0014] Write the current and voltage biases to RAM, clear the self-test flag, and start the timer.

[0015] As a preferred embodiment of the smart meter sensor sensing and control method based on the improved algorithm described in this invention, the step of constructing a sliding window to correct the interference rejection threshold in real time, and selecting the ADC resolution and performing dual-channel synchronous acquisition according to the interference rejection threshold includes: retrieving the filtered residual sequence of the most recent 10 frames from RAM. ,in, This represents the residual of the previous frame. This represents the residual of the first ten frames.

[0016] Calculate the kurtosis, 10th percentile, and 90th percentile of the filtered residual sequence, and set them as small fluctuation thresholds. and large fluctuation threshold .

[0017] When the timer interrupts, the residual from the previous reading is read, compared with two threshold values, the ADC resolution is selected, written to the ADC register, and dual-channel synchronous acquisition is triggered. The acquired raw ADC value is then subtracted from the bias and converted into current. and voltage Get the timestamp and input the sampling result into the circular buffer.

[0018] As a preferred embodiment of the smart meter sensor sensing and control method based on the improved algorithm described in this invention, the step of performing single-frame median removal on the newly sampled data in the buffer includes: retrieving the earliest enqueued measurement vector from the circular queue. Composite filtering estimation with the previous round of perception control Calculate the corresponding residuals .

[0019] Construct a median window of length 3 Find the median values ​​for the current and voltage components respectively, and replace them with the median values. The corresponding component in the middle.

[0020] The residuals after median removal are then written into a sliding window of length 5, and the values ​​exceeding the spike removal threshold are counted. The number of frames.

[0021] If the statistical value If the residual window is cleared and quantization sampling is immediately re-executed, then the statistical value... Then for the vector after elimination Perform median filtering.

[0022] As a preferred embodiment of the smart meter sensor sensing and control method based on the improved algorithm described in this invention, the step of first performing median filtering and then adaptive low-pass filtering on the removed measurement data includes: [The text abruptly ends here, so the translation stops as well.] Together with the vectors discarded from the previous two frames, a sliding window of length 3 is formed. The median of the current and voltage components is calculated separately, and the filtered median vector is output. .

[0023] Based on the output filter median vector Adjusting the filter gain based on the amplitude difference estimated by the composite filter from the previous round of perception control will... The latest composite filter estimate is generated by proportionally weighting and fusing the previous composite filter output. .

[0024] Calculate the residual of the current frame The square of the current frame residual is then accumulated into a 5-frame sliding time window.

[0025] The real-time quantization error energy is calculated based on the sum of squared residuals of all frames within the window and the window duration. .

[0026] Composite filter estimation Updated residual sliding window and real-time quantization error energy Store in the status area.

[0027] As a preferred embodiment of the smart meter sensor sensing and control method based on the improved algorithm described in this invention, the step of performing lightweight Kalman prediction and correction at the MCU end and outputting high-confidence state estimation of current and voltage includes: reading all residual values ​​in a 5-frame residual sliding window and calculating the difference between the maximum residual and the minimum residual respectively.

[0028] The difference is mapped to the measurement noise covariance according to a preset ratio, and the adaptive measurement covariance generated in this cycle is adjusted.

[0029] Using the posterior estimate of the previous perception control as the prior state, the prior covariance is updated by loading the process noise covariance, thus generating the prior estimate and prior covariance.

[0030] The Kalman gain is calculated based on the adaptive measurement covariance and the measurement vector after cleaning and filtering in the current frame.

[0031] The prior estimate is fused with the current frame's cleaned and filtered measurement vector using gain weighting to output the posterior estimated state vector, while simultaneously updating the posterior covariance.

[0032] As a preferred embodiment of the smart meter sensor sensing and control method based on the improved algorithm described in this invention, the sensing behavior of mapping the normalized error energy to CT and PT includes: reading the real-time quantized error energy, the posterior estimated state vector, and the posterior covariance from the state region.

[0033] The real-time quantization error energy is divided into error levels.

[0034] Select the corresponding parameter to be adjusted based on the error level and the uncertainty level of the posterior covariance.

[0035] The sensing gain and excitation voltage of CT and PT are adjusted.

[0036] After configuration, the next round of perception control begins. Before starting, the composite filter estimate, posterior estimate state vector, posterior covariance, and adaptive measurement noise covariance are written back to the state area.

[0037] Secondly, the present invention provides a smart meter sensor perception and control system based on an improved algorithm, including an initialization module, a threshold sampling module, a rejection module, a composite filtering module, a prediction module, and a perception mapping module.

[0038] The initialization module is used to configure the MCU timer to automatic reload mode and enable update interrupt, configure the ADC to be a dual-channel DMA acquisition triggered by current sensor CT and voltage sensor PT, and take the arithmetic mean of each channel as the static bias.

[0039] The threshold sampling module is used to construct a sliding window to correct the interference rejection threshold in real time after the MCU completes self-test and starts the timer to enter real-time monitoring, and selects the ADC resolution and performs dual-channel synchronous acquisition based on the interference rejection threshold.

[0040] The elimination module is used to perform single-frame median elimination and multi-frame abnormal ratio detection on the new sampled data in the buffer. When the deviation of consecutive frames exceeds the limit, resampling is automatically triggered to eliminate occasional spikes and continuous jitter.

[0041] The composite filtering module is used to first perform median filtering on the rejected measurement data, then perform adaptive low-pass filtering, and simultaneously accumulate measurement residual energy within the sliding time window.

[0042] The prediction module is used to adjust the measurement noise covariance in real time based on residual statistics, perform lightweight Kalman prediction and correction at the MCU, and output high-confidence state estimates of current and voltage.

[0043] The perception mapping module is used to map the normalized error energy to the perception behavior of CT and PT.

[0044] Thirdly, the present invention provides a computer device including a memory and a processor, wherein the memory stores a computer program, wherein when the computer program is executed by the processor, it implements any step of the smart meter sensor sensing and control method based on the improved algorithm described in the first aspect of the present invention.

[0045] Fourthly, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein: when the computer program is executed by a processor, it implements any step of the smart meter sensor sensing and control method based on the improved algorithm as described in the first aspect of the present invention.

[0046] The beneficial effects of this invention are as follows: This invention achieves online threshold updating and dynamic ADC resolution switching based on filter residual statistics through dynamic threshold self-calibration and adaptive sampling. During timed interrupts, it automatically sets different sampling precision levels according to the residual window results, ensuring high-quality sampling under both stable and abrupt conditions, thus achieving a balance between accuracy and power consumption. Through normalized error-driven closed-loop multi-dimensional parameter mapping and hardware configuration steps, it realizes closed-loop adjustment of end-side parameters based on real-time error energy. The error energy is mapped to configuration registers for sampling period, ADC bit width, analog bandwidth, excitation voltage, and communication period, ensuring seamless switching and rapid response of the system to different dynamic scenarios, and improving the stability and robustness of sensing and control. It is suitable for the complex power consumption conditions of laboratory buildings, dormitories, and teaching buildings on campus. Attached Figure Description

[0047] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0048] Figure 1 This is a flowchart of a smart meter sensor sensing and control method based on an improved algorithm.

[0049] Figure 2 This is a schematic diagram of a smart meter sensor sensing control system based on an improved algorithm.

[0050] Figure 3 This is a flowchart for adaptive sampling.

[0051] Figure 4 This is a flowchart for Kalman prediction correction. Detailed Implementation

[0052] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.

[0053] Many specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of the invention. Therefore, the invention is not limited to the specific embodiments disclosed below.

[0054] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The phrase "in one embodiment" appearing in different places in this specification does not necessarily refer to the same embodiment, nor is it a single or selective embodiment that is mutually exclusive with other embodiments.

[0055] Reference Figure 1 This is one embodiment of the present invention, which provides a smart meter sensor sensing and control method based on an improved algorithm, including the following steps: S1: Configure the MCU timer to auto-reload mode and enable update interrupt, configure the ADC to perform DMA acquisition and set the static bias and spike rejection threshold.

[0056] Among them, MCU stands for Microcontroller Unit, ADC stands for Analog-to-Digital Converter, CT stands for Current Transformer, PT stands for Potential Transformer, and DMA stands for Direct Memory Access.

[0057] Specifically, the ADC is configured for DMA acquisition, and static bias and spike rejection thresholds are set. Under no-load conditions, 16 ADC values ​​are each acquired for CT and PT, and the average values ​​are used as the current bias values. I and voltage bias O U .

[0058] Write the bias to RAM, clear the self-test flag, and start the timer.

[0059] Furthermore, configure the MCU timer to automatic reload mode, with the initial period being the minimum sampling period. And enable update interruption.

[0060] Configure the ADC to scan two channels, including channel CT and channel PT, set the hardware trigger source to timer update event, and enable DMA to automatically write to the memory buffer in sequence.

[0061] It should be noted that, for electromagnetic interference in the campus power grid environment, current is collected, transient spike amplitudes are calculated, and the concentrated range of transient spike amplitudes is used as a candidate range. In order to effectively eliminate most single spikes while avoiding the accidental elimination of normal load rapid changes, the median value of the candidate range is selected as a fixed threshold. .

[0062] During the initialization phase, the system needs to run continuously on campus for 24 hours, calculating the error energy at a 1-second cycle. Stored in the log.

[0063] Sort in ascending order and take the 99.9th percentile value as the maximum error energy.

[0064] Broadband white noise sources were injected into both the CT and PT channels. During testing, one thousand frames of communication output samples were continuously acquired, and the statistical variance of the output samples was calculated. These statistical variances were then used as the measurement noise covariances for the CT and PT channels, respectively. The measurement noise covariances of the CT and PT channels were then filled into a second-order diagonal matrix and permanently written into the device's Flash memory. Each time the device is powered on or reset, the covariances are loaded from Flash into RAM as the runtime measurement noise covariances. .

[0065] First, a step signal that instantaneously jumps from 0V to a set amplitude and remains constant at a predetermined time is applied to the CT and PT channels to obtain the ideal step waveform. The ADC continuously samples the signal at a clock synchronized with the signal source to obtain the actual response sequence. Then, the difference between each sampled value and the ideal step value at the corresponding time is calculated to obtain the output error sequence in the response curve. Using the least squares fitting method, a polynomial fit is performed on the error sequence, and the variance of the residuals is calculated. The obtained variance value is the process noise covariance. The process noise covariance is also stored in Flash memory as a second-order diagonal matrix and loaded into RAM during device initialization for use by the Kalman filter algorithm.

[0066] In the target campus environment, residual ranges were collected from three different fluctuation scenarios. With the corresponding true measurement noise variance Calculate the increment for each group. For residual range and Perform a least-squares linear fit; the slope of the fitted line is the proportion. .

[0067] S2: After the MCU completes its self-test and starts the timer to enter real-time monitoring, a sliding window is constructed to correct the interference rejection threshold in real time. The ADC resolution is selected according to the interference rejection threshold, and dual-channel synchronous acquisition is performed.

[0068] Specifically, during operation, a sliding window is constructed to correct small and large fluctuation thresholds in real time, including retrieving the filtered residual sequence of the most recent 10 frames from RAM. ,in, This represents the residual of the previous frame. This represents the residual of the first ten frames. The residual of each frame is obtained by subtracting the composite filter output of the previous round of perception control from the measurement value of this round.

[0069] Calculate the kurtosis, 10th percentile, and 90th percentile of the filtered residual sequence, and set them as small fluctuation thresholds. and large fluctuation threshold .

[0070] When the timer is interrupted, the residual from the previous time is read, compared with three thresholds, the ADC resolution is selected, written to the ADC register, and dual-channel synchronous acquisition is triggered.

[0071] The acquired raw ADC values ​​are subtracted for bias and converted to the current of the k-th frame. and voltage Get the timestamp and write the sampling results into the circular buffer.

[0072] For further details, please refer to Figure 3 To calculate the kurtosis of the filtered residual sequence, first calculate the mean of the sliding window residuals. With kurtosis , represented as: ; ; in, The length of the residual sliding window. This represents the current frame, and we'll take 10 frames. For the first The residual vector of the frame, For the first The magnitude of the residual vector of a frame is used to construct a kurtosis correction coefficient based on the current kurtosis value, and is expressed as: ; in, This is the threshold correction coefficient for this period. For correction factors, For reference kurtosis, the value is 3.

[0073] Within the same residual amplitude window, the 10th and 90th percentile values ​​are taken in ascending order to determine the small fluctuation threshold for this period. and large fluctuation threshold .

[0074] The timer operates on the sampling period of the last closed-loop update. Upon expiration, an ADC interrupt is triggered. If this is the first startup, the minimum sampling period will be used. maturity.

[0075] The interrupt entry reads the amplitude of the previous filtering residual. .

[0076] like Then the ADC resolution is set to 8 bits.

[0077] like Then the ADC resolution is set to 10 bits.

[0078] like The ADC resolution is then set to 12 bits. The corresponding bit width is written to the ADC control register.

[0079] It should also be noted that the acquired raw ADC values ​​are adjusted by subtracting the bias and converting them to current. and voltage , represented as: ; ; in, and These represent the digital values ​​of current and voltage read from the DMA buffer this time, respectively. and These represent the current and voltage conversion gains, respectively.

[0080] Get and Then immediately read the current timestamp , timestamp, as well as according to The format is encapsulated as a sampled triple as the final sampling result, and the final sampling result is written to a circular buffer.

[0081] S3: Performs single-frame median removal on newly sampled data in the buffer, and automatically triggers resampling when the deviation of consecutive frames exceeds the limit.

[0082] Specifically, performing single-frame median culling on newly sampled data in the buffer includes: retrieving the earliest enqueued measurement vector (without its timestamp) from the circular queue. Composite filtering estimation with the previous round of perception control Calculate the corresponding residuals .

[0083] Construct a median window of length 3 Find the median values ​​for the current and voltage components respectively, and replace them with the median values. The corresponding component in the middle, This represents the residual between the first two frames; The residuals after median removal are then written into a sliding window of length 5, and the values ​​exceeding the spike removal threshold are counted. The number of frames.

[0084] If the statistical value If the result is not satisfactory, the residual window is cleared and quantization sampling is immediately re-executed. Then, a persistent jitter detection is performed. If this fails, the residual window is cleared and quantization sampling is immediately re-executed; otherwise, the discarded vector is processed. Perform median filtering.

[0085] Furthermore, the composite filter estimate from the previous round of perception control stored in RAM is read. , This is the current estimate from the previous test. This is the current estimate from the previous iteration. The superscript T indicates transpose. If it's the first round, the initialized result vector is used. .

[0086] Construct a residual window of length 3: .

[0087] To each and Take the median value to obtain the median residual. .

[0088] Replace the current measurement with the median: ; in, This is the vector for removing intermediate elements.

[0089] Calculate the corrected residuals .

[0090] Will Append to a residual window of length 5; if it exceeds this, delete the oldest item.

[0091] If any two in the window Exceeding the spike removal threshold If the residual window is cleared, quantization sampling is retried. If resampling is not triggered, then: ; ; in, This is the residual vector after cleaning.

[0092] S4: The measurement data after rejection is first subjected to median filtering, then adaptive low-pass filtering, and the measurement residual energy is accumulated within the sliding time window.

[0093] Specifically, the process of first performing median filtering on the removed measurement data, followed by adaptive low-pass filtering, includes: [the process involves] vector... Together with the vectors discarded from the previous two frames, a sliding window of length 3 is formed. The median of the current and voltage components is calculated separately, and the filtered median vector is output. .

[0094] The filter gain is dynamically adjusted based on the amplitude difference between the current filter median and the previous composite filter output. The latest composite filter estimate is generated by proportionally weighting and fusing the previous composite filter output. .

[0095] Calculate the residual of the current frame The squared values ​​are then accumulated within a 5-frame sliding time window.

[0096] Dividing the sum of squared residuals of all frames within the window by the window duration yields the real-time quantization error energy. .

[0097] Composite filter estimation Updated residual sliding window and error energy Store in the status area.

[0098] Furthermore, receive the vector after elimination. Residual vector after cleaning and timestamp For the vector after removal Perform median averaging and output the latest composite filter estimate. Residual window update and cumulative measurement residual energy .

[0099] in, Indicates the first Current measurement value after frame cleaning Indicates the first Voltage measurement after frame cleaning.

[0100] Build length is Measurement of the sliding window after cleaning: ; in, Indicates the first The vector after frame removal. Indicates the first The vector after frame removal.

[0101] The mean values ​​of the current and voltage components, respectively, are expressed as: ; ; in, For current components, For voltage components, Indicates the first Current measurement value after frame cleaning Indicates the first Current measurement value after frame cleaning Indicates the first Voltage measurements after frame cleaning Indicates the first Voltage measurement after frame cleaning.

[0102] The filtered median vector is represented as: ; Calculate the magnitude of the difference between the median filter output and the previous filter estimate. , represented as: ; Combined with the current correction residual magnitude ,have to: ; in, For filter gain, The standard deviation of the residuals. It is the second-order gain coefficient. The root mean square of the residuals, This is the calculated adaptive filter gain.

[0103] Will Crop to range This allows it to quickly track small fluctuations and enhance the quadratic term response during moderate or severe fluctuations.

[0104] The filter output update is represented as: ; Generate new filter estimation vectors .

[0105] The recent overall deviation is quantified by accumulating error energy.

[0106] The current sampling period is As confirmed in step 2, The number of frames within the time window. The duration of the sliding time window is 5 in this embodiment.

[0107] Cumulative measurement residual energy Represented as: ; in, express The Euclidean norm of represents the th The filtered residual vector of the frame is the vector after removal. With filter output The difference, For the first Frame timestamps For the first The timestamp of the frame.

[0108] S5: Adjusts the measurement noise covariance in real time based on residual statistics, performs lightweight Kalman prediction and correction on the MCU, and outputs high-confidence state estimates of current and voltage.

[0109] Specifically, lightweight Kalman prediction and correction are performed on the MCU side. The high-confidence state estimation of output current and voltage includes: reading all residual values ​​in a 5-frame residual sliding window and calculating the difference between the maximum and minimum residuals respectively.

[0110] The difference is mapped by the coefficient. Mapped to the measurement noise covariance, the larger the fluctuation amplitude, the more important the mapping coefficient. Increase the covariance proportionally; the smaller the fluctuation range, the more it is adjusted according to the mapping coefficient. Proportionally reduce covariance to generate adaptive measurement noise covariance for the cost cycle.

[0111] Using the posterior estimate of the previous perception control as the prior state, the prior covariance is updated by loading the process noise covariance, thus generating the prior estimate and prior covariance.

[0112] The Kalman gain is calculated based on the adaptive measurement covariance and the measurement vector after cleaning and filtering in the current frame.

[0113] The prior estimate and the current measurement are fused together by gain weighting to output the posterior estimated state vector. At the same time, the posterior covariance is updated and the latest uncertainty level is recorded.

[0114] Write the posterior estimate, posterior covariance, and current adaptive measurement covariance back into the state region.

[0115] Furthermore, the latest cleaning measurement data, filter output and residual history, as well as error energy, were obtained.

[0116] Please see Figure 4 First, the posterior estimated state vector of the previous period is directly used as the prior predicted state vector of the current period.

[0117] Calculate the posterior covariance and process noise covariance of the previous period. The sum of these is taken as the prior covariance for this period. Then, the sum of the prior covariance and the adaptive measurement noise covariance is calculated, and the proportion of the prior covariance to the total sum is the Kalman gain.

[0118] Extract the residual values ​​of the most recent frames from the residual sliding window, and compare the difference between their maximum and minimum values ​​to determine the degree of drastic change in recent measurement noise or load.

[0119] Based on the residual volatility, determine the adaptive measurement covariance for this period: When residual fluctuations are small and measurements are stable, the measurement covariance remains at or below the measurement noise covariance. The measurement noise covariance is used as the adaptive measurement covariance for this period.

[0120] When the residual fluctuation is large, it is proportional. Increase measurement covariance to generate adaptive measurement covariance for the current cycle. .

[0121] A simple state identity prediction method is used, which calculates the posterior covariance of the previous period and the process noise covariance. The sum of these values ​​serves as the prior covariance for this period.

[0122] Based on the predicted covariance and the updated measurement covariance, a gain coefficient is calculated. The sum of the prior covariance and the adaptive measurement noise covariance is then calculated; the proportion of the prior covariance to the total sum is the Kalman gain. The difference between the prior predicted state vector and the new filtered estimated vector is calculated; the product of this difference and the Kalman gain is the offset of the prior predicted state vector. After the offset is completed, the posterior estimate for the current cycle is obtained. .

[0123] The updated posterior estimate for this period smooths out noise, responds quickly to actual load changes, and maintains the advantage of minimal computational cost.

[0124] The residual range assessment is simple and intuitive, requiring only two comparisons to obtain the measurement trend. It does not require complex statistics and is suitable for resource-constrained meter MCUs.

[0125] Adaptive covariance allows the filter to dynamically adjust its confidence in the measurement and prediction, ensuring that it does not overtrack in high noise conditions and converges quickly in low noise conditions.

[0126] It balances computational complexity and estimation accuracy, making it more suitable for smart meter scenarios in smart campuses that require rapid closed-loop control at the edge.

[0127] S6: Map the normalized error energy to the perceptual behavior of CT and PT.

[0128] Specifically, the sensing behavior of mapping normalized error energy to CT and PT includes: reading the current error energy from the state region, the Kalman filter posterior covariance, and the latest current and voltage estimates.

[0129] Error energy is divided into three levels: low, medium, and high, to distinguish between stable, transitional, and drastic fluctuation states.

[0130] Select the corresponding sampling period, ADC resolution, analog front-end bandwidth, sensor excitation voltage, and communication period according to the level.

[0131] Write the timer reload register, ADC control register, front-end control register, and communication scheduling register sequentially within the critical section.

[0132] Once the configuration is complete, begin the next round of perception control.

[0133] Furthermore, input error energy Adaptive measurement covariance Posterior estimation Previous sampling period , communication cycle .

[0134] Dynamically adjust the sampling period within the new period ADC resolution and analog front-end bandwidth, sensor excitation voltage, communication cycle And the reporting method.

[0135] First, error normalization and mapping triggering will determine the current error energy. The normalized index is generated by comparing the ratio of the maximum error energy upper limit obtained during the initialization phase with the value obtained during the initialization phase.

[0136] Based on the normalization interval in Table 1 where the normalized index falls, the system automatically determines whether to enter the low, medium, or high control strategy.

[0137] Dynamic sampling frequency adjustment extends the sampling period at low error levels to reduce wake-up and measurement frequency. At high error levels, it shortens the sampling period to accelerate sensing response. The adjustment takes effect by writing a new reload value (ARR) to the timer and immediately clearing the counter.

[0138] Based on the new sampling period, the bandwidth of the front-end programmable gain amplifier (PGA) or filter is dynamically set so that it neither excessively truncates the signal nor excessively amplifies the noise.

[0139] After writing to the corresponding hardware register, wait for tens of microseconds to ensure stability.

[0140] By combining the normalized error settings, different voltage levels can be output through the MCU's internal DAC or an external excitation module: Once the excitation voltage change is complete, the next data acquisition will begin.

[0141] Enable batch reporting in low error settings: send accumulated data only when a new communication cycle expires.

[0142] Enable real-time upload when the error level is high: trigger single data upload immediately after each sampling is completed.

[0143] Reconfigure the operating system or hardware timer heartbeat / interrupt to stop old tasks and start new schedules.

[0144] Table 1 Control Quantization Mapping Table gear Normalized interval Sampling period Front-end bandwidth (BW) Excitation voltage communication cycle Reporting mode low-end [0.00,0.3] 30 s 0.5 / 30 ≈ 0.017 Hz 2.5 V 60 s Batch reporting Mid-range (0.3,0.7] 10 s 0.5 / 10 = 0.05 Hz 4.0 V 20 s Batch reporting upscale (0.7,1] 1 s 0.5 / 1 = 0.50 Hz 5.0 V 1 s Real-time reporting Table 1 shows a quantization control method in one feasible embodiment.

[0145] The updated sampling period, bandwidth settings, excitation voltage, and communication mode are stored in the RAM parameter area. After completion, the system automatically returns to S2 to start the next round of closed-loop sensing and control.

[0146] Please see Figure 2 This embodiment also provides a smart meter sensor sensing and control system based on an improved algorithm, including: an initialization module, a threshold sampling module, a rejection module, a composite filtering module, a prediction module, and a sensing mapping module. The initialization module is used to configure the MCU timer to automatic reload mode and enable update interrupt, configure the ADC to be a dual-channel scan triggered by current sensor CT and voltage sensor PT for DMA acquisition, take the arithmetic mean of each channel as the static bias, and set the spike rejection threshold in the parameter area.

[0147] The threshold sampling module is used to construct a sliding window to correct interference rejection thresholds for small and large fluctuations in real time after the MCU completes self-test and starts the timer to enter real-time monitoring. Based on the interference rejection threshold, it adaptively switches between three resolutions and performs dual-channel synchronous acquisition, and inputs the sampling results into the circular buffer.

[0148] The elimination module is used to perform single-frame median elimination on newly sampled data in the buffer, and automatically triggers resampling when the deviation of consecutive frames exceeds the limit.

[0149] The composite filtering module adjusts the measurement noise covariance in real time based on residual statistics, performs lightweight Kalman prediction and correction at the MCU, and outputs high-confidence state estimates of current and voltage.

[0150] The prediction module is used to adjust the measurement noise covariance in real time based on residual statistics, perform lightweight Kalman prediction and correction on the MCU, and output high-confidence state estimates of current and voltage.

[0151] The perception mapping module is used to map the normalized error energy to the perception behavior of CT and PT.

[0152] This embodiment also provides a computer device, including: a memory and a processor; the memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to realize the smart meter sensor sensing and control method based on the improved algorithm proposed in the above embodiment.

[0153] The computer device can be a terminal, comprising a processor, memory, communication interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, carrier networks, NFC (Near Field Communication), or other technologies. The display screen can be an LCD screen or an e-ink screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad on the computer device's casing, or an external keyboard, touchpad, or mouse.

[0154] This embodiment also provides a storage medium storing a computer program, which, when executed by a processor, implements the smart meter sensor sensing and control method based on the improved algorithm proposed in the above embodiment. The storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read Only Memory (EPROM), Programmable Red-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.

[0155] In summary, this invention achieves online threshold updating and dynamic ADC resolution switching based on filter residual statistics through dynamic threshold self-calibration and adaptive sampling. During timed interrupts, it automatically sets different sampling precision levels based on the residual window results, ensuring high-quality sampling under both stable and abrupt conditions, thus achieving a balance between accuracy and power consumption. Through normalized error-driven closed-loop multidimensional parameter mapping and hardware configuration steps, it realizes closed-loop adjustment of end-side parameters based on real-time error energy. This maps the error energy to configuration registers for sampling period, ADC bit width, analog bandwidth, excitation voltage, and communication period, ensuring seamless switching and rapid response to different dynamic scenarios, and improving the stability and robustness of sensing and control. It is suitable for the complex power consumption conditions of laboratory buildings, dormitories, and teaching buildings on campus.

[0156] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.

Claims

1. A sensor sensing and control method for smart meters based on an improved algorithm, characterized in that: include: Configure the MCU timer to auto-reload mode and enable update interrupt; configure the ADC to perform DMA acquisition and set static bias and spike rejection threshold. After the MCU completes its self-test and starts the timer to enter real-time monitoring, a sliding window is constructed to correct the interference rejection threshold in real time. The ADC resolution is selected according to the interference rejection threshold and dual-channel synchronous acquisition is performed. Perform single-frame median culling on newly sampled data in the buffer, and automatically trigger resampling when the deviation of consecutive frames exceeds the limit; The measurement data after rejection are first subjected to median filtering, then adaptive low-pass filtering, while the measurement residual energy is accumulated within the sliding time window. Based on the residual statistical index, the measurement noise covariance is adjusted in real time, and lightweight Kalman prediction and correction are performed at the MCU to output high-confidence state estimates of current and voltage. The normalized error energy is mapped to the perceptual behavior of CT and PT.

2. The smart meter sensor sensing and control method based on the improved algorithm as described in claim 1, characterized in that: The configuration of ADC for DMA acquisition and setting of static bias and spike rejection thresholds includes: acquiring ADC values ​​for CT and PT channels under no-load conditions, and calculating the arithmetic mean of the sampled values ​​of each channel as current and voltage biases, respectively. The spike rejection threshold is set by the transient spike amplitude; Write the current and voltage biases to RAM, clear the self-test flag, and start the timer.

3. The smart meter sensor sensing and control method based on the improved algorithm as described in claim 2, characterized in that: The process of constructing a sliding window to correct the interference removal threshold in real time, selecting the ADC resolution based on the interference removal threshold, and performing dual-channel synchronous acquisition includes: retrieving the filtered residual sequence of the most recent 10 frames from RAM. ,in, This represents the residual of the previous frame. This represents the residual of the first ten frames; Calculate the kurtosis, 10th percentile, and 90th percentile of the filtered residual sequence, and set them as small fluctuation thresholds. and large fluctuation threshold ; When the timer interrupts, the residual from the previous reading is read, compared with two threshold values, the ADC resolution is selected, written to the ADC register, and dual-channel synchronous acquisition is triggered. The acquired raw ADC value is then subtracted from the bias and converted into current. and voltage Get the timestamp and input the sampling result into the circular buffer.

4. The smart meter sensor sensing and control method based on the improved algorithm as described in claim 3, characterized in that: The process of performing single-frame median removal on newly sampled data in the buffer includes: retrieving the earliest enqueued measurement vector from the circular queue. Composite filtering estimation with the previous round of perception control Calculate the corresponding residuals ; Construct a median window of length 3 Find the median values ​​for the current and voltage components respectively, and replace them with the median values. The corresponding component in the middle; The residuals after median removal are then written into a sliding window of length 5, and the values ​​exceeding the spike removal threshold are counted. The number of frames; If the statistical value If the residual window is cleared and quantization sampling is immediately re-executed, then the statistical value... Then for the vector after elimination Perform median filtering.

5. The smart meter sensor sensing and control method based on the improved algorithm as described in claim 4, characterized in that: The process of first performing median filtering and then adaptive low-pass filtering on the removed measurement data includes: [The text abruptly ends here, likely due to an incomplete sentence or a formatting error.] Together with the vectors discarded from the previous two frames, a sliding window of length 3 is formed. The median of the current and voltage components is calculated separately, and the filtered median vector is output. ; Based on the output filter median vector Adjusting the filter gain based on the amplitude difference estimated by the composite filter from the previous round of perception control will... The latest composite filter estimate is generated by proportionally weighting and fusing the previous composite filter output. ; Calculate the residual of the current frame And the square of the current frame residual is accumulated into a 5-frame sliding time window; The real-time quantization error energy is calculated based on the sum of squared residuals of all frames within the window and the window duration. ; Composite filter estimation Updated residual sliding window and real-time quantization error energy Store in the status area.

6. The smart meter sensor sensing and control method based on the improved algorithm as described in claim 5, characterized in that: The process of performing lightweight Kalman prediction and correction on the MCU side and outputting high-confidence state estimation of current and voltage includes: reading all residual values ​​in a 5-frame residual sliding window and calculating the difference between the maximum and minimum residuals respectively; The difference is mapped to the measurement noise covariance according to a preset ratio, and the adaptive measurement covariance generated in this cycle is adjusted. Using the posterior estimate of the previous perception control as the prior state, the prior covariance is updated by loading the process noise covariance, thus generating the prior estimate and the prior covariance. The Kalman gain is calculated based on the adaptive measurement covariance and the measurement vector after cleaning and filtering in the current frame. The prior estimate is fused with the current frame's cleaned and filtered measurement vector using gain weighting to output the posterior estimated state vector, while simultaneously updating the posterior covariance.

7. The smart meter sensor sensing and control method based on the improved algorithm as described in claim 6, characterized in that: The sensing behavior of mapping the normalized error energy to CT and PT includes: reading the real-time quantized error energy, the posterior estimated state vector, and the posterior covariance from the state region; The real-time quantization error energy is divided into error levels; Select the corresponding parameter to be adjusted based on the error level and the uncertainty level of the posterior covariance; Adjust the sensing gain and excitation voltage of CT and PT; After configuration, the next round of perception control begins. Before starting, the composite filter estimate, posterior estimate state vector, posterior covariance, and adaptive measurement noise covariance are written back to the state area.

8. A smart meter sensor sensing and control system based on an improved algorithm, based on the smart meter sensor sensing and control method based on the improved algorithm as described in any one of claims 1 to 7, characterized in that: It includes an initialization module, a threshold sampling module, a rejection module, a composite filtering module, a prediction module, and a perception mapping module; The initialization module is used to configure the MCU timer to automatic reload mode and enable update interrupt, configure the ADC to perform DMA acquisition and set static bias and spike rejection threshold. The threshold sampling module is used to construct a sliding window to correct the interference rejection threshold in real time after the MCU completes self-test and starts the timer to enter real-time monitoring, and select the ADC resolution and perform dual-channel synchronous acquisition according to the interference rejection threshold. The elimination module is used to perform single-frame median elimination on newly sampled data in the buffer, and automatically triggers resampling when the deviation of consecutive frames exceeds the limit. The composite filtering module adjusts the measurement noise covariance in real time based on residual statistics, performs lightweight Kalman prediction and correction at the MCU, and outputs high-confidence state estimates of current and voltage. The prediction module is used to adjust the measurement noise covariance in real time based on the residual statistical index, perform lightweight Kalman prediction and correction at the MCU end, and output high-confidence state estimates of current and voltage. The perception mapping module is used to map the normalized error energy to the perception behavior of CT and PT.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, it implements the steps of the smart meter sensor sensing and control method based on the improved algorithm as described in any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by the processor, it implements the steps of the smart meter sensor sensing and control method based on the improved algorithm as described in any one of claims 1 to 7.

Citation Information

Cited By

  • Method, device and equipment for evaluating uncertainty of measurement result of electric power measurement equipment

    CN121432320A