Sampling signal anomaly detection method for electric energy meter, medium and terminal
By employing a random starting point truncation method and a lightweight neural network in the electricity meter, the time alignment problem of sampling signal anomaly detection in the prior art is solved, realizing efficient and low-resource-consumption anomaly detection, which is suitable for power metering systems.
Patent Information
- Application Number
- CN202511449889.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-11
- Publication Date
- 2026-02-13
AI Technical Summary
Existing methods for detecting anomalies in electricity meter sampling signals require time alignment, have poor generalization ability, strong data dependence, and high resource consumption.
A random starting point truncation method is adopted to select two sampling points at different positions from a continuous digital voltage sampling stream, forming a difference vector as the input of a neural network. Anomaly detection is performed through a custom neural network model, and one-hot encoded labels and a lightweight network are used for classification. The balanced partitioning of the training set and the test set enables anomaly detection without time alignment.
It achieves sampling signal anomaly detection without time alignment, has strong generalization ability, low resource consumption, is suitable for micro-computing embedded devices, and simplifies the maintenance of electricity meters and the localization of metering chip problems.
Smart Images

Figure CN121522564A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of power metering technology, and in particular relates to a method, medium and terminal for detecting abnormal sampling signals of electricity meters. Background Technology
[0002] As the core equipment of the power metering system, the quality of the sampling signal of the electricity meter directly determines the fairness, accuracy, and legal validity of electricity metering. With the deepening of the intelligent transformation of the power system and the refinement of the granularity of electricity market transactions (such as time-of-use pricing and demand management), higher requirements are placed on the millisecond-level accuracy and long-term operational stability of the sampling signal.
[0003] In real-world operating environments, sampled signals face multiple interference threats, such as transient disturbances, baseline drift, transmission loss, and high-frequency contamination. All of these can cause anomalies in the sampled signals, thus affecting the accuracy of electricity metering. To ensure the accuracy of electricity metering and the effectiveness of its functional expansion, it is essential to prioritize and optimize anomaly detection methods for electricity meter sampling signals. Existing detection methods mainly include threshold comparison methods, statistical analysis methods, signal processing-related methods, Empirical Mode Decomposition (EMD) and its improved versions, signal filtering and abrupt change detection techniques, and pattern recognition and machine learning techniques. All of these methods require time alignment of the sampled period signals, have poor generalization ability, strong data dependence, and high resource consumption. Patent CN118536046B discloses a method, device, meter, and medium for identifying abnormal jumps in electricity meter sampling signals. The method involves acquiring electrical signals from at least two consecutive sampling periods; then aligning the electrical signals of the sampling periods to ensure that each time point in two adjacent new periods corresponds to a sampling point; after alignment, obtaining the difference between the amplitudes of the electrical signals corresponding to the target sampling points at the same time points in two adjacent new periods; and determining that an abnormal jump exists in the target sampling point if the difference exceeds a threshold. However, this patent also requires alignment of the sampling period signals, failing to consider that sampling points within consecutive periods may differ. Therefore, the alignment method used is ineffective and suffers from the same drawbacks as existing technologies.
[0004] Therefore, how to provide a method for detecting abnormal energy meter sampling signals that has strong generalization ability, does not rely on historical data, and consumes less resources is a problem that urgently needs to be solved by people in this technical field. Summary of the Invention
[0005] To address the shortcomings of existing technologies, the purpose of this invention is to provide a method for detecting abnormal sampling signals in electricity meters, thereby solving the problems of existing methods requiring time alignment, poor generalization ability, strong data dependence, and high resource consumption. In addition, this invention also provides a medium and terminal for detecting abnormal sampling signals in electricity meters.
[0006] To solve the above-mentioned technical problems, the present invention adopts the following technical solution:
[0007] In a first aspect, the present invention provides a method for detecting abnormal sampling signals in an electricity meter, comprising the following steps:
[0008] S10, the ADC sampling chip samples the voltage and current signals of the power meter's connected circuit;
[0009] S20. From the continuous digital voltage sampling stream, select two different positions, and extract several sampling points from the two different positions, respectively as the data window of the previous cycle and the data window of the current cycle;
[0010] S30. Subtract the value of each sampling point in the current cycle from the value of the sampling point at the corresponding position in the previous cycle to form a difference vector, and use the difference vector as the input to the neural network.
[0011] S40, a custom neural network model, with fully connected layers outputting one-hot encoded labels;
[0012] S50. Collect basic data, divide the data into windows and generate abnormal data, simulate abnormal situations, generate difference data and label it, balance the dataset and divide it into training and test sets.
[0013] S60. Train the anomaly detection model batch by batch on the training set, monitor the training in real time and verify the loss and accuracy, and periodically evaluate the classification accuracy, confusion matrix and recall of each category on the test set.
[0014] Furthermore, in step S20, a starting position is randomly selected. Cut off from this position Each sampling point serves as a window of data for the previous period, where... Sampling frequency, For power grid frequency; from location Start, continuously intercept Each sampling point serves as the data window for the current period.
[0015] Furthermore, in step S30, the difference between each sampling point value in the current period and the corresponding sampling point value in the previous period is calculated to form a value of length [missing information]. difference vector ,in ,in Let i be the difference vector of length i. This represents the value of the i-th sampling point in the current period. This is the value of the i-th sampling point in the previous period.
[0016] Furthermore, the difference vector The input dimension is .
[0017] Furthermore, in S40, the neural network model includes an input layer, hidden layer 1, hidden layer 2, and an output layer, wherein the dimension of the input layer is... The dimensions of hidden layer 1 and hidden layer 2 are... The dimension of the output layer is The activation function chosen is ReLU.
[0018] Furthermore, the encoding of the unique hot-coded tag includes 0000, 0001, 0010, 0100 and 1000, where 0000 represents the normal state, 0001 represents the missing abnormal state, 0010 represents the jitter abnormal state, 0100 represents the mutation abnormal state and 1000 represents the noise abnormal state.
[0019] Furthermore, the specific steps of S50 are as follows:
[0020] S501. Use an energy meter to collect voltage / current and other related waveform data under real mains power conditions;
[0021] S502. The collected waveform data is divided into time series sliding window blocks, and three complete power frequency cycles of data are extracted as a sample unit each time.
[0022] S503. Simulate different types of abnormal states one by one in the second cycle of data;
[0023] S504. Generate two sets of difference data for each sample unit. Each set of difference data is labeled with the corresponding anomaly type label, and the anomaly location and attributes are recorded.
[0024] S505. Set the ratio of normal sample data to abnormal sample data to 1:1, and set the internal ratio of abnormal sample data as follows: missing class: mutation class: noise class: mixed class to 1:1:1:1. Then divide the dataset into training set and test set in a ratio of 7:3.
[0025] Furthermore, in S60, the loss function for training the anomaly detection model is the cross-entropy loss function, the optimizer is Adam, the initial learning rate is set to 1e-3, and it is dynamically decayed.
[0026] In a second aspect, the present invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method described above.
[0027] Thirdly, the present invention also provides an electronic terminal, comprising: a processor and a memory; the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory to cause the terminal to perform the method described above.
[0028] The method for detecting abnormal sampling signals in electricity meters provided by this invention has at least the following advantages compared with the prior art:
[0029] Existing methods for detecting anomalies in electricity meter sampling signals require time alignment of the sampling period signals, resulting in poor generalization ability, strong data dependency, and high resource consumption. This invention offers a simple and convenient process. By employing a random starting point truncation method, it solves the problem of time alignment required for the sampling period signals in existing methods. The one-hot encoded tag contains multiple anomaly types in the sampling signals, greatly facilitating subsequent electricity meter maintenance and the location of metering core issues. Through a combination of difference vectors and lightweight networks, using the difference signal from the voltage sampling signal, it effectively reflects the characteristics of the anomaly location. Only a simple two-layer network is needed to achieve excellent accuracy, facilitating deployment in embedded devices with low computing power. The entire invention eliminates the need for time alignment during the detection process, exhibits strong generalization ability, is independent of historical data, and consumes relatively few resources. Attached Figure Description
[0030] To more clearly illustrate the solutions of the present invention, a brief introduction will be given to the drawings used in the description of the embodiments below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0031] Figure 1 A flowchart of a method for detecting abnormal sampling signals in an electricity meter, provided as an embodiment of the present invention;
[0032] Figure 2 This is a schematic diagram of a custom neural network model structure in a method for detecting abnormal sampling signals of an electricity meter, provided in an embodiment of the present invention. Detailed Implementation
[0033] To facilitate understanding of the present invention, a more complete description will be given below with reference to the accompanying drawings. Preferred embodiments of the invention are shown in the drawings. However, the invention can be implemented in many different forms and is not limited to the embodiments described herein. Rather, these embodiments are provided to provide a thorough and complete understanding of the disclosure of the invention.
[0034] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein in the description of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention.
[0035] This invention provides a method for detecting abnormal sampling signals in electricity meters. Applied to the process of detecting abnormal sampling signals in electricity metering, the method includes the following steps:
[0036] S10. The ADC sampling chip samples the voltage and current signals of the electricity meter's connected circuit. S20. From the continuous digital voltage sampling stream, two different positions are selected, and several sampling points are extracted from these two positions, serving as the data window for the previous cycle and the data window for the current cycle, respectively. S30. The difference between each sampling point value in the current cycle and the corresponding sampling point value in the previous cycle is calculated to form a difference vector, which is then used as the input to the neural network. S40. A custom neural network model is defined, with fully connected layers outputting one-hot encoded labels. S50. Basic data is collected, windows are divided, and abnormal data is generated. Abnormal situations are simulated, difference data is generated and labeled, the dataset is balanced, and training and test sets are divided. S60. The anomaly detection model is trained batch by batch on the training set, with real-time monitoring of training and verification of loss and accuracy. On the test set, classification accuracy, confusion matrix, and recall metrics for each category are periodically evaluated.
[0037] The present invention has a simple process, is easy to operate, does not require time alignment during the inspection process, has strong generalization ability, does not rely on historical data, and consumes less resources.
[0038] To enable those skilled in the art to better understand the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings.
[0039] This invention provides a method for detecting abnormal sampling signals in electricity meters, applied in the process of detecting abnormalities in electricity meter sampling signals, combined with... Figure 1 and Figure 2 In this embodiment, the method for detecting abnormal sampling signals of the electricity meter includes the following steps:
[0040] S10, the ADC sampling chip samples the voltage and current signals of the power meter's connected circuit.
[0041] Specifically, in this embodiment, the electricity meter integrates a high-precision ADC (analog-to-digital converter) sampling chip to sample the voltage and current signals of the electricity meter's connected circuit in real time, providing basic data for subsequent processing. The sampling frequency is set to... It can accurately capture power frequency and its main harmonic components.
[0042] S20. Select two different positions from the continuous digital voltage sampling stream, and extract several sampling points from the two different positions to serve as the data window of the previous cycle and the data window of the current cycle, respectively.
[0043] Specifically, in this embodiment, a starting position is first randomly selected from the continuous digital voltage sampling stream. Cut off from this position (Round up) sampling points are used as the data window for the previous period, where This refers to the power grid frequency (e.g., 50 Hz). Secondly, from the perspective of location... Start, then continuously extract Each sampling point is used as the data window for the current period. Finally, the difference between each sampling point value in the current period and the corresponding sampling point value in the previous period is calculated to form a data window of length [length missing]. difference vector ,in: Difference vectors can highlight the differences between abnormal and normal signals, especially in abnormal situations such as signal distortion, waveform abrupt changes, and noise interference.
[0044] S30. Subtract the value of each sampling point in the current cycle from the value of the corresponding sampling point in the previous cycle to form a difference vector, and use the difference vector as the input to the neural network.
[0045] Specifically, in this embodiment, the difference vector As input to the neural network, the input dimension is... .
[0046] Furthermore, in this embodiment, the network structure adopts a minimalist design to adapt to the computing power of the embedded chip of the energy meter. The number of network parameters is small and the inference latency is low, which can meet the real-time and resource consumption requirements of micro-computing embedded hardware (such as low-power MCUs and dedicated metering SoCs).
[0047] In this embodiment, the neural network model includes an input layer, hidden layer 1, hidden layer 2, and an output layer, wherein the dimension of the input layer is... The dimensions of hidden layer 1 and hidden layer 2 are... The dimension of the output layer is The activation function chosen is ReLU.
[0048] S40, a custom neural network model, with fully connected layers outputting one-hot encoded labels.
[0049] Specifically, in this embodiment, the fully connected layer outputs one-hot encoded labels. The label types include different anomaly types (such as loss, jitter, mutation, noise interference) and normal states. The encoding of the classification network output results is shown in Table 1 below.
[0050] Table 1
[0051] coding meaning 0000 Indicates normal state 0001 Indicates a missing abnormal state 0010 Indicates an abnormal jitter state 0100 Indicates a mutational abnormal state 1000 Indicates abnormal noise status
[0052] As shown in Table 1 above, the codes of the unique hot-coded tags include 0000, 0001, 0010, 0100 and 1000, where 0000 represents the normal state, 0001 represents the missing abnormal state, 0010 represents the jitter abnormal state, 0100 represents the mutation abnormal state and 1000 represents the noise abnormal state.
[0053] S50. Collect basic data, divide the data into windows and generate abnormal data, simulate abnormal situations, generate difference data and label it, balance the dataset and divide it into training and test sets.
[0054] Specifically, in this embodiment, step S50 consists of the following steps:
[0055] S501. Use an energy meter to collect voltage / current and other relevant waveform data under real mains power conditions. The collected data should cover normal operating conditions under different time periods and load states with multiple energy meters. The data sampling frequency should be... It accurately captures power frequency and major harmonics, and the collected data serves as a baseline sample for normal data. Its advantages include compatibility with power grid frequency fluctuations (49.5-50.5Hz), allowance for variations in the number of period points (±1 point), and elimination of the influence of clock crystal oscillator errors.
[0056] S502. Extract the acquired waveform data using a time-series sliding window, extracting 3 complete power frequency cycles each time. Data from 1 sampling point is taken as a sample unit, and the three periods within the sample unit are analyzed:
[0057] First cycle data: Maintain the original normal waveform;
[0058] Second period data: artificially simulated abnormal situations;
[0059] The third cycle of data: maintain the original normal waveform.
[0060] S503. In the second period of data, simulate different types of anomalies one by one:
[0061] Missing values / jitter: Randomly select several sampling points at different positions within the period, set them to zero, set them to default values, or simulate them with perturbation by previous and next points to cover different missing positions and enhance the model's generalization ability.
[0062] Abrupt changes: Insert amplitude abrupt changes (positive increase, negative decrease) at different positions within the period, and record the position and direction of the abrupt change points. The abrupt change amplitude should cover both small and large abrupt changes.
[0063] Noise interference: High-frequency or random noise is superimposed at different locations, and the noise amplitude range is divided into different intervals (such as low noise, medium noise, and high noise) to cover a variety of noise levels.
[0064] S504. Generate two sets of difference data for each sample unit.
[0065] Group 1: Subtract the data from the first period's data point by point from the data from the second period:
[0066]
[0067] Group 2: Subtract the data from the second period's data point by point:
[0068]
[0069] Each set of difference data is labeled with the corresponding anomaly type (such as missing, mutation, noise), and the anomaly location and attributes (such as mutation direction, noise interval, etc.) are recorded.
[0070] S505, Normal sample data : Abnormal sample data = 1 : 1;
[0071] The internal ratio of outlier samples: missing data: mutation data: noise data: mixed data = 1:1:1:1;
[0072] The final dataset is divided into training and testing sets in a 7:3 ratio to ensure a balanced distribution of each class of data between the training and testing sets.
[0073] S60. Train the anomaly detection model batch by batch on the training set, monitor the training in real time and verify the loss and accuracy, and periodically evaluate the classification accuracy, confusion matrix and recall of each category on the test set.
[0074] Specifically, in this embodiment, the model training is performed as follows:
[0075] Model input: Each sample is a difference vector (length = number of periodic sampling points, such as 128), and the label is the one-hot encoding of the corresponding abnormal type or normal category (e.g., 5 categories: normal, missing, mutation, noise, and mixed).
[0076] Network structure: Input layer is 1×128; Hidden layer 1 is 1×64, fully connected, with ReLU activation function; Hidden layer 2 is 1×32, fully connected, with ReLU activation function; Output layer is 1×5, fully connected + softmax activation, used for multi-class probability output.
[0077] Training configuration: loss function is cross-entropy loss (multi-class categorical crossentropy); optimizer is Adam; initial learning rate is set to 1e-3, with dynamic decay.
[0078] This invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the methods in this embodiment.
[0079] This invention also provides an electronic terminal, including: a processor and a memory; the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that the terminal performs any of the methods in this embodiment.
[0080] As will be understood by those skilled in the art, the computer-readable storage medium described in this embodiment allows for the implementation of all or part of the steps in the above method embodiments by computer program-related hardware. The aforementioned computer program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.
[0081] The electronic terminal provided in this embodiment includes a processor, a memory, a transceiver, and a communication interface. The memory and the communication interface are connected to the processor and the transceiver and complete communication between them. The memory is used to store computer programs, the communication interface is used to perform communication, and the processor and the transceiver are used to run the computer programs, so that the electronic terminal performs the steps of the above method.
[0082] The sampling signal anomaly detection method for electricity meters described in the above embodiments, compared with the prior art, requires time alignment of the sampling period signals in the prior art, resulting in poor generalization ability, strong data dependence, and high resource consumption. The present invention features a simple process and convenient operation. By using a random starting point interception method, it solves the problem of time alignment required for the sampling period signals in existing methods. The one-hot encoded tag contains multiple anomaly types of sampling signals, greatly facilitating subsequent electricity meter maintenance and the location of metering core problems. Through the combination of difference vectors and lightweight networks, using the difference signal of voltage sampling signals, it can effectively reflect the characteristics of the anomaly location. Only a simple two-layer network is needed to achieve excellent accuracy, facilitating the deployment of embedded devices with low computing power. The entire invention does not require time alignment during the detection process, has strong generalization ability, does not rely on historical data, and consumes relatively few resources.
[0083] Obviously, the embodiments described above are merely preferred embodiments of the present invention, and not all embodiments. The accompanying drawings illustrate preferred embodiments of the present invention, but do not limit the scope of the patent. The present invention can be implemented in many different forms; rather, these embodiments are provided to provide a more thorough and complete understanding of the disclosure of the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing specific embodiments, or make equivalent substitutions for some of the technical features. Any equivalent structures made using the content of this specification and drawings, directly or indirectly applied to other related technical fields, are similarly within the scope of patent protection of this invention.
Claims
1. A method for detecting abnormal sampling signals in an electricity meter, characterized in that, Includes the following steps: S10, the ADC sampling chip samples the voltage and current signals of the power meter's connected circuit; S20. From the continuous digital voltage sampling stream, select two different positions, and extract several sampling points from the two different positions, respectively as the data window of the previous cycle and the data window of the current cycle; S30. Subtract the value of each sampling point in the current cycle from the value of the sampling point at the corresponding position in the previous cycle to form a difference vector, and use the difference vector as the input to the neural network. S40, a custom neural network model, with fully connected layers outputting one-hot encoded labels; S50. Collect basic data, divide the data into windows and generate abnormal data, simulate abnormal situations, generate difference data and label it, balance the dataset and divide it into training and test sets. S60. Train the anomaly detection model batch by batch on the training set, monitor the training in real time and verify the loss and accuracy, and periodically evaluate the classification accuracy, confusion matrix and recall of each category on the test set.
2. The method for detecting abnormal sampling signals in an electricity meter according to claim 1, characterized in that, In step S20, a starting position is randomly selected. Cut off from this position Each sampling point serves as a window of data for the previous period, where... Sampling frequency, For power grid frequency; from location Start, continuously intercept Each sampling point serves as the data window for the current period.
3. The method for detecting abnormal sampling signals in an electricity meter according to claim 1, characterized in that, In step S30, the difference between each sampling point value in the current period and the corresponding sampling point value in the previous period is calculated to form a result of length [missing value]. difference vector ,in ,in Let i be the difference vector of length i. This represents the value of the i-th sampling point in the current period. This is the value of the i-th sampling point in the previous period.
4. The method for detecting abnormal sampling signals in an electricity meter according to claim 3, characterized in that, The difference vector The input dimension is .
5. The method for detecting abnormal sampling signals in an electricity meter according to claim 1, characterized in that, In S40, the neural network model includes an input layer, hidden layer 1, hidden layer 2, and an output layer, wherein the dimension of the input layer is... The dimensions of hidden layer 1 and hidden layer 2 are... The dimension of the output layer is The activation function chosen is ReLU.
6. The method for detecting abnormal sampling signals in an electricity meter according to claim 5, characterized in that, The unique hot-coded tag is encoded in the form of 0000, 0001, 0010, 0100 and 1000, where 0000 represents the normal state, 0001 represents the missing abnormal state, 0010 represents the jitter abnormal state, 0100 represents the mutation abnormal state and 1000 represents the noise abnormal state.
7. The method for detecting abnormal sampling signals in an electricity meter according to claim 1, characterized in that, The specific steps of S50 are as follows: S501. Use an energy meter to collect relevant waveform data such as voltage / current; S502. The collected waveform data is divided into time series sliding window blocks, and three complete power frequency cycles of data are extracted as a sample unit each time. S503. Simulate different types of abnormal states one by one in the second cycle of data; S504. Generate two sets of difference data for each sample unit. Each set of difference data is labeled with the corresponding anomaly type label, and the anomaly location and attributes are recorded. S505. Set the ratio of normal sample data to abnormal sample data to 1:1, and set the internal ratio of abnormal sample data as follows: missing class: mutation class: noise class: mixed class to 1:1:1:
1. Then divide the dataset into training set and test set in a ratio of 7:
3.
8. The method for detecting abnormal sampling signals in an electricity meter according to claim 1, characterized in that, The loss function for training the anomaly detection model in S60 is the cross-entropy loss function, the optimizer is Adam, and the initial learning rate is set to 1e-3, with dynamic decay.
9. A computer-readable storage medium, characterized in that, The storage medium stores a computer program that, when executed by a processor, implements the method as described in any one of claims 1 to 8.
10. An electronic terminal, characterized in that, include: Processor and memory; The memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory to cause the terminal to perform the method as described in any one of claims 1 to 8.
Citation Information
Patent Citations
Method, device, electric energy meter and medium for identifying abnormal jump of electric energy meter sampling signal
CN118536046B