An electric parameter high-precision analysis method based on a light DSP algorithm

By employing a lightweight DSP algorithm that combines whole-cycle sampling, window functions, and Kalman filtering, the problems of high hardware cost and low accuracy in electrical parameter monitoring equipment are solved, enabling high-precision, low-cost, and real-time electrical parameter analysis.

CN122361894APending Publication Date: 2026-07-10NANTONG VOCATIONAL COLLEGE
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-05-19
Publication Date
2026-07-10

AI Technical Summary

Technical Problem

Existing electrical parameter monitoring equipment suffers from high hardware costs, large size, poor deployment flexibility, and low-cost embedded devices have insufficient spectrum leakage and noise suppression capabilities, low harmonic analysis accuracy, and high computational overhead, making it difficult to balance lightweight design, real-time performance, and industrial-grade measurement accuracy.

Method used

An electrical parameter analysis method based on a lightweight DSP algorithm is adopted. By sampling the entire cycle and suppressing spectral leakage with a window function, combined with adaptive Kalman filtering and integer arithmetic, the time-domain power calculation is optimized, the computational overhead is reduced, and the CPU utilization is controlled.

Benefits of technology

It achieves high-precision harmonic measurement, improves steady-state accuracy to 0.1%, has strong real-time performance, reduces CPU utilization to 15%, adapts to power grid frequency fluctuations, and meets the needs of industrial real-time monitoring.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122361894A_ABST
    Figure CN122361894A_ABST
Patent Text Reader

Abstract

This invention relates to the field of power system parameter monitoring technology and discloses a high-precision analysis method for electrical parameters based on a lightweight DSP algorithm, comprising the following steps: sampling and data buffering, lightweight DSP core processing, electrical parameter output, and code-level optimization. This invention suppresses spectral leakage through integer-cycle sampling combined with window functions, achieving harmonic measurement accuracy of ±0.5%. After Kalman filtering, data fluctuation is reduced by 80%, and steady-state accuracy is improved to within 0.1%, enabling high-precision measurement. Simultaneously, downsampling and integer operations reduce computational load, and code-level optimization keeps CPU utilization ≤15%, allowing it to run on low-cost MCUs such as the STM32F407.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of power system parameter monitoring technology, specifically to a high-precision analysis method for electrical parameters based on a lightweight DSP algorithm. Background Technology

[0002] Current electrical parameter monitoring equipment falls into two categories: one is high-end power analyzers, which employ high-performance processors and dedicated algorithms, resulting in high measurement accuracy, but also in high hardware costs, large size, and poor deployment flexibility; the other is low-cost embedded monitoring devices, which mostly use basic sampling and floating-point operations, and suffer from problems such as spectrum leakage, insufficient noise suppression, low harmonic analysis accuracy, high computational overhead, and high CPU utilization, making it difficult to balance lightweight design, real-time performance, and industrial-grade measurement accuracy.

[0003] Traditional FFT harmonic analysis is prone to spectral leakage under non-integer sampling conditions, resulting in significant deviations between the measured harmonic amplitude and total harmonic distortion rate. Conventional digital filtering algorithms cannot balance steady-state smoothness and dynamic response speed. Time-domain power calculations often use floating-point root mean square operations, resulting in low computational efficiency. Embedded algorithms do not perform fixed-point optimization and execution efficiency optimization for hardware resources, which restricts their large-scale application on low-cost MCUs. In view of this, we propose a high-precision electrical parameter analysis method based on a lightweight DSP algorithm. Summary of the Invention

[0004] The purpose of this invention is to provide a high-precision analysis method for electrical parameters based on a lightweight DSP algorithm, so as to solve the problems mentioned in the background art.

[0005] To achieve the above objectives, the present invention provides the following technical solution: a high-precision analysis method for electrical parameters based on a lightweight DSP algorithm, comprising the following steps: S1. Sampling and Data Buffering: The ADC is used to sample analog voltage and current signals, and the sampled data is stored in a DMA double buffer. The sampling frequency is set to 3.2kHz or 6.4kHz, and the data buffer length is 512 points. S2, Lightweight DSP Core Processing: Performs downsampling and integer arithmetic preprocessing, FFT harmonic analysis, adaptive Kalman filtering, and time-domain power calculation optimization on the sampled data in sequence; S3. Electrical Parameter Output: The processed electrical parameters and harmonic data are transmitted to the host computer via serial port, and the waveforms and values ​​are displayed on the LCD. The FFT harmonic analysis uses a 256-point FFT operation to meet the integer sampling condition. The 1st to 31st harmonic components are extracted through dynamic peak search and phase compensation, and the total harmonic distortion rate is calculated. The adaptive Kalman filter is used to suppress sampling noise and power grid fluctuation interference. The time-domain power calculation optimization is achieved by downsampling combined with integer arithmetic. S4. Code-level optimization: Uses fixed-point or single-precision floating-point arithmetic, combined with hardware FPU acceleration, reduces computational overhead through loop unrolling and table lookup, and controls the CPU utilization of DSP tasks.

[0006] Optionally, the integer-cycle sampling in S2 satisfies the relation N / f s =mT0; where N is the number of sampling points, f s Where m is the sampling frequency, T0 is a positive integer, and T0 is the period of the 50Hz power frequency fundamental wave.

[0007] Optionally, S2 further includes: in non-integer period sampling scenarios, using a Hanning window or a Hamming window to suppress spectral leakage.

[0008] Optionally, the adaptive Kalman filter has a process noise covariance Q=0.01 and a measurement noise covariance R=0.1; the data fluctuation is reduced by 80% after filtering, and the steady-state measurement accuracy is ≤0.1%.

[0009] Optionally, time-domain power calculation uses 64-point downsampling and replaces floating-point root mean square calculation with integer operations; active power, apparent power, and power factor are updated every 100ms.

[0010] Optionally, after code-level optimization, the CPU utilization of DSP tasks is ≤15%.

[0011] Optionally, the method is implemented based on an STM32F407 microcontroller.

[0012] Optionally, when the sampling frequency is 6.4kHz, the frequency resolution of the 256-point FFT is 25Hz, the single operation time is 0.2ms, and the total harmonic distortion rate measurement accuracy is ±0.5%.

[0013] Compared with existing technologies, this invention provides a high-precision analysis method for electrical parameters based on a lightweight DSP algorithm, which has the following advantages: 1. This high-precision electrical parameter analysis method based on a lightweight DSP algorithm suppresses spectral leakage through integer-cycle sampling and window functions, achieving a harmonic measurement accuracy of ±0.5%. After Kalman filtering, data fluctuations are reduced by 80%, and steady-state accuracy is improved to within 0.1%, enabling high-precision measurement. At the same time, the computational load is reduced through downsampling and integer operations, and code-level optimization keeps the CPU utilization rate ≤15%, allowing it to run on low-cost MCUs such as STM32F407.

[0014] 2. This high-precision electrical parameter analysis method based on lightweight DSP algorithm achieves a single calculation time of only 0.2ms for 256-point FFT and a power parameter refresh time of 100ms, meeting the real-time monitoring needs of industry and possessing the advantage of strong real-time performance.

[0015] 3. This high-precision analysis method for electrical parameters based on a lightweight DSP algorithm combines whole-cycle sampling with non-whole-cycle window function suppression, making it adaptable to power grid frequency fluctuation scenarios and taking into account both steady-state and dynamic performance. Attached Figure Description Figure 1 This is a schematic diagram of the process of the present invention; Figure 2 This is a schematic diagram of the FFT integer harmonic analysis results of the present invention; Figure 3 This is a schematic diagram of the FFT non-integer period harmonic analysis results of the present invention; Figure 4 This is a schematic diagram illustrating the effect of using a Hanning window in this invention; Figure 5 This is a simulation diagram comparing the full-time domain filtering effect of the present invention; Figure 6 This is a schematic diagram comparing the step response speed of the present invention; Figure 7 This is a schematic diagram showing a detailed comparison between the stationary and abrupt change sections of the present invention; Figure 8 This is a schematic diagram showing the filtering time and response speed under different parameters of the present invention; Detailed Implementation

[0016] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0017] like Figures 1-8 As shown, the present invention provides a technical solution: a high-precision analysis method for electrical parameters based on a lightweight DSP algorithm, comprising the following steps: S1. Sampling and Data Buffering: The ADC is used to sample analog voltage and current signals, and the sampled data is stored in a DMA double buffer. The sampling frequency is set to 3.2kHz or 6.4kHz, and the data buffer length is 512 points. S2, Lightweight DSP Core Processing: Performs downsampling and integer arithmetic preprocessing, FFT harmonic analysis, adaptive Kalman filtering, and time-domain power calculation optimization on the sampled data in sequence; Among them, integer-cycle sampling satisfies the relationship N / f s =mT0; where N is the number of sampling points, f s Where m is the sampling frequency, T0 is the 50Hz power frequency fundamental frequency period; in non-integer period sampling scenarios, Hanning window or Hamming window is used to suppress spectral leakage.

[0018] At a sampling frequency of 6.4kHz, the frequency resolution of the 256-point FFT is 25Hz, the single operation time is 0.2ms, and the total harmonic distortion rate measurement accuracy is ±0.5%. S3. Electrical Parameter Output: The processed electrical parameters and harmonic data are transmitted to the host computer via serial port, and the waveforms and values ​​are displayed on the LCD. The FFT harmonic analysis uses a 256-point FFT operation to meet the integer sampling condition. The 1st to 31st harmonic components are extracted through dynamic peak search and phase compensation, and the total harmonic distortion rate is calculated. The adaptive Kalman filter is used to suppress sampling noise and power grid fluctuation interference. The time-domain power calculation optimization is achieved by downsampling combined with integer arithmetic. The adaptive Kalman filter has a process noise covariance Q=0.01 and a measurement noise covariance R=0.1; the data fluctuation is reduced by 80% after filtering, and the steady-state measurement accuracy is ≤0.1%.

[0019] Time-domain power calculation uses 64-point downsampling and replaces floating-point root mean square calculation with integer operations; active power, apparent power, and power factor are updated every 100ms.

[0020] S4. Code-level optimization: Uses fixed-point or single-precision floating-point arithmetic, combined with hardware FPU acceleration, reduces computational overhead through loop unrolling and table lookup, and controls the CPU utilization of DSP tasks.

[0021] After code-level optimization, the CPU utilization rate of DSP tasks is ≤15%.

[0022] This embodiment is implemented based on the STM32F407 microcontroller.

[0023] In FFT harmonic analysis, a typical power frequency voltage signal model containing the 1st, 3rd, 5th, 7th, 9th, 11th, and 13th harmonics was simulated and constructed. Its mathematical expression is as follows: ; in, This represents the instantaneous value of the power frequency voltage as a function of time t. For harmonic order; The amplitude of the h-th harmonic; the amplitude of the fundamental frequency. 3rd to 13th harmonic amplitude ; For time; fundamental frequency =50Hz, amplitude of each harmonic All are set to 1.5V (50% of the fundamental amplitude of 3.0V), initial phase Set to 0; Let be the angular frequency of the h-th harmonic.

[0024] Sampling frequency Number of sampling points At this point, the sampling time length It is exactly equal to the fundamental period. 2 times ( ), satisfying the integer period sampling condition described in the formula.

[0025] According to the formula Calculate the amplitude corresponding to each spectral line and extract the actual measured values ​​of the fundamental wave and each harmonic component.

[0026] The complex spectrum value of the k-th frequency point is obtained by Fast Fourier Transform (FFT) of a time-domain sampled sequence of length N. For discrete frequency points; For complex spectrum The modulus, i.e., the spectral amplitude; This is the amplitude correction factor; For the first The actual voltage amplitude corresponding to each frequency point; For complex numbers The argument of the k-th harmonic corresponds to the actual phase of the k-th harmonic. ; Based on the Nyquist sampling theorem, the highest frequency point is effectively analyzed to avoid aliasing distortion.

[0027] like Figure 2 As shown in the spectrum, the energy of each harmonic is highly concentrated at its corresponding discrete frequency point, with no energy dispersion. Analysis of the data indicates that the actual measured amplitudes of the fundamental wave and each odd harmonic (150Hz, 250Hz, ..., 650Hz) are in high agreement with the theoretical values. For example, the theoretical amplitude of the 3rd harmonic is 1.5000V, while the measured amplitude is 1.5002V; the theoretical amplitude of the 13th harmonic is 1.5000V, while the measured amplitude is 1.5051V. The results directly verify the formula... The theory is that when the sampling time is an integer multiple of the signal period, the spectrum lines of the FFT can be precisely aligned with the actual harmonic frequencies of the signal, thereby avoiding spectrum leakage and obtaining accurate amplitude and frequency information.

[0028] in, This represents the number of sampling points for the discrete signal. The sampling frequency for analog-to-digital conversion; The fundamental frequency period; A positive integer, representing the number of fundamental frequency cycles included in the total sampling duration. The FFT integer sampling data is shown in the table below: Harmonic number Theoretical amplitude (V) Actual amplitude (V) Theoretical percentage (%) Actual percentage (%) 1 3.0000 3.0007 100.00 100.00 3 1.5000 1.5002 50.00 49.99 5 1.5000 1.4996 50.00 49.97 7 1.5000 1.5002 50.00 50.00 9 1.5000 1.4976 50.00 49.91 11 1.5000 1.4997 50.00 49.98 13 1.5000 1.4987 50.00 49.95 Modify the sampling frequency (non-integer cycle sampling) as follows: Figure 3As shown, the spectrum graph exhibits significant spectral leakage, meaning that harmonic energy is no longer concentrated on a single spectral line but "leaks" to multiple adjacent frequency points. In the corresponding harmonic analysis table, the actual measured amplitudes of each harmonic (e.g., 1.4659 V for the 3rd harmonic and 1.4029 V for the 5th harmonic) deviate significantly from the theoretical values ​​(1.5000 V), and these deviations are irregular. Non-integer period sampling violates the periodicity assumption of the FFT algorithm. Windowing the signal (rectangular window) causes convolution and diffusion in the spectrum, affecting measurement accuracy. The non-integer period FFT data is shown in the table below: Harmonic number Theoretical amplitude (V) Actual amplitude (V) Theoretical percentage (%) Actual percentage (%) 1 3.0000 2.9699 100.00 100.00 3 1.5000 1.4136 50.00 47.60 5 1.5000 1.3562 50.00 45.67 7 1.5000 1.3184 50.00 44.39 9 1.5000 1.2862 50.00 43.31 11 1.5000 1.2769 50.00 42.99 13 1.5000 1.3322 50.00 44.86 In actual power grids, the power frequency is not strictly stable at 50 Hz, and frequency fluctuations such as 49 Hz may occur, causing sampling to fail to meet the integer cycle condition, resulting in spectral leakage and severely affecting the accuracy of harmonic measurements. To evaluate the system's performance under asynchronous sampling and suppress leakage, this embodiment compares the harmonic analysis effects of rectangular windows, Hanning windows, and Hamming windows at a fundamental frequency of 49 Hz. The simulation conditions were set to a sampling frequency of 6400 Hz, 256 sampling points, and a frequency resolution of 25 Hz. The results show that, under non-integer cycle sampling at 49 Hz, although the rectangular window has a high frequency resolution, its sidelobe attenuation is poor (-13 dB), causing severe leakage of harmonic energy to adjacent frequency points. The measured amplitudes of each harmonic (e.g., the 13th harmonic is only 0.8482 V) deviate significantly from the theoretical value (1.5000 V). In contrast, the Hanning window and Hamming window, with their excellent sidelobe suppression characteristics (sidelobe attenuation reaching -32 dB and -43 dB respectively), effectively reduce spectral leakage, and the measured amplitudes of each harmonic are closer to the true values. Although windowing slightly widens the main lobe and reduces amplitude accuracy, it significantly improves the stability and reliability of harmonic analysis under non-ideal power frequency conditions, providing effective algorithmic support for the system to cope with actual power grid frequency fluctuations. The Hanning window's spectral leakage suppression data are shown in the table below: Harmonic number Theoretical amplitude (V) Windowless amplitude (V) Windowing amplitude (V) Windowless percentage (%) Windowing percentage (%) 1 3.0000 2.9721 2.9984 100.00 100.00 3 1.5000 1.4135 1.4932 50.00 49.80 5 1.5000 1.3587 1.4850 50.00 49.53 7 1.5000 1.3177 1.4716 50.00 49.08 9 1.5000 1.2879 1.4500 50.00 48.36 11 1.5000 1.2767 1.4174 50.00 47.27 13 1.5000 1.3347 1.3768 50.00 45.92 This embodiment implements adaptive Kalman filtering using a Kalman filter. A one-dimensional Kalman filter model is constructed in the Matlab platform, focusing on analyzing the influence of process noise covariance Q and measurement noise covariance R on the filtering effect. The Kalman parameter set is first configured, with the following data: Parameter group Q value R value Feature Description Group 1 1e-4 1e-2 Small Q, Large R → Smooth, slow response Group 2 1e-2 1e-2 Medium Q, Medium R → Balance Group 3 1e-2 1e-4 Large Q, small R → Fast response but volatile Group 4 1e-4 1e-4 Little Q, Little R → Sensitive To simulate step change scenarios in actual measurements (such as electrical parameter jumps caused by sudden load changes), a 500-point step signal is generated as the true value, with the first 200 points set to 0 and the last 300 points set to 1. Gaussian white noise with a standard deviation of 0.1 is superimposed as the measured value.

[0029] Simulation results are as follows Figure 5As shown; to quantify the filtering performance of different parameter groups, the following three indicators are calculated: rise time: the number of transition sampling points from 0.1 to 0.9, reflecting the dynamic response speed; mean square error (MSE): the deviation between the filtered output and the real signal, reflecting the filtering accuracy; execution time: the time it takes for the algorithm to run, reflecting the computational complexity.

[0030] Among them, Group 1 (Q=1e-4, R=1e-2): has the smoothest filter curve, but responds slowly to step changes and has the longest rise time; Group 2 (Q=1e-2, R=1e-2): Achieves a good balance between smoothness and response speed, making it a better engineering compromise; Group 3 (Q=1e-2, R=1e-4): The response speed is the fastest, but the filtered curve still fluctuates significantly, and the noise suppression effect is poor. Group 4 (Q=1e-4, R=1e-4): It is too sensitive to the measured value, the filtering effect is not obvious, and it basically follows the noise change.

[0031] like Figure 6 As shown, the tracking ability of different parameters to the step response can be observed more clearly, and the filtering results of the step region (sampling points 150-300) can be magnified. Among them, the rise process of group 1 is the smoothest, with a rise time of 108 sampling points; group 3 responds almost synchronously with the noise measurement, with a rise time of only 15 sampling points; the rise time of group 2 is 42 sampling points, showing a moderate response speed.

[0032] like Figure 7 As shown, a 2-row × 4-column layout is used to display the filtering details of each parameter group in the steady-state segment (1-150 points) and the abrupt change segment (150-300 points). This comparison intuitively reveals the trade-off between parameter selection and steady-state error and dynamic tracking capability: Group 1 performs best in the steady-state segment (minimum fluctuation), but its tracking lag is significant in the abrupt change segment; Group 3 tracks rapidly in the abrupt change segment, but its fluctuation is large in the steady-state segment; Group 2 shows relatively balanced performance in both stages.

[0033] The present invention has been described in detail above. However, modifications or improvements can be made to it, which will be obvious to those skilled in the art. Therefore, any modifications or improvements that do not depart from the spirit of the present invention are within the scope of protection of the present invention.

Claims

1. A high-precision analysis method for electrical parameters based on a lightweight DSP algorithm, characterized in that, Includes the following steps: S1. Sampling and Data Buffering: ADC is used to sample analog voltage and current quantities, and DMA is used to store the sampled data in a double buffer. The data buffer length is 512 points. S2, Lightweight DSP Core Processing: Performs downsampling and integer arithmetic preprocessing, FFT harmonic analysis, adaptive Kalman filtering, and time-domain power calculation optimization on the sampled data in sequence; S3. Electrical Parameter Output: The processed electrical parameters and harmonic data are transmitted to the host computer via serial port, and the waveforms and values ​​are displayed on the LCD. The FFT harmonic analysis uses a 256-point FFT operation to meet the integer sampling condition. The 1st to 31st harmonic components are extracted through dynamic peak search and phase compensation, and the total harmonic distortion rate is calculated. The adaptive Kalman filter is used to suppress sampling noise and power grid fluctuation interference. The time-domain power calculation optimization is achieved by downsampling combined with integer arithmetic. S4. Code-level optimization: Uses fixed-point or single-precision floating-point arithmetic, combined with hardware FPU acceleration, reduces computational overhead through loop unrolling and table lookup, and controls the CPU utilization of DSP tasks.

2. The high-precision electrical parameter analysis method based on a lightweight DSP algorithm according to claim 1, characterized in that, The integer-cycle sampling in S2 satisfies the relation N / f s =mT0; where N is the number of sampling points, f s Where m is the sampling frequency, T0 is a positive integer, and T0 is the period of the 50Hz power frequency fundamental wave.

3. The high-precision electrical parameter analysis method based on a lightweight DSP algorithm according to claim 2, characterized in that, S2 further includes: in non-integer period sampling scenarios, using a Hanning window or a Hamming window to suppress spectral leakage.

4. The high-precision electrical parameter analysis method based on a lightweight DSP algorithm according to claim 1, characterized in that, The adaptive Kalman filter has a process noise covariance Q=0.01 and a measurement noise covariance R=0.1; the data fluctuation is reduced by 80% after filtering, and the steady-state measurement accuracy is ≤0.1%.

5. The high-precision electrical parameter analysis method based on a lightweight DSP algorithm according to claim 1, characterized in that, Time-domain power calculation uses 64-point downsampling and replaces floating-point root mean square calculation with integer operations; active power, apparent power, and power factor are updated every 100ms.

6. The high-precision electrical parameter analysis method based on a lightweight DSP algorithm according to claim 1, characterized in that, After code-level optimization, the CPU utilization rate of DSP tasks is ≤15%.

7. The high-precision electrical parameter analysis method based on a lightweight DSP algorithm according to claim 1, characterized in that, The method is implemented based on the STM32F407 microcontroller.

8. The high-precision electrical parameter analysis method based on a lightweight DSP algorithm according to claim 2, characterized in that, At a sampling frequency of 6.4kHz, the frequency resolution of the 256-point FFT is 25Hz, the single operation time is 0.2ms, and the total harmonic distortion rate measurement accuracy is ±0.5%.