Power line frequency detection method and system, electronic device and readable storage medium

CN122882811APending Publication Date: 2026-10-09SHENZHEN EMEET TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611365390.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-04
Publication Date
2026-10-09

AI Technical Summary

Technical Problem

[0005]本申请的主要目的在于提供一种电力线的工频检测方法,旨在解决过零检测法易受谐波和噪声干扰的问题的技术问题

Benefits of technology

[0017]本申请通过采集预设数量的原始采样值,平衡了频率分辨率,防止频率分辨率过高或过低导致的精确度降低问题;通过对原始采样值进行浮点转换和去直流处理,滤除信号中的直流偏置干扰,实现对电力线信号的降噪;通过预设的幅度算法得到幅度值,并结合预设的采样参数确定实际频率,实现了从频域角度对信号特征的全面提取;通过根据所述幅度值和所述实际频率确定工频频率类型以及精确频率,将时域信号转换至频域进行分析,非时域波形特征进行频率判定,从而避免了过零检测法因谐波导致波形畸变、因噪声导致过零点偏移的问题;通过预设的相位算法以及所述精确频率计算频域复数结果得到相位值,使得输出的工频信息更加完整,能够直接用于各种电力系统应用场景。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122882811A_ABST
    Figure CN122882811A_ABST
Patent Text Reader

Abstract

The application discloses a power line power frequency detection method and system, electronic equipment and a readable storage medium, and relates to the technical field of power system power frequency detection. The power line power frequency detection method is applied to an IIO device. The power line power frequency detection method comprises the following steps: in response to collecting a preset number of original sampling values of a power line, preprocessing each original sampling value to obtain each alternating component data; inputting each alternating component data into a preset forward transformation function to obtain a frequency domain complex result; inputting the frequency domain complex result into a preset amplitude function to obtain an amplitude value, and determining an actual frequency according to a preset sampling parameter; determining a frequency type and an accurate frequency according to the amplitude value and the actual frequency; determining a phase value based on a preset phase function, the accurate frequency and the frequency domain complex result, and outputting the phase value, the frequency type, the amplitude value and the accurate frequency. The application overcomes harmonic and noise interference, and realizes joint extraction of frequency and phase.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of power frequency detection technology in power systems, and in particular to a power frequency detection method, system, electronic device, and computer-readable storage medium for power lines. Background Technology

[0002] With the rapid development of smart grids, industrial automation, and online monitoring of power equipment, power line frequency detection has become a core component of power grid status perception and equipment synchronization control.

[0003] Currently, while industrial data acquisition equipment based on the IIO (Industrial I / O) framework is widely used in power signal acquisition, its power frequency detection mainly adopts the traditional zero-crossing detection method. After the power line signal passes through a conditioning circuit, it is shaped into a square wave by a comparator, and then the processor captures the rising or falling edge of the square wave. The power frequency is obtained by calculating the time interval between adjacent zero-crossing points. In this process, the processor needs to detect the moment the signal crosses the zero level. However, this zero-crossing detection scheme has significant drawbacks in power line environments with severe harmonic interference and noise pollution: each zero-crossing determination requires the processor to find the accurate zero-level crossing position on the time-domain waveform. In scenarios with high grid harmonic content and low signal-to-noise ratio, waveform distortion causes the zero-crossing position to shift, significantly increasing frequency measurement errors and making it impossible to accurately extract phase information. Especially in situations where strong interference loads such as frequency converters and electric arc furnaces are connected, the zero-crossing detection results frequently change, drastically reducing system stability and severely impacting the user experience.

[0004] Therefore, how to overcome the problem that the zero-crossing detection method in the prior art is susceptible to harmonic and noise interference is a technical problem that urgently needs to be solved in this field. Summary of the Invention

[0005] The main objective of this application is to provide a power frequency detection method for power lines, which aims to solve the technical problem that the zero-crossing detection method is susceptible to harmonic and noise interference.

[0006] To achieve the above objectives, this application proposes a power frequency detection method for power lines, applied to IIO equipment. The power frequency detection method for power lines includes: In response to the collection of a preset number of raw sampled values ​​of the power line, each raw sampled value is converted into a single-precision floating-point number, and the DC component of each single-precision floating-point number is removed to obtain AC component data. The AC component data are input into a preset forward transform function to obtain the frequency domain complex result; The frequency domain complex result is input into a preset amplitude function to obtain the amplitude value, and the actual frequency is determined according to the preset sampling parameters; The frequency type and precise frequency are determined based on the amplitude value and the actual frequency. Based on the preset phase function, the precise frequency, and the frequency domain complex result, the phase value is determined, and the phase value, the frequency type, the amplitude value, and the precise frequency are output.

[0007] In one embodiment, the frequency type includes at least a first frequency type and a second frequency type; the step of determining the frequency type and the precise frequency based on the amplitude value and the actual frequency includes: A first frequency range and a second frequency range are determined based on the actual frequency, wherein the value of the second frequency range is greater than the value of the first frequency range; The maximum amplitude value is searched within the first frequency range to obtain the first energy peak value and the first frequency value, and the maximum amplitude value is searched within the second frequency range to obtain the second energy peak value and the second frequency value. Compare the first energy peak value and the second energy peak value; If the first energy peak value is greater than the second energy peak value, then the frequency type is determined to be the first frequency type, and the first frequency value is interpolated to obtain the accurate frequency; If the first energy peak value is less than the second energy peak value, then the frequency type is determined to be the second frequency type, and the second frequency value is interpolated to obtain the accurate frequency.

[0008] In one embodiment, the step of interpolating the first frequency value or the second frequency value to obtain the accurate frequency includes: Extract interpolation calculation points from the first frequency value or the second frequency value; The interpolation calculation points are fitted based on a preset interpolation algorithm to obtain the accurate frequency.

[0009] In one embodiment, prior to the step of converting each of the original sampled values ​​into a single-precision floating-point number, the method further includes: Scan the IIO device to obtain at least one valid channel, and extract the identifier field from the FFTW (Fastest Fourier Transform in the West) library deployed on the IIO device; Allocate multiple buffers for each of the aforementioned valid channels; A forward transformation function is created based on the capacity of each buffer and the identifier field.

[0010] In one embodiment, after the step of creating a forward transformation function based on the capacity corresponding to each of the buffers and the identifier field, the method further includes: Collect multiple sets of power line signals; Each of the power line signals is converted into a corresponding digital signal to obtain the original sampled value.

[0011] In one embodiment, after the step of removing the DC component from each of the single-precision floating-point numbers to obtain the AC component data, the method further includes: Obtain the preset window function coefficients; The AC component data is multiplied by the window function coefficients to obtain the windowed AC component data; The windowed AC component data is used as input to the forward transform function to obtain the frequency domain complex result.

[0012] In one embodiment, the step of determining the phase value based on a preset phase function, the precise frequency, and the frequency domain complex result includes: The frequency point index corresponding to the precise frequency is determined according to a preset index mapping table; Extract the real and imaginary parts corresponding to the frequency point index from the frequency domain complex number result; The real part and the imaginary part are input into a preset phase function to obtain the phase value.

[0013] Furthermore, to achieve the above objectives, this application also proposes a power frequency detection system for use in IIO equipment, the power frequency detection system comprising: The preprocessing module is used to convert each of the original sampled values ​​of the power line into a single-precision floating-point number in response to a preset number of original sampled values, and to perform DC component removal processing on each of the single-precision floating-point numbers to obtain AC component data. The input module is used to input the AC component data into a preset forward transform function to obtain the frequency domain complex result; The calculation module is used to input the frequency domain complex number result into a preset amplitude function to obtain an amplitude value, determine the actual frequency according to preset sampling parameters, determine the frequency type and precise frequency according to the amplitude value and the actual frequency, and determine the phase value based on a preset phase function, the precise frequency and the frequency domain complex number result. The output module is used to output the phase value, the frequency type, the amplitude value, and the precise frequency.

[0014] In addition, to achieve the above objectives, this application also proposes an electronic device, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the power frequency detection method for power lines as described above.

[0015] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the power line frequency detection method described above.

[0016] This application proposes a power frequency detection method for power lines, applied to an IIO device. The method includes: in response to a preset number of original sampled values ​​of the power line, converting each original sampled value into a single-precision floating-point number, and performing DC component removal processing on each single-precision floating-point number to obtain AC component data; inputting each AC component data into a preset forward transform function to obtain a frequency domain complex result; inputting the frequency domain complex result into a preset amplitude function to obtain an amplitude value, and determining the actual frequency according to preset sampling parameters; determining the frequency type and precise frequency based on the amplitude value and the actual frequency; determining the phase value based on a preset phase function, the precise frequency, and the frequency domain complex result, and outputting the phase value, the frequency type, the amplitude value, and the precise frequency.

[0017] This application balances frequency resolution by collecting a preset number of raw sample values, preventing accuracy reduction caused by excessively high or low frequency resolution. It filters out DC bias interference in the signal by performing floating-point conversion and DC removal on the raw sample values, achieving noise reduction for power line signals. An amplitude value is obtained through a preset amplitude algorithm, and the actual frequency is determined by combining preset sampling parameters, achieving comprehensive extraction of signal features from the frequency domain perspective. By determining the power frequency type and precise frequency based on the amplitude value and the actual frequency, the time-domain signal is converted to the frequency domain for analysis, and non-time-domain waveform features are used for frequency determination, thus avoiding waveform distortion caused by harmonics and zero-crossing point offset caused by noise in the zero-crossing detection method. The phase value is obtained by calculating the frequency domain complex number result using a preset phase algorithm and the precise frequency, making the output power frequency information more complete and directly applicable to various power system application scenarios. Attached Figure Description

[0018] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0019] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0020] Figure 1A flowchart illustrating an embodiment of the power frequency detection method for power lines in this application; Figure 2 This is a flowchart illustrating Embodiment 2 of the power frequency detection method for power lines in this application. Figure 3 A simplified flowchart illustrating the power frequency detection method for power lines provided in Embodiment 1 of this application; Figure 4 This is a schematic diagram of the module structure of the power frequency detection system according to an embodiment of this application; Figure 5 This is a schematic diagram of the equipment structure of the hardware operating environment involved in the power line frequency detection method in this application embodiment. Detailed Implementation

[0021] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.

[0022] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.

[0023] The main solution of this application embodiment is as follows: In response to the acquisition of a preset number of original sampled values ​​of the power line, each original sampled value is preprocessed to obtain each AC component data; each AC component data is input into a preset forward transform function to obtain a frequency domain complex result; the frequency domain complex result is input into a preset amplitude function to obtain an amplitude value, and the actual frequency is determined according to preset sampling parameters; the frequency type and precise frequency are determined according to the amplitude value and the actual frequency; the phase value is determined based on the preset phase function, the precise frequency, and the frequency domain complex result, and the phase value, frequency type, amplitude value, and precise frequency are output.

[0024] In this embodiment, for ease of description, the IIO device will be used as the execution subject in the following description.

[0025] Because existing technologies primarily employ the traditional zero-crossing detection method, this approach has significant drawbacks in power line environments with severe harmonic interference and noise pollution. Each zero-crossing determination requires the processor to locate the precise zero-level crossing position on the time-domain waveform. In scenarios with high grid harmonic content and low signal-to-noise ratios, waveform distortion leads to zero-crossing position shifts, significantly increasing frequency measurement errors and hindering accurate phase information extraction. Particularly in situations with highly interfering loads such as frequency converters and electric arc furnaces, frequent jumps in zero-crossing detection results drastically reduce system stability and severely impact user experience.

[0026] This application provides a solution that balances frequency resolution by collecting a preset number of raw sample values, preventing accuracy reduction caused by excessively high or low frequency resolution. By performing floating-point conversion and DC removal on the raw sample values, DC bias interference in the signal is filtered out, achieving noise reduction for power line signals. An amplitude value is obtained through a preset amplitude algorithm, and the actual frequency is determined by combining preset sampling parameters, achieving comprehensive extraction of signal features from the frequency domain perspective. By determining the power frequency type and precise frequency based on the amplitude value and actual frequency, the time-domain signal is converted to the frequency domain for analysis, and frequency determination is performed using non-time-domain waveform features, thus avoiding waveform distortion caused by harmonics and zero-crossing point offset caused by noise in the zero-crossing detection method. The phase value is obtained by calculating the frequency domain complex number result using a preset phase algorithm and precise frequency, making the output power frequency information more complete and directly applicable to various power system application scenarios.

[0027] It should be noted that the executing entity in this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, or mobile phone, or an electronic device or embedded device capable of performing the above functions. The following description uses an IIO device as an example to illustrate this embodiment and the subsequent embodiments.

[0028] Based on this, embodiments of this application provide a power frequency detection method for power lines, referring to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the power frequency detection method for power lines in this application.

[0029] In this embodiment, the power frequency detection method for power lines includes the following steps: S110: In response to the collection of a preset number of raw sampled values ​​of the power line, convert each raw sampled value into a single-precision floating-point number, and perform DC component removal processing on each single-precision floating-point number to obtain each AC component data. It should be noted that the raw sample value refers to the sample value of the power line signal sampled by the ADC (Analog-to-Digital Converter) and converted into a digital signal. It is usually in 16-bit or 24-bit integer format, and its value is proportional to the input voltage.

[0030] Single-precision floating-point numbers refer to 32-bit floating-point numbers conforming to the IEEE 754 (IEEE Standard for Floating-Point Arithmetic) standard. They occupy 4 bytes of storage space, can represent values ​​with a large dynamic range, and have high computational precision. Converting the original sampled values ​​from integer format to single-precision floating-point numbers is to avoid integer overflow issues in subsequent FFT (Fast Fourier Transform) operations and to improve the accuracy of frequency and phase calculations.

[0031] For example, assume that the sampling frequency fs (Sampling Frequency) of the IIO device is 1024Hz (Hertz), and the preset number of samples N is 1024. The collected samples are stored in a circular buffer, the capacity of which is at least twice the number of FFT analysis points N. When the accumulated raw sample values ​​in the circular buffer reach 1024 each time, an FFT analysis is triggered. The latest 1024 raw sample values ​​of type uint16_t are read from the circular buffer, such as raw_data[0]=32768, raw_data[1]=33000, raw_data[2]=33250... These raw sample values ​​represent the digital codes of the instantaneous voltage of the power line signal at different times. The 1024 original sampled values ​​were converted one by one into single-precision floating-point numbers and stored in the pre-allocated fft_data buffer: fft_data[0]=32768.0f, fft_data[1]=33000.0f, fft_data[2]=33250.0f.

[0032] Additionally, it should be noted that DC component removal refers to subtracting the mean value from the signal to eliminate the DC bias component. After power line signals are acquired by an ADC, a fixed DC component is usually superimposed due to the ADC's zero-point drift or the bias of the signal conditioning circuit. If this DC component is not eliminated, a huge energy peak will be generated at 0Hz in the FFT result, affecting the frequency points around 50Hz / 60Hz through spectral leakage, leading to a decrease in power frequency detection accuracy.

[0033] For example, assuming 1024 raw sample values ​​are collected, the arithmetic mean of these 1024 values ​​is first calculated. Then, the average value is subtracted from each sample value to obtain the AC component data after removing the DC component. For instance, if the raw value of a certain sample point is 16500 and the average value of the 1024 points is 100, then the value of that point after removing the DC component is 16400.

[0034] Understandably, by converting the original sampled values ​​into single-precision floating-point numbers and removing the DC component, the data format is unified to meet the precision requirements of FFT operations. On the other hand, the interference of DC bias on frequency domain analysis is eliminated, providing a clean AC signal input for the subsequent forward transform function, thereby improving the accuracy of power frequency and phase detection.

[0035] In one possible implementation, after step S110, the method further includes: Step S111: Obtain the preset window function coefficients; It should be noted that window function coefficients refer to a set of pre-calculated and stored weighted coefficients used to window the time-domain signal to reduce spectral leakage effects in FFT analysis. Commonly used window functions include the Hanning window, Hamming window, and Blackman window.

[0036] For example, using a Hanning window, the formula for calculating the window coefficient is: Where i = 0, 1, ..., N-1, and N is the number of samples. These are the window coefficients. N window function coefficients are pre-calculated and stored in an array, and can be read directly when needed.

[0037] Step S112: Multiply the AC component data with the window function coefficients to obtain the windowed AC component data; It should be noted that the windowed AC component data refers to the new data sequence obtained by multiplying each AC component data point by the window function coefficient at the corresponding position.

[0038] For example, suppose the i-th AC component data after removing DC is 5000.0f, and the corresponding window function coefficient w[i] = 0.5, then the windowed data is 5000.0f × 0.5 = 2500.0f. Performing the same multiplication operation on all N points sequentially yields the complete windowed data sequence.

[0039] The windowed AC component data is used as input to the forward transform function to obtain the frequency domain complex result.

[0040] By smoothly attenuating both ends of the data sequence to near zero, spectral leakage caused by data truncation is reduced, making the amplitude values ​​near the power frequency in the FFT results more concentrated and accurate, thereby improving the frequency detection accuracy.

[0041] In this embodiment, by pre-calculating and storing the window function coefficients, the repeated calculation of coefficients is avoided each time windowing is applied, thus reducing runtime computational overhead. Windowing processing suppresses the interference of spectral leakage on power frequency detection, making subsequent amplitude peak search and interpolation calculations more accurate, and further improving the accuracy of power frequency and phase detection.

[0042] S120: Input the data of each AC component into a preset forward transform function to obtain the frequency domain complex result; It should be noted that the preset forward transform function refers to the pre-created execution function in the FFTW library, used to perform a Fast Fourier Transform on time-domain data, converting the time-domain signal into a frequency-domain signal. This function is specifically designed to convert a real number sequence into a complex spectrum.

[0043] The frequency domain complex result refers to a set of complex numbers output by the FFT. Each complex number corresponds to a frequency point and contains two parts: a real part and an imaginary part, representing the cosine and sine components of that frequency component, respectively. The number of complex results is N / 2+1 (a number that is conjugate symmetric to the number of real numbers N).

[0044] For example, assuming N=1024 and the sampling frequency fs=1024Hz, the FFT operation yields 513 complex results. The 50th complex result corresponds to the 50Hz frequency point, with a real part of 8500.0f and an imaginary part of 3200.0f, representing the amplitude and phase information of the 50Hz component.

[0045] Understandably, by using a preset forward transformation function, the AC component data in the time domain is converted to the frequency domain, making the frequency components, amplitude, and phase information that were originally hidden in the time domain waveform directly obtainable and analyzable, thus providing basic data for subsequent power frequency detection.

[0046] S130: Input the frequency domain complex result into the preset amplitude function to obtain the amplitude value, and determine the actual frequency according to the preset sampling parameters; It should be noted that the preset amplitude function refers to the function used to calculate the modulus of a complex number, and the calculation formula is as follows: ,in and These are the real and imaginary parts of the k-th frequency point, respectively. This function returns the amplitude value for each frequency point, reflecting the energy intensity of that frequency component. Furthermore, to improve anti-interference capabilities, the spectrum can be smoothed before amplitude spectrum analysis, or a peak detection algorithm can be used, requiring the peak value to be greater than the two adjacent points before and after it, and the amplitude to exceed a predetermined threshold of the maximum amplitude.

[0047] The amplitude value refers to the complex modulus value corresponding to each frequency point. It is a non-negative real number that represents the energy level of that frequency component in the signal. The larger the amplitude value, the higher the proportion of that frequency component in the original signal.

[0048] For example, for the 50th frequency point, the real part is 8500.0f and the imaginary part is 3200.0f, then the amplitude value is calculated as 9082.5f using the formula.

[0049] Additionally, it should be noted that the preset sampling parameters refer to the ADC sampling frequency fs and the number of FFT analysis points N. The sampling frequency fs is determined by the hardware configuration of the IIO device, and the number of FFT analysis points N is the preset number of samples.

[0050] The actual frequency refers to the frequency value corresponding to each frequency index k, and the calculation formula is as follows: The unit is Hertz (Hz). Actual frequency converts abstract frequency indexes into physically meaningful frequency values.

[0051] For example, if fs = 1024 Hz and N = 1024, then the actual frequency of the 50th frequency point is 50 × 1024 / 1024 = 50 Hz. The actual frequency of the 60th frequency point is 60 × 1024 / 1024 = 60 Hz.

[0052] Understandably, by calculating the amplitude value of each frequency point using a preset amplitude function, the energy strength of each frequency component can be quantitatively assessed; by determining the actual frequency using preset sampling parameters, the frequency point index can be mapped to the specific frequency value. Together, they provide a data foundation and coordinate reference for subsequent frequency type determination and accurate frequency calculation.

[0053] S140: Determine the frequency type and precise frequency based on the amplitude value and the actual frequency; It should be noted that frequency type refers to the power frequency standard of the power system, including the first frequency type (50Hz system) and the second frequency type (60Hz system). The frequency type is determined by comparing the peak energy levels within two preset frequency ranges.

[0054] For example, the maximum amplitude is searched within the range of 47Hz to 53Hz to obtain the first energy peak value mag50 = 9082.5 and its corresponding first frequency value f50 = 50Hz; the maximum amplitude is searched within the range of 57Hz to 63Hz to obtain the second energy peak value mag60 = 1200.3 and its corresponding second frequency value f60 = 60Hz. Comparing mag50 and mag60, since 9082.5 > 1200.3, the frequency type is determined to be the first frequency type (50Hz system).

[0055] Additionally, it should be noted that the precise frequency refers to the power frequency value with decimals obtained through interpolation, rather than the coarse frequency corresponding to integer frequency points. Due to the limited frequency resolution of FFT, the frequencies corresponding to integer frequency points are only approximate values. By interpolating using the amplitude values ​​of the peak frequency point and its adjacent frequency points, a more accurate frequency estimate can be obtained.

[0056] For example, after determining it to be a 50Hz system, the amplitude value A_mid = 9082.5 at the integer peak position k = 50, the amplitude value A_left = 5500.0 at the left neighbor k = 49, and the amplitude value A_right = 7200.0 at the right neighbor k = 51 are taken. Substituting these values ​​into the interpolation formula, the offset is calculated to be 0.311. Therefore, the precise frequency is 50.311Hz.

[0057] Understandably, by comparing the energy peak values ​​within two preset frequency ranges, the power frequency system can be accurately determined without being affected by harmonics and noise; the precise frequency is obtained through interpolation calculation, breaking through the limitations of FFT frequency resolution and achieving sub-hertz level frequency detection accuracy.

[0058] S150: Based on the preset phase function, precise frequency, and frequency domain complex results, determine the phase value and output the phase value, frequency type, amplitude value, and precise frequency.

[0059] It should be noted that the preset phase function refers to the function used to calculate the complex phase angle, and the calculation formula is as follows: Where atan2 is the four-quadrant arctangent function, the return value is in degrees, ranging from -180° to 180°. For the real part, This is the imaginary part value. This function calculates the initial phase angle of the frequency component based on the real and imaginary parts of the frequency.

[0060] Phase value refers to the phase angle of a power frequency signal at the initial moment, measured in degrees. It represents the phase shift of that frequency component relative to a reference cosine wave. Phase value plays an important role in applications such as grid synchronization and power factor calculation.

[0061] For example, assuming the precise frequency is 50.311Hz and the corresponding frequency index is k=50 (rounded down), the real part real=8500.0f and the imaginary part img=3200.0f of the 50th frequency point are extracted from the complex number result in the frequency domain. These are then substituted into the phase function to calculate a phase value of 20.63°. The final output power frequency information includes: a phase value of 20.63°, a frequency type of the first frequency type (50Hz system), an amplitude value of 9082.5, and a precise frequency of 50.311Hz.

[0062] In addition, after calculating the phase value, the IIO device outputs complete power frequency information, including phase value, frequency type, amplitude value and precise frequency, for use by upper-level applications (such as grid connection control, power metering, relay protection, etc.).

[0063] In one feasible implementation, step S150 includes: Step S210: Determine the frequency point index corresponding to the precise frequency according to the preset index mapping table; It should be noted that the preset index mapping table refers to a pre-established lookup table that maps precise frequencies to the nearest frequency index. Since the precise frequency may not be an integer, and the frequency domain complex number result only contains frequency data corresponding to integer indices, it is necessary to find the integer frequency index that is closest to the precise frequency.

[0064] For example, assuming the precise frequency is 50.311Hz and the frequency resolution is 1Hz, the nearest integer frequency is 50Hz, and the corresponding frequency index is k=50. If the precise frequency is 50.689Hz, the nearest integer frequency is 51Hz, and the corresponding frequency index is k=51.

[0065] The frequency index refers to the sequence number of each complex element in the FFT result array, ranging from 0 to N / 2. Each index k corresponds to a specific frequency value.

[0066] Understandably, by using a pre-defined index mapping table, the calculated precise frequency can be quickly located to the corresponding frequency point in the frequency domain complex number result, providing an accurate index for subsequent extraction of the real and imaginary parts.

[0067] Step S220: Extract the real and imaginary parts corresponding to the frequency point indices from the frequency domain complex results; It should be noted that the real part and imaginary part refer to the two components of the complex data at a specified frequency index in the frequency domain complex number result. The real part represents the amplitude of the cosine component of that frequency component, and the imaginary part represents the amplitude of the sine component of that frequency component. Together, they determine the amplitude and phase of that frequency component.

[0068] For example, assuming the frequency index k=50, the 50th element extracted from the frequency domain complex result has a real part of 8500.0f and an imaginary part of 3200.0f. These two values ​​will be used for subsequent phase calculations.

[0069] Understandably, by extracting the real and imaginary parts of a specified frequency point from the complex results in the frequency domain, all the complex information required to calculate the phase value is obtained, thus avoiding the computational overhead of traversing the entire frequency domain results.

[0070] Step S230: Input the real and imaginary parts into a preset phase function to obtain the phase value; For example, substituting the real part real=8500.0f and the imaginary part img=3200.0f into the phase function yields a phase value of 20.63°.

[0071] Understandably, by inputting the real and imaginary parts into a preset phase function, the initial phase angle of the power frequency signal can be calculated quickly and accurately without additional time-domain analysis or complex calculations, thus achieving joint extraction of frequency and phase.

[0072] Additionally, for example, to aid in understanding the implementation process of the power line frequency detection method obtained in this embodiment, please refer to... Figure 3 , Figure 3 A simplified flowchart of a power frequency detection method for power lines is provided, specifically: First, the system continuously acquires power line signals at a preset sampling frequency using an IIO device. When a preset number (e.g., 1024) of raw sample values ​​are acquired, a detection process is triggered. Each raw sample value is converted from integer format to single-precision floating-point number, and the arithmetic mean of all floating-point numbers is calculated. This average is subtracted from each sample value to eliminate the DC bias component, resulting in clean AC component data.

[0073] Subsequently, the obtained AC component data is input into a preset forward transform function to perform a fast Fourier transform, converting the time-domain signal to the frequency domain and obtaining a set of frequency-domain complex results. Each complex number corresponds to a frequency point and contains both real and imaginary parts.

[0074] In the frequency domain analysis phase, the system inputs the complex frequency domain results into a preset amplitude function to calculate the amplitude value at each frequency point and determines the actual frequency corresponding to each frequency point based on preset sampling parameters (sampling frequency and FFT points). Then, it searches for the largest amplitude value within a preset first frequency range (47Hz~53Hz) and a second frequency range (57Hz~63Hz) to obtain the first and second energy peak values. By comparing the two energy peak values, the frequency type is determined: if the first energy peak is larger, it is determined to be the first frequency type (50Hz system); if the second energy peak is larger, it is determined to be the second frequency type (60Hz system). After selecting the frequency type, a three-point parabolic interpolation calculation is performed using the amplitude values ​​of the peak frequency point and its left and right adjacent frequency points to obtain the accurate frequency that breaks through the FFT frequency resolution limitation.

[0075] At the same time, the system determines the frequency index corresponding to the precise frequency according to the preset index mapping table, extracts the real and imaginary parts corresponding to the frequency index from the frequency domain complex number results, inputs the real and imaginary parts into the preset phase function, and calculates the phase value of the power frequency signal.

[0076] Finally, the system integrates all the above calculation results and outputs complete power frequency detection information, including frequency type, precise frequency, amplitude value and phase value, for use by upper-level applications (such as grid connection control, power metering, relay protection, etc.), thus completing a complete power line frequency detection process.

[0077] In the embodiments of steps S110-S150 above, by collecting a preset number of original sampled values, the frequency resolution is balanced to prevent the accuracy reduction caused by excessively high or low frequency resolution; by performing floating-point conversion and DC removal processing on the original sampled values, DC bias interference in the signal is filtered out, thereby achieving noise reduction of the power line signal; by obtaining the amplitude value through a preset amplitude algorithm and determining the actual frequency in combination with preset sampling parameters, a comprehensive extraction of signal features from the frequency domain perspective is achieved; by determining the power frequency type and precise frequency based on the amplitude value and the actual frequency, the time domain signal is converted to the frequency domain for analysis, and the non-time domain waveform features are used for frequency determination, thereby avoiding the problems of waveform distortion caused by harmonics and zero-crossing point offset caused by noise in the zero-crossing detection method; by calculating the frequency domain complex result through a preset phase algorithm and precise frequency, the phase value is obtained, making the output power frequency information more complete and directly applicable to various power system application scenarios.

[0078] Based on the first embodiment of this application, in the second embodiment of this application, the content that is the same as or similar to that in Embodiment 1 above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 2 Before step S110, the power frequency detection method for power lines also includes the following steps: Step S310: Scan the IIO device to obtain at least one valid channel and extract the identifier field from the FFTW library deployed on the IIO device; It should be noted that a valid channel refers to a physical sampling channel available in the IIO device. Each channel corresponds to an independent signal input link, such as the A-phase voltage channel, B-phase voltage channel, and C-phase voltage channel in a three-phase power system. These three channels support synchronous acquisition. Furthermore, each sampling channel independently maintains a circular buffer, using mutex locks to ensure thread safety for data reading and writing. After scanning the IIO devices, a list of actually existing and functioning channels in the system is obtained.

[0079] For example, by calling the scanning interface of the IIO subsystem, three valid channels are obtained, corresponding to the A-phase, B-phase, and C-phase voltage signals of the power line, respectively. Each channel has a unique channel ID and attribute configuration.

[0080] The FFTW library refers to a Fast Fourier Transform library pre-deployed on IIO devices, providing efficient FFT calculation functions and function creation interfaces. In this embodiment, the FFTW library is used to create and execute forward transform functions.

[0081] The identifier field refers to the unique identification information generated by the FFTW library during initialization, specifically the FFTW_FORWARD and FFTW_MEASURE fields, used to distinguish different FFTW function configurations. This identifier field records information such as the function's input / output direction and optimization strategy, ensuring that subsequently created forward transform functions match the hardware environment and data format.

[0082] For example, the optimization strategy identifier field for the current device is extracted from the FFTW library. This field contains the optimal FFT computation parameter configuration for the current processor architecture.

[0083] Understandably, obtaining valid channels by scanning IIO devices ensures that the target of subsequent data acquisition is clear and usable; by extracting the identifier field of the FFTW library, a configuration basis is provided for creating a forward transformation function adapted to the current hardware environment, avoiding the overhead of repeated optimization calculations.

[0084] Step S320: Allocate multiple buffers for each valid channel; It should be noted that the various buffers refer to the storage space allocated for each valid channel for temporarily storing sampled data and intermediate calculation results. These include at least the single-precision floating-point data buffer `fft_data`, the FFTW single-precision complex input buffer `in`, the FFTW single-precision complex output buffer `out`, and the magnitudes buffer. Specifically, the `fft_data` buffer stores the single-precision floating-point data after format conversion and DC removal; the `in` buffer serves as the complex input interface for the FFT; the `out` buffer stores the frequency domain complex results of the FFT output; and the `magnitudes` buffer stores the amplitude values ​​at each frequency point calculated based on the frequency domain complex results.

[0085] For example, the following are allocated for phase A channel: an fft_data buffer with a capacity of N×sizeof(float) (N=1024); an in and out buffer with a capacity of N×sizeof(fftwf_complex); and a magnitudes buffer with a capacity of N / 2×sizeof(float) (i.e., 512 floating-point numbers).

[0086] Understandably, by allocating multiple buffers to each valid channel, independent management and parallel processing of multi-channel data are achieved, avoiding data interference between channels. The dedicated allocation of each buffer reduces memory fragmentation and dynamic allocation overhead, providing continuous and fixed storage space for subsequent format conversion, FFT calculation and amplitude extraction.

[0087] Step S330: Create a forward transformation function based on the capacity and identifier fields corresponding to each buffer; For example, for phase A channel, its in buffer capacity is N×sizeof(fftwf_complex), and its out buffer capacity is also N×sizeof(fftwf_complex). Combining the extracted FFTW library identifier field, a forward transform function is created. This function converts the real data in the in buffer into the frequency domain complex result in the out buffer and uses the optimization parameters in the identifier field to accelerate the calculation. Similarly, independent FFTW functions are created for phase B and phase C channels respectively.

[0088] Understandably, by creating a forward transform function based on the capacity and identifier field of each buffer, the input and output buffers of the FFT function are ensured to strictly match the actual allocated data space. At the same time, the hardware optimization information of the FFTW library is utilized to improve the computational efficiency of frequency domain transformation.

[0089] In one possible implementation, after step S330, the method further includes: Step S331: Acquire multiple sets of power line signals; Step S332: Convert each power line signal into its corresponding digital signal to obtain each original sampled value.

[0090] For example, the IIO device continuously acquires three power line signals (phases A, B, and C) at a sampling frequency of 1024Hz. For each acquired sample, the ADC converts it into a 16-bit unsigned integer and stores it as the raw sample value in the corresponding channel's circular buffer. The sampling frequency fs should satisfy the Nyquist sampling theorem, i.e. ,in This represents the highest effective frequency component in the signal. An FFT analysis is triggered when the number of accumulated samples in the circular buffer reaches 1024.

[0091] In this embodiment, by continuously acquiring multiple sets of power line signals and converting them into raw sampled values, continuous data input is provided for subsequent frequency domain analysis, ensuring the real-time and continuous nature of power frequency detection.

[0092] In the embodiments of steps S310-S320 above, by scanning the IIO device to obtain valid channels and allocating multiple buffers, independent acquisition and management of multi-channel signals are realized; by extracting the FFTW library identifier field and creating a forward transform function according to the buffer capacity, the precise matching of the FFT function with the hardware environment and data scale is ensured. In subsequent FFT analysis, there is no need to perform the steps of allocating memory and creating functions, which provides an efficient execution foundation for subsequent frequency domain analysis.

[0093] Based on any of the above embodiments, in the third embodiment of this application, the content that is the same as or similar to the above embodiments can be referred to the above description, and will not be repeated hereafter. Based on this, step S140, the power frequency detection method for power lines further includes the following step: Step S410: Determine the first frequency range and the second frequency range based on the actual frequency, wherein the value of the second frequency range is greater than the value of the first frequency range; It should be noted that the first frequency range refers to a preset frequency interval centered at 50Hz, used to search for the energy peak of the 50Hz system power frequency signal; the second frequency range refers to a preset frequency interval centered at 60Hz, used to search for the energy peak of the 60Hz system power frequency signal. Both ranges are located using actual frequency values, that is, by traversing the actual frequencies of all frequency points and filtering out the frequency point indices that fall within the preset value intervals.

[0094] For example, suppose the sampling frequency fs = 1024 Hz, the number of FFT points N = 1024, and the frequency resolution is 1 Hz. The first frequency range is set to 47 Hz ~ 53 Hz, with corresponding frequency point indices k = 47 to k = 53; the second frequency range is set to 57 Hz ~ 63 Hz, with corresponding frequency point indices k = 57 to k = 63. The minimum value of the second frequency range, 57 Hz, is greater than the maximum value of the first frequency range, 53 Hz.

[0095] Step S420: Search for the maximum amplitude value within the first frequency range to obtain the first energy peak value and the first frequency value, and search for the maximum amplitude value within the second frequency range to obtain the second energy peak value and the second frequency value; It should be noted that the first energy peak value refers to the maximum amplitude value searched within the first frequency range, reflecting the energy intensity of the signal near 50Hz; the second energy peak value refers to the maximum amplitude value searched within the second frequency range, reflecting the energy intensity of the signal near 60Hz.

[0096] For example, when the amplitude values ​​of each frequency point are traversed in the range of 47Hz to 53Hz, it is found that the amplitude value at k=50 is the largest, which is 9082.5, so the first energy peak value mag50=9082.5; when the amplitude values ​​of each frequency point are traversed in the range of 57Hz to 63Hz, it is found that the amplitude value at k=60 is the largest, which is 1200.3, so the second energy peak value mag60=1200.3.

[0097] The first frequency value refers to the frequency value represented by the frequency point corresponding to the first energy peak; the second frequency value refers to the frequency value represented by the frequency point corresponding to the second energy peak.

[0098] For example, the frequency index k=50 corresponding to the first energy peak mag50 is 50Hz, and its actual frequency is 50Hz, so the first frequency value f50=50Hz; the frequency index k=60 corresponding to the second energy peak mag60 is 60Hz, and its actual frequency is 60Hz, so the second frequency value f60=60Hz.

[0099] Understandably, by searching for the maximum amplitude value in two preset frequency ranges respectively, the energy contribution of the 50Hz system and the 60Hz system in the signal can be quantitatively evaluated, providing an objective basis for subsequent frequency type determination and avoiding the subjectivity and fragility of the single threshold judgment in the time-domain zero-crossing detection method.

[0100] Step S430: Compare the first energy peak value and the second energy peak value; Step S440: If the first energy peak value is greater than the second energy peak value, then the frequency type is determined to be the first frequency type, and the first frequency value is interpolated to obtain the accurate frequency; It should be noted that the precise frequency refers to the power frequency value with decimals obtained through interpolation calculation. Its accuracy is higher than the FFT frequency resolution (1Hz in this example) and can achieve sub-hertz level frequency detection.

[0101] Additionally, it should be noted that interpolation calculation refers to using the amplitude values ​​of the peak frequency and its left and right adjacent frequencies, through parabolic fitting or other interpolation algorithms, to estimate the offset of the true peak position, thereby obtaining a more accurate frequency value. Commonly used interpolation algorithms include three-point parabolic interpolation and Gaussian interpolation.

[0102] For example, the frequency index k=50 corresponds to the first energy peak mag50=9082.5. The amplitude value of the left neighboring point k=49 is taken as 5500.0, and the amplitude value of the right neighboring point k=51 is taken as 7200.0. A three-point parabolic interpolation formula is used. , The amplitude value of the right neighboring point. The amplitude value of the left neighbor point. This represents the amplitude value at the current peak point. The offset value is calculated. =(7200-5500) / (2×9082.5-5500-7200)=1700 / 5465≈0.311. Therefore, the precise frequency is 50+0.311=50.311Hz.

[0103] Step S450: If the first energy peak value is less than the second energy peak value, then the frequency type is determined to be the second frequency type, and the second frequency value is interpolated to obtain the accurate frequency; By way of example, if mag50=1200.3 and mag60=9082.5, then mag50<mag60, and the frequency type is determined to be the second frequency type (60Hz system).

[0104] It can be understood that by comparing the magnitudes of energy peaks in two frequency ranges, the power frequency standard of the power system can be accurately determined, and even if the 60Hz system generates a harmonic component near 50Hz, it will not cause misjudgment; interpolation calculation is performed on the selected frequency value, which breaks through the limitation of FFT frequency resolution and realizes high-precision frequency measurement, meeting the strict requirements for frequency accuracy in applications such as grid-connected control.

[0105] In a feasible embodiment, in step S430 or step S440, the step of performing interpolation calculation on the first frequency value or the second frequency value to obtain an accurate frequency comprises: Step S510: extracting interpolation calculation points from the first frequency value or the second frequency value; It should be noted that the interpolation calculation points refer to three key data points used for interpolation calculation, including the peak frequency point, the amplitude values of its left and right adjacent frequency points and the corresponding frequency values. These three points constitute the basic data for interpolation calculation.

[0106] By way of example, for the first frequency value f50=50Hz, the extracted interpolation calculation points are: left adjacent point (k=49, freq=49Hz, mag=5500.0), peak point (k=50, freq=50Hz, mag=9082.5), right adjacent point (k=51, freq=51Hz, mag=7200.0).

[0107] It can be understood that by extracting the data of the peak frequency point and its adjacent frequency points, all input parameters required for interpolation calculation are obtained, which provides a data basis for the subsequent accurate frequency calculation.

[0108] Step S520: fitting the interpolation calculation points based on a preset interpolation algorithm to obtain an accurate frequency.

[0109] It should be noted that the preset interpolation algorithm refers to a pre-selected mathematical method for estimating the real peak position, and this embodiment adopts a three-point parabolic interpolation algorithm. This algorithm assumes that the amplitude spectrum near the peak is parabolic, and fits the position of the parabolic vertex through the coordinates of three points, thereby obtaining the offset δ.

[0110] It can be understood that by fitting three interpolation calculation points through a preset interpolation algorithm, the frequency detection accuracy can be improved to the sub-hertz level without increasing the number of FFT points, which takes into account both calculation efficiency and detection accuracy.

[0111] In this embodiment, by searching for the maximum amplitude value in the first frequency range and the second frequency range respectively and comparing the two, the accurate discrimination of the 50Hz system and the 60Hz system is achieved. Even if there are harmonics or noise interference in the signal, it will not affect the judgment result. By performing three-point parabolic interpolation on the selected frequency value, the limitation of FFT frequency resolution is broken, and high-precision frequency measurement is achieved, providing an accurate frequency reference for subsequent phase calculation and power frequency information output.

[0112] In the embodiments of steps S410-S450 above, by determining the first frequency range and the second frequency range based on the actual frequency, and searching for the maximum amplitude value in each of the two ranges, the automatic identification of the power system frequency mode is realized; by comparing the height of the two energy peaks, the misjudgment problem caused by harmonics and noise in the zero-crossing detection method is avoided; by performing interpolation calculation on the selected frequency value, the limitation of FFT frequency resolution is broken, and high-precision frequency detection at the sub-hertz level is realized, providing reliable frequency data for applications such as grid connection control and power metering.

[0113] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the power frequency detection method for power lines in this application. Any simple modifications based on this technical concept are within the protection scope of this application.

[0114] This application also provides a power frequency detection system; please refer to [reference needed]. Figure 4 The power frequency detection system includes: The preprocessing module 10 is used to convert each original sample value into a single-precision floating-point number in response to a preset number of original sample values ​​collected from the power line, and to process each single-precision floating-point number to remove the DC component, thereby obtaining each AC component data. Input module 20 is used to input the data of each AC component into a preset forward transform function to obtain the frequency domain complex result; The calculation module 30 is used to input the frequency domain complex result into a preset amplitude function to obtain the amplitude value, determine the actual frequency according to the preset sampling parameters, determine the frequency type and precise frequency according to the amplitude value and the actual frequency, and determine the phase value based on the preset phase function, precise frequency and frequency domain complex result. Output module 40 is used to output phase value, frequency type, amplitude value and precise frequency.

[0115] The power frequency detection system provided in this application employs the power frequency detection method for power lines described in the above embodiments, which can solve the technical problem that the zero-crossing detection method is susceptible to harmonic and noise interference. Compared with the prior art, the beneficial effects of the power frequency detection system provided in this application are the same as those of the power frequency detection method for power lines provided in the above embodiments, and other technical features of the power frequency detection system are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.

[0116] This application provides an electronic device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the power line frequency detection method of the above embodiment 1.

[0117] The following is for reference. Figure 5 The diagram illustrates a structural schematic of an electronic device suitable for implementing embodiments of this application. The electronic devices in these embodiments may include, but are not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 5 The electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.

[0118] like Figure 5As shown, the electronic device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory 1002 or a program loaded from a storage device 1003 into a random access memory 1004. The random access memory 1004 also stores various programs and data required for the operation of the electronic device. The processing unit 1001, the read-only memory 1002, and the random access memory 1004 are interconnected via a bus 1005. An input / output interface 1006 is also connected to the bus. Typically, the following systems can be connected to the input / output interface 1006: input devices 1007 including, for example, touchscreens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices 1008 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 1003 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1009. The communication device 1009 allows the electronic device to communicate wirelessly or wiredly with other devices to exchange data. Although the diagrams show electronic devices with various systems, it should be understood that it is not required to implement or have all of the systems shown. More or fewer systems may be implemented alternatively.

[0119] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from read-only memory 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.

[0120] The electronic device provided in this application, employing the power line frequency detection method in the above embodiments, can solve the technical problem that the zero-crossing detection method is susceptible to harmonic and noise interference. Compared with the prior art, the beneficial effects of the electronic device provided in this application are the same as those of the power line frequency detection method provided in the above embodiments, and other technical features of this electronic device are the same as those disclosed in the previous embodiment method, and will not be repeated here.

[0121] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.

[0122] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

[0123] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to execute the power line frequency detection method in the above embodiments.

[0124] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems or devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.

[0125] The aforementioned computer-readable storage medium may be included in an electronic device or may exist independently without being assembled into an electronic device.

[0126] The aforementioned computer-readable storage medium carries one or more programs. When the aforementioned one or more programs are executed by an electronic device, the electronic device causes the following actions: in response to acquiring a preset number of raw sampled values ​​from the power line, the electronic device converts each raw sampled value into a single-precision floating-point number, and performs DC component removal processing on each single-precision floating-point number to obtain AC component data; inputs each AC component data into a preset forward transform function to obtain a frequency domain complex result; inputs the frequency domain complex result into a preset amplitude function to obtain an amplitude value, and determines the actual frequency based on preset sampling parameters; determines the frequency type and precise frequency based on the amplitude value and the actual frequency; and determines the phase value based on a preset phase function, the precise frequency, and the frequency domain complex result, and outputs the phase value, frequency type, amplitude value, and precise frequency.

[0127] Computer program code for performing the operations of this application can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, and conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can 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 can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0128] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0129] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.

[0130] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the power line frequency detection method described above. This addresses the technical problem that the zero-crossing detection method is susceptible to harmonic and noise interference. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the power line frequency detection method provided in the above embodiments, and will not be elaborated upon here.

[0131] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.

Claims

1. A power frequency detection method for power lines, characterized in that, The power frequency detection method for power lines, applied to IIO devices, includes: In response to the collection of a preset number of raw sampled values ​​of the power line, each raw sampled value is converted into a single-precision floating-point number, and the DC component of each single-precision floating-point number is removed to obtain AC component data. The AC component data are input into a preset forward transform function to obtain the frequency domain complex result; The frequency domain complex result is input into a preset amplitude function to obtain the amplitude value, and the actual frequency is determined according to the preset sampling parameters; The frequency type and precise frequency are determined based on the amplitude value and the actual frequency. Based on the preset phase function, the precise frequency, and the frequency domain complex result, the phase value is determined, and the phase value, the frequency type, the amplitude value, and the precise frequency are output.

2. The power frequency detection method for power lines as described in claim 1, characterized in that, The frequency type includes at least a first frequency type and a second frequency type; the step of determining the frequency type and the precise frequency based on the amplitude value and the actual frequency includes: A first frequency range and a second frequency range are determined based on the actual frequency, wherein the value of the second frequency range is greater than the value of the first frequency range; The maximum amplitude value is searched within the first frequency range to obtain the first energy peak value and the first frequency value, and the maximum amplitude value is searched within the second frequency range to obtain the second energy peak value and the second frequency value. Compare the first energy peak value and the second energy peak value; If the first energy peak value is greater than the second energy peak value, then the frequency type is determined to be the first frequency type, and the first frequency value is interpolated to obtain the accurate frequency; If the first energy peak value is less than the second energy peak value, then the frequency type is determined to be the second frequency type, and the second frequency value is interpolated to obtain the accurate frequency.

3. The power frequency detection method for power lines as described in claim 2, characterized in that, The steps of interpolating the first frequency value or the second frequency value to obtain the accurate frequency include: Extract interpolation calculation points from the first frequency value or the second frequency value; The interpolation calculation points are fitted based on a preset interpolation algorithm to obtain the accurate frequency.

4. The power frequency detection method for power lines as described in claim 1, characterized in that, Before the step of converting each of the original sampled values ​​into a single-precision floating-point number, the method further includes: Scan the IIO device to obtain at least one valid channel, and extract the identification field from the FFTW library deployed on the IIO device; Allocate multiple buffers for each of the aforementioned valid channels; A forward transformation function is created based on the capacity of each buffer and the identifier field.

5. The power frequency detection method for power lines as described in claim 4, characterized in that, After the step of creating a forward transformation function based on the capacity of each buffer and the identifier field, the method further includes: Collect multiple sets of power line signals; Each of the power line signals is converted into a corresponding digital signal to obtain the original sampled value.

6. The power frequency detection method for power lines as described in claim 1, characterized in that, After the step of removing the DC component from each of the single-precision floating-point numbers to obtain the AC component data, the method further includes: Obtain the preset window function coefficients; The AC component data is multiplied by the window function coefficients to obtain the windowed AC component data; The windowed AC component data is used as input to the forward transform function to obtain the frequency domain complex result.

7. The power frequency detection method for power lines as described in claim 1, characterized in that, The step of determining the phase value based on the preset phase function, the precise frequency, and the frequency domain complex number result includes: The frequency point index corresponding to the precise frequency is determined according to a preset index mapping table; Extract the real and imaginary parts corresponding to the frequency point index from the frequency domain complex number result; The real part and the imaginary part are input into a preset phase function to obtain the phase value.

8. A power frequency detection system, characterized in that, The power frequency detection system, applied to IIO equipment, includes: The preprocessing module is used to convert each of the original sampled values ​​of the power line into a single-precision floating-point number in response to a preset number of original sampled values, and to perform DC component removal processing on each of the single-precision floating-point numbers to obtain AC component data. The input module is used to input the AC component data into a preset forward transform function to obtain the frequency domain complex result; The calculation module is used to input the frequency domain complex number result into a preset amplitude function to obtain an amplitude value, determine the actual frequency according to preset sampling parameters, determine the frequency type and precise frequency according to the amplitude value and the actual frequency, and determine the phase value based on a preset phase function, the precise frequency and the frequency domain complex number result. The output module is used to output the phase value, the frequency type, the amplitude value, and the precise frequency.

9. An electronic device, characterized in that, The device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the power line frequency detection method as described in any one of claims 1 to 7.

10. A readable storage medium, characterized in that, The readable storage medium is a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the power line frequency detection method as described in any one of claims 1 to 7.