Power waveform zero-crossing detection method and system under wide-frequency harmonics

By combining the Transformer model with ambient temperature and humidity information, the accuracy and versatility issues of zero-crossing point detection of power waveforms under wide-frequency harmonics are solved, achieving high-precision zero-crossing point detection and improving system stability.

CN119534980BActive Publication Date: 2025-09-30STATE GRID JIANGSU ELECTRIC POWER CO LTD MARKETING SERVICE CENT +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411621765.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-14
Publication Date
2025-09-30
Estimated Expiration
2044-11-14

AI Technical Summary

Technical Problem

The existing power waveform zero-crossing point detection method is difficult to accurately detect the zero-crossing point in a wide-band harmonic environment, resulting in a decrease in frequency detection accuracy. In addition, the existing algorithm lacks versatility and effectiveness in different environments.

Method used

The Transformer model is used to detect the zero-crossing point of the power waveform. By collecting ambient temperature and humidity information, word embedding and learnable position embedding methods are used to establish the input sequence. Mask processing and noise training are used to improve the generalization and noise suppression capabilities of the model.

Benefits of technology

It achieves high-precision zero-crossing point detection in a wide-frequency harmonic environment, reduces prediction errors, improves the stability and prediction capability of the power system, and enhances the ability to suppress noise and interference.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119534980B_ABST
    Figure CN119534980B_ABST
Patent Text Reader

Abstract

A method and system for detecting the zero-crossing point of an electric power waveform under wide-frequency domain harmonics takes a data unit vector, a quantized embedding vector of the ambient temperature, a quantized embedding vector of the ambient relative humidity, and a weighted sum of position codes as an input sequence; according to the set mask processing ratio and noise processing ratio, the unit segments containing the zero-crossing point of the electric power waveform in the input sequence are replaced with different types of noise and then input into a trained Transformer model, with the starting point position of the unit segment containing the zero-crossing point of the electric power waveform as the label value of the input sequence; the model output sequence includes: the predicted data of the unit segment containing the zero-crossing point of the electric power waveform in the input sequence, and the label value of the output sequence is the predicted value of the distance from the starting point position of the unit segment containing the zero-crossing point of the electric power waveform to the zero-crossing point of the electric power waveform; the sum of the label value of the input sequence and the label value of the output sequence is the predicted value of the zero-crossing point of the electric power waveform, thereby reducing the amount of data labeling and improving the generalization ability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of power quality detection, and in particular, relates to a method and system for detecting zero-crossing points of an electric power waveform under the influence of wide-frequency domain harmonics. Background Art

[0002] With the comprehensive construction of new power systems and the widespread integration of distributed energy resources, the number of power electronic devices with impact, nonlinear, and unbalanced characteristics has rapidly increased in power systems. Grid harmonics are gradually showing new characteristics such as a widening of the harmonic frequency domain and an increase in the content of medium and high-frequency harmonics. This causes signal jitter and multiple zero crossings, affecting the accuracy of frequency detection. Furthermore, nonlinear electrical devices in daily life exhibit high power fluctuations and distortion, seriously affecting the accuracy of energy metering.

[0003] Existing frequency detection methods include complex algorithms such as Fourier transforms, filter design algorithms, phase-locked loops, and optimal estimation. However, these methods fail to meet metrological requirements. Zero-crossing detection is the foundation of frequency detection and can be directly used for frequency estimation. Once the zero crossing of an AC signal is accurately detected, the signal's frequency information is obtained by measuring the time interval between consecutive zero crossings. Existing zero-crossing detection methods primarily rely on mathematical statistics. By performing numerical statistics and threshold determination on multiple data points near the zero point of the signal, they ignore the precise location of the zero crossing and the accuracy of the single-point signal value, resulting in poor performance in suppressing signal noise and interference. Digital sinusoidal signal frequency measurement based on univariate linear regression theory is based on the fundamental principle that sinusoidal signals can be approximately linearized near zero crossings. After roughly detecting the zero crossing location, the signal values ​​near the zero crossing are subjected to univariate linear regression analysis to obtain the intercept of the signal on the time axis, which is the signal's zero crossing instant. The time difference between different zero crossing instants can be used to accurately calculate the signal period and, therefore, the frequency. This method relies on the approximate linearization of the sinusoidal signal near its zero crossing. For high-frequency noise or other higher-frequency harmonic components, the signal's zero crossing may no longer appear linear, leading to increased errors in the regression analysis results. Zero-crossing detection for signals with intertwined amplitude and phase variations involves applying a narrowband filter to effectively filter out both high- and low-order harmonics. This normalizes the signal to eliminate interference from harmonics, noise, and sudden amplitude changes on phase detection. To improve the accuracy and speed of zero-crossing detection, a threshold is defined: a sampling point is identified as a zero-crossing only if it falls within this region and exhibits no jitter (i.e., continuous jumps) within a specified timeframe. Human-designed filters and thresholds are designed for specific applications, but these fixed designs are difficult to adapt to diverse environments. This makes the selection of filters and thresholds critical, impacting the algorithm's versatility and effectiveness in diverse environments. Summary of the Invention

[0004] In order to address the deficiencies in the prior art, the present invention provides a method and system for detecting the zero-crossing point of an electric power waveform under wide-frequency harmonics, and predicts the zero-crossing point of an electric energy time series waveform based on a Transformer model, thereby solving the technical problems in this field such as the large amount of data labeling and the poor effect and generalization ability of the artificial threshold of the existing algorithms.

[0005] The present invention adopts the following technical solutions.

[0006] The present invention proposes a method for detecting zero-crossing points of a power waveform under wide-frequency harmonics, comprising:

[0007] Step 1: within a detection cycle, sampling the power signal source at a set sampling frequency to obtain multiple data samples;

[0008] Step 2: collecting the actual value of the ambient temperature and the actual value of the ambient relative humidity, and performing quantization processing to obtain the quantized value of the ambient temperature and the quantized value of the ambient relative humidity;

[0009] Step 3: Divide the data sample into multiple data unit vectors, with the same number of data samples in each data unit vector; use a word embedding method to process the quantized value of the ambient temperature and the quantized value of the ambient relative humidity into a quantized embedding vector of the ambient temperature and a quantized embedding vector of the ambient relative humidity, respectively;

[0010] Step 4: Using a learnable position embedding method, determine the position encoding of the data unit vector, the quantized embedding vector of the ambient temperature, and the quantized embedding vector of the ambient relative humidity;

[0011] Step 5: Create an input sequence using the weighted sum of the data unit vector, the quantized embedding vector of the ambient temperature, the quantized embedding vector of the ambient relative humidity, and the position code;

[0012] Step 6: According to the set mask processing ratio and noise processing ratio, any unit segment in the input sequence is replaced with different types of noise and then input into the Transformer model for training; according to the set mask processing ratio and noise processing ratio, the unit segment containing the zero crossing point of the power waveform in the input sequence is replaced with different types of noise and then input into the trained Transformer model, and the starting point position of the unit segment containing the zero crossing point of the power waveform is used as the label value of the input sequence; the output sequence of the trained Transformer model includes: the predicted data of the unit segment containing the zero crossing point of the power waveform in the input sequence, and the label value of the output sequence is the predicted value of the distance from the starting point position of the unit segment containing the zero crossing point of the power waveform to the zero crossing point of the power waveform; the sum of the label value of the input sequence and the label value of the output sequence is used as the predicted value of the zero crossing point of the power waveform.

[0013] Preferably, in step 3, the size of the embedding dictionary corresponding to the quantized value of the ambient temperature is defined as 20, the size of the embedding dictionary corresponding to the quantized value of the ambient relative humidity is defined as 16, and a benchmark word embedding vector with a dimension of 32 is used to embed the quantized value of the ambient temperature and the quantized value of the ambient relative humidity.

[0014] Preferably, the input sequence satisfies the following relationship:

[0015] X=α×Q+β×T+θ×H+ε×P

[0016] Where X is the input sequence, Q and α are the data unit vectors and their corresponding weight parameters, T and β are the quantized embedding vectors of the ambient temperature and their corresponding weight parameters, H and θ are the quantized embedding vectors of the ambient relative humidity and their corresponding weight parameters, and P and ε are the position codes and their corresponding weight parameters.

[0017] It satisfies θ+β+θ+ε=1, and α, β, θ, and ε are not 0.

[0018] Preferably, the Transformer model comprises: a Transformer encoder layer;

[0019] The Transformer encoder is composed of multiple identical layers stacked together, each of which has two sub-layers. The first sub-layer structure includes a multi-head self-attention sub-layer, a normalization layer, and a residual connection, and the second sub-layer structure includes a position-based feedforward network sub-layer, a normalization layer, and a residual connection.

[0020] Preferably, step 6 includes:

[0021] Step 6.1, divide the input sequence into D units of equal length; D is a positive integer greater than or equal to 10;

[0022] Step 6.2: Mask any D·τ unit segments according to the set mask processing ratio τ, including: replacing any D·τ·τ1 unit segments with different types of noise, leaving D·τ·(1-τ1) unit segments unchanged; where τ1 is the noise processing ratio; the different types of noise include: noise of the data unit vector and its corresponding weight parameter, noise of the quantized embedded vector of the ambient temperature and its corresponding weight parameter, noise of the quantized embedded vector of the ambient relative humidity and its corresponding weight parameter, and noise of the position code and its corresponding weight parameter;

[0023] In step 6.3, the input sequence processed in step 6.2 is fed into the Transformer model for training. The output sequence of the Transformer model has the same format as the input sequence, including the predicted data for any D·τ·τ1 unit segment in the input sequence.

[0024] Step 6.4: Mask the D·τ segments containing the zero crossings of the power waveform according to the set masking ratio τ, including replacing the D·τ·τ1 segments containing the zero crossings with different types of noise, leaving the D·τ·(1-τ1) segments containing the zero crossings unchanged; and using the starting points of the D·τ segments containing the zero crossings as the labels of the input sequence.

[0025] In step 6.5, the input sequence processed in step 6.4 is input into the Transformer model trained in step 6.3. The output sequence of the Transformer model has the same format as the input sequence, including: the predicted data of D·τ·τ1 unit segments in the input sequence containing the zero crossing point of the power waveform; the label value of the output sequence of the Transformer model is the predicted value of the distance from the starting point of the D·τ unit segment containing the zero crossing point of the power waveform to the zero crossing point of the power waveform;

[0026] In step 6.6, the sum of the label value of the input sequence and the label value of the output sequence is used as the predicted value of the zero-crossing point of the power waveform.

[0027] Preferably, the mask processing ratio τ is no more than 25%, and the noise processing ratio τ1 is no less than 90%.

[0028] The present invention also proposes a power waveform zero-crossing detection system under wide-frequency harmonics, comprising:

[0029] The acquisition module is used to sample the power signal source at a set sampling frequency within a detection cycle to obtain multiple data samples; collect the actual value of the ambient temperature and the actual value of the ambient relative humidity, and perform quantization processing to obtain a quantized value of the ambient temperature and the quantized value of the ambient relative humidity;

[0030] A vector partitioning module is used to divide the data sample into multiple data unit vectors, where the number of data samples in each data unit vector is the same; a word embedding method is used to process the quantized value of the ambient temperature and the quantized value of the ambient relative humidity into a quantized embedding vector of the ambient temperature and a quantized embedding vector of the ambient relative humidity, respectively;

[0031] A position encoding module is used to determine the position encoding of the data unit vector, the quantized embedding vector of the ambient temperature, and the quantized embedding vector of the ambient relative humidity using a learnable position embedding method;

[0032] An input sequence establishment module, configured to establish an input sequence using a weighted sum of a data unit vector, a quantized embedding vector of an ambient temperature, a quantized embedding vector of an ambient relative humidity, and a position code;

[0033] The power waveform zero-crossing prediction module is used to replace any unit segment in the input sequence with different types of noise according to the set mask processing ratio and noise processing ratio, and then input it into the Transformer model for training; according to the set mask processing ratio and noise processing ratio, replace the unit segment containing the power waveform zero-crossing point in the input sequence with different types of noise, and then input it into the trained Transformer model, and use the starting point position of the unit segment containing the power waveform zero-crossing point as the label value of the input sequence; the output sequence of the trained Transformer model includes: the predicted data of the unit segment containing the power waveform zero-crossing point in the input sequence, and the label value of the output sequence is the predicted value of the distance from the starting point position of the unit segment containing the power waveform zero-crossing point to the power waveform zero-crossing point; the sum of the label value of the input sequence and the label value of the output sequence is used as the predicted value of the power waveform zero-crossing point.

[0034] The power waveform zero-crossing prediction module includes:

[0035] An input sequence partitioning unit is used to divide the input sequence into D unit segments of the same length; D is a positive integer greater than or equal to 10;

[0036] A model training unit is used to perform masking on any D·τ unit segments according to a set masking ratio τ, including: replacing any D·τ·τ1 unit segments with different types of noise, and retaining D·τ·(1-τ1) unit segments unchanged; where τ1 is the noise processing ratio; different types of noise include: noise of data unit vectors and their corresponding weight parameters, noise of quantized embedding vectors of ambient temperature and their corresponding weight parameters, noise of quantized embedding vectors of ambient relative humidity and their corresponding weight parameters, and noise of position codes and their corresponding weight parameters; inputting the masked input sequence into the Transformer model for training; the output sequence of the Transformer model has the same format as the input sequence, including: predicted data of any D·τ·τ1 unit segments in the input sequence;

[0037] A zero-crossing prediction unit is used to perform mask processing on D·τ unit segments containing the zero-crossing point of the power waveform according to a set mask processing ratio τ, including: replacing the D·τ·τ1 unit segments containing the zero-crossing point of the power waveform with different types of noise, and retaining the D·τ·(1-τ1) unit segments containing the zero-crossing point of the power waveform unchanged; and using the starting point positions of the D·τ unit segments containing the zero-crossing point of the power waveform as the label values ​​of the input sequence; inputting the masked input sequence into the trained Transformer model, the output sequence of the Transformer model has the same format as the input sequence, including: predicted data of the D·τ·τ1 unit segments containing the zero-crossing point of the power waveform in the input sequence; the label value of the output sequence of the Transformer model is the predicted value of the distance from the starting point positions of the D·τ unit segments containing the zero-crossing point of the power waveform to the zero-crossing point of the power waveform; and using the sum of the label value of the input sequence and the label value of the output sequence as the predicted value of the zero-crossing point of the power waveform.

[0038] The present invention also provides a terminal, comprising a processor and a storage medium; the storage medium is used to store instructions; and the processor is used to operate according to the instructions to execute the steps of the method.

[0039] The present invention also provides a computer-readable storage medium having a computer program stored thereon, which implements the steps of the method when the program is executed by a processor.

[0040] The beneficial effect of the present invention is that, compared with the prior art, at least the method proposed in the present invention uses the Transformer model to perform zero-crossing detection on the power signal, utilizes multiple data without time series, and captures the time series relationship in the data based on the sequence modeling capability of the Transformer model, and self-learns the insertion positions of parameters such as temperature and humidity based on the captured time series relationship, thereby realizing effective encoding of data samples, temperature, and humidity, which can not only accurately predict the zero-crossing position of the electric energy waveform and its changing trend, but also achieve lower prediction error and stronger generalization ability, and improve the measurement accuracy and stability with strong noise and interference suppression ability, thereby improving the stability and prediction ability of the power system. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] Figure 1 This is a flow chart of the method for detecting the zero-crossing point of an electric power waveform under wide-frequency domain harmonics proposed by the present invention. DETAILED DESCRIPTION

[0042] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. The embodiments described in this application are only part of the embodiments of the present invention, not all of them. Based on the spirit of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0043] The present invention proposes a method for detecting the zero-crossing point of power waveform under wide frequency domain harmonics. Figure 1 As shown, including:

[0044] Step 1: In one detection cycle, the power signal source is sampled at a set sampling frequency to obtain a plurality of data samples.

[0045] The power signal source outputs a power time-series waveform. In this embodiment, under real-world operating conditions, the signal source is sampled using a waveform recording device at a sampling frequency f1. The signal source's power frequency f0∈[50-δ, 50+δ], where δ∈[-1, 1] represents the frequency fluctuation range of the power frequency, is set to the sampling frequency f1. Data samples are collected from the signal source at n sampling points. These data samples lack time-series characteristics. The collected data is used to analyze the frequency fluctuation characteristics under operating conditions and for subsequent signal processing, supporting algorithm optimization and practical application of high-precision power sensing devices. In this embodiment, the sampling frequency f1 = 12.8kHz, the signal source's power frequency f0 = 50Hz, and waveform data is collected for three cycles, totaling 768 sampling points.

[0046] Each data sample corresponds to a sampling moment and has a time characteristic.

[0047] Step 2: Collect the actual value of the ambient temperature and the actual value of the ambient relative humidity, and perform quantization processing on them to obtain the quantized value of the ambient temperature and the quantized value of the ambient relative humidity.

[0048] Considering that the ambient temperature and humidity have an impact on the sampling components and will affect the sampling value, the temperature, humidity and other information are also taken into account when determining the input data sequence. The actual value of the ambient temperature and the actual value of the ambient relative humidity are quantified, including:

[0049] 1) The actual value of the ambient temperature of the actual meter application is T∈[-40℃, 80℃], with the minimum unit scale being 2℃. The quantified value of the ambient temperature is T C ∈[0,60), where the mathematical symbol Indicates rounding up. y is the quantized value of the ambient temperature, and x is the actual value of the ambient temperature. If the actual value of the ambient temperature is 37.3°C, the quantized value of the actual value of the ambient temperature is 39.

[0050] 2) The actual relative humidity of the environment in which the meter is actually used is G∈[10%RH, 90%RH], with the minimum unit scale being 5%RH. The quantitative value of the ambient humidity is H C ∈[0,16), where the mathematical symbol Indicates rounding up, y is the quantized value of the ambient relative humidity, and x is the actual value of the ambient relative humidity. When the actual value of the ambient relative humidity is 50% RH, the quantized value of the ambient relative humidity is 8.

[0051] Step 3: Divide the data samples into multiple data unit vectors, and the number of data samples in each data unit vector is the same; use the word embedding method to process the quantized value of the ambient temperature and the quantized value of the ambient relative humidity into the quantized embedding vector of the ambient temperature and the quantized embedding vector of the ambient relative humidity, respectively.

[0052] However, the quantized values ​​of ambient temperature and relative humidity have time-period characteristics and remain constant over a certain period of time. However, the time period corresponding to temperature and the time period corresponding to humidity are different in length, and the data samples collected in step 1 are also different within the time period corresponding to temperature and the time period corresponding to humidity. Existing techniques often fuse temperature and humidity with data samples based on the sampling time. However, the fused data cannot accurately reflect the impact of temperature and humidity on power data. Therefore, it is necessary to determine the temporal correspondence between temperature, humidity, and data samples.

[0053] In an embodiment, if the number of data samples in each data unit vector is the same, then the length of each data unit vector is the same. The present invention proposes to divide the data samples into multiple data unit vectors of the same length to realize the transformation from data samples with moment characteristics to data unit vectors, so as to be consistent with the time period characteristics of the quantized value of the ambient temperature and the quantized value of the ambient relative humidity, and also facilitate the embedding and integration of the quantized value of the ambient temperature and the quantized value of the ambient relative humidity.

[0054] Within a detection cycle, a word embedding method is used to convert the high-dimensional quantized values ​​of ambient temperature and ambient relative humidity into low-dimensional vectors. When used, the word embedding method actually removes the time period characteristics of the quantized values ​​of ambient temperature and ambient relative humidity, thereby improving the generalization ability and making the subsequently obtained input sequence model a more general model. Therefore, when processing power data influencing parameters other than ambient temperature and ambient relative humidity, the input sequence model has extremely high accuracy and reliability. In an embodiment, the size of the embedding dictionary corresponding to the quantized value of ambient temperature is defined as 20, which means that the quantized value of ambient temperature will be divided into 20 categories; the size of the embedding dictionary corresponding to the quantized value of ambient relative humidity is defined as 16, which means that the quantized value of ambient relative humidity will be divided into 16 categories; for each quantized category, a baseline word embedding vector with a dimension of 32 is used to implement the embedding processing of the quantized value of ambient temperature and the quantized value of ambient relative humidity, fully capturing the temporal differences between ambient temperature and ambient relative humidity.

[0055] Step 4: Use a learnable position embedding method to determine the position encoding of the data unit vector, the quantized embedding vector of the ambient temperature, and the quantized embedding vector of the ambient relative humidity.

[0056] Position embedding is a technology for encoding the position information of elements in a sequence. It can distinguish different positions in the sequence, thereby better interpreting the sequence structure, and strengthening the dependencies in the sequence through position information to improve the integrity of the sequence. In the Transformer model, each element in the input sequence is mapped to a vector representation in a high-dimensional space. However, the traditional self-attention mechanism does not contain position information, so additional position embedding is required to supplement this information. In the learnable position embedding method of the embodiment, the position embedding is usually a learnable parameter matrix, which is initialized to a tensor of [sequence_length, embedding_dim], and this tensor is updated by backpropagation during the subsequent Transformer model training process.

[0057] The position encoding determined by the learnable position embedding method is used to dynamically learn the importance of each position between the data unit vector, the quantized embedding vector of the ambient temperature, and the quantized embedding vector of the ambient relative humidity. The expression of the position information is adaptively adjusted according to different sequence data, further enhancing the generalization ability of the input sequence model.

[0058] Step 5: Create an input sequence using the weighted sum of the data unit vector, the quantized embedding vector of the ambient temperature, the quantized embedding vector of the ambient relative humidity, and the position code.

[0059] The input sequence satisfies the following relationship:

[0060] X=α×Q+β×T+θ×H+ε×P

[0061] Where X is the input sequence, Q and α are the data unit vectors and their corresponding weight parameters, T and β are the quantized embedding vectors of the ambient temperature and their corresponding weight parameters, H and θ are the quantized embedding vectors of the ambient relative humidity and their corresponding weight parameters, and P and ε are the position codes and their corresponding weight parameters.

[0062] α+β+θ+ε=1, and α, β, θ, and ε are all non-zero.

[0063] Each weight coefficient is used to adjust the contribution of power data, temperature, humidity, and position encoding to the input sequence. Because power data, temperature, and humidity contribute differently to the model's predictions, learnable weight parameters α, β, θ, and ε are introduced for each component. This allows the model to automatically adjust the weight of each type of information during training, ensuring that the model assigns appropriate weights to different inputs based on the actual data.

[0064] Step 6: According to the set mask processing ratio and noise processing ratio, any unit segment in the input sequence is replaced with different types of noise and then input into the Transformer model for training; according to the set mask processing ratio and noise processing ratio, the unit segment containing the zero crossing point of the power waveform in the input sequence is replaced with different types of noise and then input into the trained Transformer model, and the starting point positions of D·τ unit segments containing the zero crossing point of the power waveform are used as the label values ​​of the input sequence; the output sequence of the trained Transformer model includes: the predicted data of the unit segment containing the zero crossing point of the power waveform in the input sequence, and the label value of the output sequence is the predicted value of the distance from the starting point position of the unit segment containing the zero crossing point of the power waveform to the zero crossing point of the power waveform; the sum of the label value of the input sequence and the label value of the output sequence is used as the predicted value of the zero crossing point of the power waveform.

[0065] The method proposed in the present invention applies natural language processing to the field of power time series waveform detection, which also brings many changes to the training of the Transformer model.

[0066] In one embodiment, the Transformer model includes a Transformer encoder layer. The Transformer encoder is composed of multiple identical layers stacked together, each of which has two sublayers. The first sublayer structure includes a multi-head self-attention sublayer, a normalization layer, and a residual connection, and the second sublayer structure includes a position-based feedforward network sublayer, a normalization layer, and a residual connection.

[0067] Specifically, the Multi-Head Self-Attention Layer (MMSL), based on the multi-head self-attention mechanism, can parallelly compute multiple attention heads, focusing on different parts of the input sequence through different projections. The input sequence undergoes a linear transformation to generate a query vector Qr, a key vector K, and a value vector V. The weighted summation is calculated by calculating the attention weights, as shown in the following formula:

[0068]

[0069] Where Attention(Qr,K,V) is the attention weight, d k is the dimension of the key vector.

[0070] The multi-head self-attention mechanism concatenates the outputs of the attention heads and obtains the final output through linear transformation. The formula is as follows:

[0071] MultiHead(Qr,K,V)=Concat(head1,head2,…,head h )W O

[0072] Where MultiHead(Qr,K,V) is multi-head self-attention, W i Qr , W O is the learned parameter matrix.

[0073] Specifically, the normalization layer and the residual connection (Layer Normalization and ResidualConnection):

[0074] Each sub-layer is followed by a normalization layer (LayerNorm) to standardize the output of the sub-layer.

[0075] At the same time, a residual connection is used to add the input directly to the output of the sub-layer, satisfying the following relationship:

[0076] SubLayerOutput=LayerNorm(X+SubLayer(X))

[0077] Where SubLayerOutput is the output of the sublayer, X is the input of the sublayer, SubLayer(X) is the output of the sublayer, and LayerNorm() is the transfer function of the normalization layer.

[0078] Specifically, the position-based feed-forward network sublayer (Positionwise Feed-Forward Network Layer) consists of two linear transformations and an activation function, which is used to perform independent nonlinear transformations on the vectors at each position, satisfying the following relationship:

[0079] FFN(x)=max(0,xW1+b1)W2+b2

[0080] Where W1, W2 and b1, b2 are the learned parameter matrices and bias terms.

[0081] The Transformer encoder satisfies the following relationship:

[0082] EncoderLayer(x)=LayerNorm(FFN(LayerNorm(MultiHead(X,X,X))+X)+(MultiHead(X,X,X)+X)

[0083] Among them, EncoderLayer(x) is the output of a single-layer encoder, FFN represents the feedforward network layer, MultiHead represents the multi-head self-attention layer, LayerNorm represents the normalization layer, and the final encoder output is obtained after N layers are stacked.

[0084] Specifically, step 6 includes:

[0085] Step 6.1: Divide the input sequence into D segments of length L; D is a positive integer greater than or equal to 10;

[0086] Step 6.2: Mask any D·τ unit segments according to the set mask processing ratio τ, including: replacing any D·τ·τ1 unit segments with different types of noise, leaving D·τ·(1-τ1) unit segments unchanged; where τ1 is the noise processing ratio; the different types of noise include: noise of the data unit vector and its corresponding weight parameter, noise of the quantized embedded vector of the ambient temperature and its corresponding weight parameter, noise of the quantized embedded vector of the ambient relative humidity and its corresponding weight parameter, and noise of the position code and its corresponding weight parameter;

[0087] In the embodiment, the mask processing ratio τ is set to be no greater than 25%, and the noise processing ratio τ1 is set to be no less than 90%;

[0088] In traditional electric energy waveform prediction methods, only a single electric power time series data is often considered as input data, and only the noise of the electric power data is used during model training. However, the present invention also introduces a quantized embedding vector of the ambient temperature, a quantized embedding vector of the ambient relative humidity, a learnable positional encoding, and various weight parameters to form an input sequence. The input sequence is masked and different types of noise are added before inputting into the Transformer model. The model can be trained without labeling the input sequence. The model autonomously learns the temporal correlation between the variables and the contribution of each variable to the input sequence, and optimizes the weight parameters corresponding to each variable to obtain an input sequence that is more in line with the actual situation. After iterative training, the accuracy of the Transformer model's prediction of the input sequence is significantly improved. This method of fusing multiple variables to form an input sequence not only enhances the model's prediction performance, but also expands its potential for application in multiple fields.

[0089] In step 6.3, the input sequence processed in step 6.2 is fed into the Transformer model for training. The output sequence of the Transformer model has the same format as the input sequence, including the predicted data for any D·τ·τ1 unit segment in the input sequence.

[0090] Step 6.4: Mask and label the D·τ segments containing the zero-crossing points of the power waveform according to the set masking ratio τ. The masking process includes replacing the D·τ·τ1 segments containing the zero-crossing points of the power waveform with different types of noise, while retaining the D·τ·(1-τ1) segments containing the zero-crossing points of the power waveform unchanged. The labeling process includes labeling the input sequence with the starting point positions of the D·τ segments containing the zero-crossing points of the power waveform.

[0091] In step 6.5, the input sequence processed in step 6.4 is input into the Transformer model trained in step 6.3. The output sequence of the Transformer model has the same format as the input sequence, including: the predicted data of D·τ·τ1 unit segments in the input sequence containing the zero crossing point of the power waveform; the label value of the output sequence of the Transformer model is the predicted value of the distance from the starting point of the D·τ unit segment containing the zero crossing point of the power waveform to the zero crossing point of the power waveform;

[0092] In step 6.6, the sum of the label value of the input sequence and the label value of the output sequence is used as the predicted value of the zero-crossing point of the power waveform.

[0093] The method proposed in the present invention focuses on the area near the zero crossing point, and the data masking method of the training model is to randomly select data areas for masking so that the model can learn the overall characteristics of the data. However, when the model predicts the zero crossing point, the masked area of ​​the training data set will be mainly concentrated near the zero crossing point. The zero crossing point is an important characteristic point of the sine waveform. The waveform in these areas is easily affected by noise and distortion. Therefore, the focused training of data near the zero crossing point can significantly improve the prediction accuracy of the model in these key areas. Masking a certain number of sampling points before and after the zero crossing fluctuation area can enable the model to focus on learning how to denoise and correct near the fluctuation, thereby improving the robustness and accuracy of the model.

[0094] To further enhance the practicality and scalability of the model, this paper employs a self-supervised learning approach for model training. Self-supervised learning utilizes the data's own supervisory signals for training, eliminating the need for extensive manual data labeling. This approach not only reduces the cost and difficulty of data labeling but also enables the model to extract useful information from large amounts of unlabeled data, improving its generalization and robustness, thereby better serving subsequent downstream tasks such as anomaly detection and denoising.

[0095] The present invention also proposes a power waveform zero-crossing detection system under wide-frequency harmonics, comprising:

[0096] The acquisition module is used to sample the power signal source at a set sampling frequency within a detection cycle to obtain multiple data samples; collect the actual value of the ambient temperature and the actual value of the ambient relative humidity, and perform quantization processing to obtain a quantized value of the ambient temperature and the quantized value of the ambient relative humidity;

[0097] A vector partitioning module is used to divide the data sample into multiple data unit vectors, where the number of data samples in each data unit vector is the same; a word embedding method is used to process the quantized value of the ambient temperature and the quantized value of the ambient relative humidity into a quantized embedding vector of the ambient temperature and a quantized embedding vector of the ambient relative humidity, respectively;

[0098] A position encoding module is used to determine the position encoding of the data unit vector, the quantized embedding vector of the ambient temperature, and the quantized embedding vector of the ambient relative humidity using a learnable position embedding method;

[0099] An input sequence establishment module, configured to establish an input sequence using a weighted sum of a data unit vector, a quantized embedding vector of an ambient temperature, a quantized embedding vector of an ambient relative humidity, and a position code;

[0100] The power waveform zero-crossing prediction module is used to replace any unit segment in the input sequence with different types of noise according to the set mask processing ratio and noise processing ratio, and then input it into the Transformer model for training; according to the set mask processing ratio and noise processing ratio, replace the unit segment containing the power waveform zero-crossing point in the input sequence with different types of noise, and then input it into the trained Transformer model, and use the starting point position of the unit segment containing the power waveform zero-crossing point as the label value of the input sequence; the output sequence of the trained Transformer model includes: the predicted data of the unit segment containing the power waveform zero-crossing point in the input sequence, and the label value of the output sequence is the predicted value of the distance from the starting point position of the unit segment containing the power waveform zero-crossing point to the power waveform zero-crossing point; the sum of the label value of the input sequence and the label value of the output sequence is used as the predicted value of the power waveform zero-crossing point.

[0101] The power waveform zero-crossing prediction module includes:

[0102] An input sequence partitioning unit is used to divide the input sequence into D unit segments of the same length; D is a positive integer greater than or equal to 10;

[0103] A model training unit is used to perform masking on any D·τ unit segments according to a set masking ratio τ, including: replacing any D·τ·τ1 unit segments with different types of noise, and retaining D·τ·(1-τ1) unit segments unchanged; where τ1 is the noise processing ratio; different types of noise include: noise of data unit vectors and their corresponding weight parameters, noise of quantized embedding vectors of ambient temperature and their corresponding weight parameters, noise of quantized embedding vectors of ambient relative humidity and their corresponding weight parameters, and noise of position codes and their corresponding weight parameters; inputting the masked input sequence into the Transformer model for training; the output sequence of the Transformer model has the same format as the input sequence, including: predicted data of any D·τ·τ1 unit segments in the input sequence;

[0104] A zero-crossing prediction unit is used to perform mask processing on D·τ unit segments containing the zero-crossing point of the power waveform according to a set mask processing ratio τ, including: replacing the D·τ·τ1 unit segments containing the zero-crossing point of the power waveform with different types of noise, and retaining the D·τ·(1-τ1) unit segments containing the zero-crossing point of the power waveform unchanged; and using the starting point positions of the D·τ unit segments containing the zero-crossing point of the power waveform as the label values ​​of the input sequence; inputting the masked input sequence into the trained Transformer model, the output sequence of the Transformer model has the same format as the input sequence, including: predicted data of the D·τ·τ1 unit segments containing the zero-crossing point of the power waveform in the input sequence; the label value of the output sequence of the Transformer model is the predicted value of the distance from the starting point positions of the D·τ unit segments containing the zero-crossing point of the power waveform to the zero-crossing point of the power waveform; and using the sum of the label value of the input sequence and the label value of the output sequence as the predicted value of the zero-crossing point of the power waveform.

[0105] The present disclosure may be a system, method and / or computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for causing a processor to implement various aspects of the present disclosure.

[0106] Computer-readable storage media can be a tangible device that can hold and store the instructions used by the instruction execution device. Computer-readable storage media can be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination thereof. More specific examples (non-exhaustive list) of computer-readable storage media include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, for example, a punch card or a raised structure in a groove on which instructions are stored, and any suitable combination thereof. Computer-readable storage media used herein is not interpreted as a transient signal itself, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagated by waveguides or other transmission media (for example, light pulses by fiber optic cables), or electrical signals transmitted by wires.

[0107] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions to be stored in the computer-readable storage medium in each computing / processing device.

[0108] The computer program instructions for performing the operations of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Smalltalk, C++, and conventional procedural programming languages ​​such as "C" language or similar programming languages. Computer-readable program instructions may be executed entirely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., utilizing an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be personalized by utilizing the state information of the computer-readable program instructions. The electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present disclosure.

[0109] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents. Any modification or equivalent replacement that does not depart from the spirit and scope of the present invention should be covered by the scope of protection of the claims of the present invention.

Claims

1. A method for detecting zero-crossing points of power waveforms under wide-frequency harmonics, characterized in that: include: Step 1: within a detection cycle, sampling the power signal source at a set sampling frequency to obtain multiple data samples; Step 2: collecting the actual value of the ambient temperature and the actual value of the ambient relative humidity, and performing quantization processing to obtain the quantized value of the ambient temperature and the quantized value of the ambient relative humidity; Step 3: Divide the data sample into multiple data unit vectors, with the same number of data samples in each data unit vector; use a word embedding method to process the quantized value of the ambient temperature and the quantized value of the ambient relative humidity into a quantized embedding vector of the ambient temperature and a quantized embedding vector of the ambient relative humidity, respectively; Step 4: Using a learnable position embedding method, determine the position encoding of the data unit vector, the quantized embedding vector of the ambient temperature, and the quantized embedding vector of the ambient relative humidity; Step 5: Create an input sequence using the weighted sum of the data unit vector, the quantized embedding vector of the ambient temperature, the quantized embedding vector of the ambient relative humidity, and the position code; Step 6: Replace any unit segment in the input sequence with different types of noise according to the set mask processing ratio and noise processing ratio, and then input it into the Transformer model for training; Replace the unit segment containing the zero crossing point of the power waveform in the input sequence with different types of noise according to the set mask processing ratio and noise processing ratio, and then input it into the trained Transformer model, and use the starting point position of the unit segment containing the zero crossing point of the power waveform as the label value of the input sequence; The output sequence of the trained Transformer model includes: the predicted data of the unit segment containing the zero-crossing point of the power waveform in the input sequence, and the label value of the output sequence is the predicted value of the distance from the starting point of the unit segment containing the zero-crossing point of the power waveform to the zero-crossing point of the power waveform; the sum of the label value of the input sequence and the label value of the output sequence is used as the predicted value of the zero-crossing point of the power waveform.

2. The method for detecting zero-crossing points of power waveforms under wide-frequency harmonics according to claim 1, characterized in that: In step 3, the size of the embedding dictionary corresponding to the quantized value of the ambient temperature is defined as 20, and the size of the embedding dictionary corresponding to the quantized value of the ambient relative humidity is defined as 16. A benchmark word embedding vector with a dimension of 32 is used to embed the quantized value of the ambient temperature and the quantized value of the ambient relative humidity.

3. The method for detecting zero-crossing points of power waveforms under wide-frequency harmonics according to claim 1, wherein: The input sequence satisfies the following relationship: X=α×Q+β×T+θ×H+ε×P Where X is the input sequence, Q and α are the data unit vectors and their corresponding weight parameters, T and β are the quantized embedding vectors of the ambient temperature and their corresponding weight parameters, H and θ are the quantized embedding vectors of the ambient relative humidity and their corresponding weight parameters, and P and ε are the position codes and their corresponding weight parameters. α+β+θ+ε=1, and α, β, θ, and ε are all non-zero.

4. The method for detecting zero-crossing points of power waveforms under wide-frequency harmonics according to claim 1, wherein: The Transformer model includes: Transformer encoder layer; The Transformer encoder is composed of multiple identical layers stacked together, each of which has two sub-layers. The first sub-layer structure includes a multi-head self-attention sub-layer, a normalization layer, and a residual connection, and the second sub-layer structure includes a position-based feedforward network sub-layer, a normalization layer, and a residual connection.

5. The method for detecting zero-crossing points of electric power waveforms under wide-frequency harmonics according to claim 1, characterized in that: Step 6 includes: Step 6.1, divide the input sequence into D units of equal length; D is a positive integer greater than or equal to 10; Step 6.2: Mask any D·τ unit segments according to the set mask processing ratio τ, including: replacing any D·τ·τ1 unit segments with different types of noise, leaving D·τ·(1-τ1) unit segments unchanged; where τ1 is the noise processing ratio; the different types of noise include: noise of the data unit vector and its corresponding weight parameter, noise of the quantized embedded vector of the ambient temperature and its corresponding weight parameter, noise of the quantized embedded vector of the ambient relative humidity and its corresponding weight parameter, and noise of the position code and its corresponding weight parameter; In step 6.3, the input sequence processed in step 6.2 is fed into the Transformer model for training. The output sequence of the Transformer model has the same format as the input sequence, including the predicted data for any D·τ·τ1 unit segment in the input sequence. Step 6.4: Mask the D·τ segments containing the zero crossings of the power waveform according to the set masking ratio τ, including replacing the D·τ·τ1 segments containing the zero crossings with different types of noise, leaving the D·τ·(1-τ1) segments containing the zero crossings unchanged; and using the starting points of the D·τ segments containing the zero crossings as the labels of the input sequence. In step 6.5, the input sequence processed in step 6.4 is input into the Transformer model trained in step 6.

3. The output sequence of the Transformer model has the same format as the input sequence, including: the predicted data of D·τ·τ1 unit segments in the input sequence containing the zero crossing point of the power waveform; the label value of the output sequence of the Transformer model is the predicted value of the distance from the starting point of the D·τ unit segment containing the zero crossing point of the power waveform to the zero crossing point of the power waveform; In step 6.6, the sum of the label value of the input sequence and the label value of the output sequence is used as the predicted value of the zero-crossing point of the power waveform.

6. The method for detecting zero-crossing points of power waveforms under wide-frequency harmonics according to claim 5, characterized in that: The mask processing ratio τ is set to be no greater than 25%, and the noise processing ratio τ1 is set to be no less than 90%.

7. A power waveform zero-crossing detection system under wide frequency domain harmonics, characterized in that: include: The acquisition module is used to sample the power signal source at a set sampling frequency within a detection cycle to obtain multiple data samples; The actual value of the ambient temperature and the actual value of the ambient relative humidity are collected and quantified to obtain a quantized value of the ambient temperature and a quantized value of the ambient relative humidity; A vector partitioning module is used to divide the data sample into multiple data unit vectors, where the number of data samples in each data unit vector is the same; a word embedding method is used to process the quantized value of the ambient temperature and the quantized value of the ambient relative humidity into a quantized embedding vector of the ambient temperature and a quantized embedding vector of the ambient relative humidity, respectively; A position encoding module is used to determine the position encoding of the data unit vector, the quantized embedding vector of the ambient temperature, and the quantized embedding vector of the ambient relative humidity using a learnable position embedding method; An input sequence establishment module, configured to establish an input sequence using a weighted sum of a data unit vector, a quantized embedding vector of an ambient temperature, a quantized embedding vector of an ambient relative humidity, and a position code; The power waveform zero-crossing prediction module is used to replace any unit segment in the input sequence with different types of noise according to the set mask processing ratio and noise processing ratio, and then input it into the Transformer model for training. According to the set mask processing ratio and noise processing ratio, the unit segment containing the power waveform zero-crossing point in the input sequence is replaced with different types of noise, and then input it into the trained Transformer model, and the starting point position of the unit segment containing the power waveform zero-crossing point is used as the label value of the input sequence; The output sequence of the trained Transformer model includes: the predicted data of the unit segment containing the zero-crossing point of the power waveform in the input sequence, and the label value of the output sequence is the predicted value of the distance from the starting point of the unit segment containing the zero-crossing point of the power waveform to the zero-crossing point of the power waveform; the sum of the label value of the input sequence and the label value of the output sequence is used as the predicted value of the zero-crossing point of the power waveform.

8. The power waveform zero-crossing detection system under wide-frequency harmonics according to claim 7, characterized in that: The power waveform zero-crossing prediction module includes: An input sequence partitioning unit is used to divide the input sequence into D unit segments of the same length; D is a positive integer greater than or equal to 10; A model training unit is used to perform masking on any D·τ unit segments according to a set masking ratio τ, including: replacing any D·τ·τ1 unit segments with different types of noise, and retaining D·τ·(1-τ1) unit segments unchanged; where τ1 is the noise processing ratio; different types of noise include: noise of data unit vectors and their corresponding weight parameters, noise of quantized embedding vectors of ambient temperature and their corresponding weight parameters, noise of quantized embedding vectors of ambient relative humidity and their corresponding weight parameters, and noise of position codes and their corresponding weight parameters; inputting the masked input sequence into the Transformer model for training; the output sequence of the Transformer model has the same format as the input sequence, including: predicted data of any D·τ·τ1 unit segments in the input sequence; A zero-crossing prediction unit is used to perform mask processing on D·τ unit segments containing the zero-crossing point of the power waveform according to a set mask processing ratio τ, including: replacing the D·τ·τ1 unit segments containing the zero-crossing point of the power waveform with different types of noise, and retaining the D·τ·(1-τ1) unit segments containing the zero-crossing point of the power waveform unchanged; and using the starting point positions of the D·τ unit segments containing the zero-crossing point of the power waveform as the label values ​​of the input sequence; inputting the masked input sequence into the trained Transformer model, the output sequence of the Transformer model has the same format as the input sequence, including: predicted data of the D·τ·τ1 unit segments containing the zero-crossing point of the power waveform in the input sequence; the label value of the output sequence of the Transformer model is the predicted value of the distance from the starting point positions of the D·τ unit segments containing the zero-crossing point of the power waveform to the zero-crossing point of the power waveform; and using the sum of the label value of the input sequence and the label value of the output sequence as the predicted value of the zero-crossing point of the power waveform.

9. A terminal comprising a processor and a storage medium; characterized in that: The storage medium is used to store instructions; The processor is configured to operate according to the instructions to execute the steps of the method according to any one of claims 1 to 6.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.