Research on harmonic detection based on wavelet threshold and FFT algorithm

ABSTRACT The fast Fourier transform (FFT) algorithm with window interpolation is the most commonly used and most effective method in harmonic analysis. However, the fast Fourier transform has a great dependence on the quality of the signal, and the existence of noise makes the detection result error. A harmonic detection method based on wavelet threshold preprocessing noise elimination and windowed interpolation FFT algorithm is proposed in this thesis. Firstly, de-noising the selected signals, and the wavelet coefficients are used to select the wavelet threshold to eliminate the noise in the signal. Then the signal after the de-noising is analysed by the Nuttall window interpolate FFT algorithm, and the calculation formula is derived by using the amplitude information content of four spectral lines. The simulation results show that the proposed method is more accurate and effective to detect the signal after de-noising.


Introduction
With the interconnection of power systems becoming more and more complex, a large number of nonlinear loads cause the harmonic pollution serious and complex in the power grid. The control of harmonics is of great significance (Xiao, Mao, & Zhou, 2002). The signal in practical application has the complex characteristical. The interference of noise will bear the brunt and affect the further analysis of harmonic detection. Therefore, to eliminate noise and make harmonic detection stable fast as much as possible are of great significance for providing highquality power (Yuan, Ai, & Huang, 2011;Zheng, Yang, & Gao, 2006).
Threshold de-noising method is a common method for realizing simple and eliminating noise (Wu, Wang, & Bao, 2014;Zhong, Song, & You, 2014). There is a shortcoming between the discontinuity of the hard threshold and the constant deviation of soft threshold in the traditional wavelet threshold process (Sun, Pang, & Wang, 2016;Zhang, Liu, & Zhou, 2006). Therefore, we use the combination of the soft and the hard threshold method to overcome the drawbacks of the hard threshold and the soft threshold and remove low-amplitude noise from harmonic signals, this method amplifies the middle part of the signal which is easily confused and reduces the part that is not easily confused, therefore, we can easily recognize the noise.
CONTACT Chuanjiang Wang cxjwang@163.com This article has been republished with minor changes. These changes do not impact the academic content of the article.
The fast Fourier transform (FFT) is a typical power quality signal analysis method. The signal processed by window function can effectively compensate for the spectrum leakage (Zhang, He, & Zang, 2017) and the fence effect when the harmonic parameters are analysed (Chen, Chen, & Cai, 2011;Lan, Li, & Wang, 2009;Li, Li, & Yang, 2017;Zeng, Tang, & Qing, 2014). The double-spectrums interpolation algorithm and the threespectrum-line interpolation algorithm are widely used. The double-spectrum interpolation algorithm uses the two spectral lines near the peak spectral frequency to obtain the harmonic parameters by introducing the frequency offset, but the algorithm does not fully take advantage of the information of the leakage line near the frequency (Qing, Teng, & Gao, 2009). The three-spectrumline interpolation algorithm uses the three spectral lines near peak spectral frequency to improve the utilization of leakage information, but the algorithm does not consider the information contained in the left and right symmetric lines of the frequency point (Niu, Liang, & Zhang, 2012b;Cai, Zhang, & Lu, 2015). The Nuttall window interpolation FFT algorithm is used for analysis, and the correction formula is derived from the weighted operation of the four spectral lines, which effectively utilizes the spectrum information, suppresses sidelobe leakage, and reduces the error caused by the fence effect.

The principle and method of wavelet threshold
In wavelet analysis, the wavelet threshold de-noising method was proposed by Donohod et al. which is an effective de-noising method. After wavelet decomposing, the wavelet transform coefficient of the signal is larger than that of the noise, therefore, we should properly select the threshold T. The coefficient is caused by the noise mainly when it is less than T, then, set it as zero. when the wavelet coefficient is greater than T, we considered that the coefficient is caused by the signal mainly, and retained (hard threshold) directly or shrinks to zero according to a certain fixed amount (soft threshold), then reconstructing the signal by the new wavelet, and obtain a de-noised signal.
(1) Select the appropriate wavelet basis db20, determine the number of decomposition layers (4 layers), then wavelet-decompose the signal and obtain wavelet coefficients W j,k .
(2) Deal with the wavelet coefficients of the highfrequency part, and select the threshold λ = σ 2 log(N); N is the length of the wavelet coefficients; σ the standard deviation of the noise.
(3) Reconstruct the processed wavelet coefficients and obtain de-noised signals.
In the de-noising process, the selection and quantization of the threshold is the key. For the selection of the threshold, the soft and hard de-noising method is as shown as Where f is the frequency.
Since the threshold T is continuous, the disadvantage of discontinuity of the hard threshold function is overcome. Since the harmonic noise mainly exists at the high-frequency regions, the improved threshold function establishes an exponential relationship between noise and frequency to reduce the constant deviation of the soft threshold method to some certain extent.
We can reconstruct the processed wavelet coefficients to obtain the de-noised signal by using the threshold function combined with the soft and the hard threshold based on transform wavelet coefficients.

Analysis of algorithm based on window interpolation FFT algorithm
The Nuttall window function is actually a cosine combination window function, which has good side-lobe characteristics, and the general expression of the cosine window is shown as where M is the number of window function items; n = 0, 1, .., N − 1; when selecting M = 4 and the coefficient a m meets the following conditions: M−1 m=0 a m = 1, M−1 m=0 (−1) m a m = 0, in other words, a 0 = 10/32, a 1 = 15/32, a 2 = 6/32, a 3 = 1/32.
Firstly, when the single-frequency signal contained DC component and harmonic is sampled at a fixed frequency f s , we can obtain the discrete-time signals shown as where C, f 0 , ϕ are the amplitude, frequency and phase separately.
The signal x(n) is convoluted by window function w(n), and the continuous Fourier transform is expressed as The discrete spectrum x w (k f )of signal x(n) can be obtained by the FFT algorithm, which is the result of the equal intervals sample of the continuous spectrum function x w (f ) on the interval (−π , π) essentially. Therefore, the discrete spectrum expression of the function X w (n) with ignoring side-lobe effects at −f 0 , which is shown in Equation (5): where f = f s N , k = 0, 1 . . . .N − 1, N is the number of sampling points.
Since the non-synchronous or non-periodic signal needs to be sampled, the harmonic peak frequency f = k f is difficult to match the sampling frequency point exactly, in other words, k is not an integer. According to the relationship among the signal spectrums, we assume that the maximum and sub-maximum spectral lines nearby peak frequency point are k p , k p+1 , and two outer spectral lines are k p−1 , k p+2 , shown as Figure 1, and there exists k p−1 < k p < k < k p+1 < k p+2 , k p+2 = k p+1 + 1, k p = k p−1 + 1.
Where ε = k − k p − 0.5, which is in the range of (−0.5, 0.5). The corresponding value of the four-spectral-line is noted as y p−1 = |X(k p−1 f )|,y p = |X(k p f )|,y p+1 = |X(k p+1 f )|,y p+2 = |X(k p+2 f )|, then let β = (2y p+1 +y p+2 )−(2y p +y p−1 ) y p−1 +2y p +2y p+1 +y p+2 , R = 2y p+1 + y p+2 , S = 2y p + y p−1 , substituting ε into Equation (5), which can be obtained by as the inverse function of β, and the frequency correction equation is obtained, shown as The amount of information of each line is different, therefore, let the weight of four lines k p−1 ,k p ,k p+1 ,k p+2 are 1,2,2,1. The amplitude correction formula is shown as C = 2(y p−1 + 2y p + 2y p+1 + y p+2 ) S + R When N 1, equation (8) can be simplified to the following form: The initial phase correction equation is followed as The above equations are applied to the theoretical derivation, but in practical applications (Wen, Teng, & Wang, 2012), the correction formula can be written as We choose the Nuttall window function to deal with the FFT algorithm in this article, and bring its coefficient and parameter k = −α ± 1.5,−α ± 0.5 into equation (6), then results in W 2π(−ε±1.5) The calculation steps of Nuttall window are as follows: (1) Randomly take a value of α in the range of [−0.5, 0.5].
The correction formulas are shown as follows: When calculated the correction formula of the Nuttal window function interpolation FFT algorithm, we drew on the relationship between the phase of the derivation process of the double-spectrums interpolation algorithm and the three spectral lines interpolation algorithm (Niu, Liang, & Zhang, 2012a), and applied the fou-spectral-lines interpolation algorithm to it.

Verification analysis of the pretreatment of wavelet de-noising
In order to verify the effectiveness of the FFT algorithm based on wavelet threshold de-noising, we choose the electric frequency signal which has been given from the reference (Hao, Gu, & Chu, 2014), the signal fundamental frequency f 0 = 50.1 Hz, the sampling frequency f s = 5120 Hz, the number of sampling point N = 1024, and the amplitude and phase of each harmonics are shown in Table 1.
The harmonic signal contained noise is processed by the wavelet threshold de-noising algorithm, then we can obtain the reconstructed de-noised signal waveform (Figure 2).   From the above figures, we can intuitively see that the noise is well eliminated after the pretreatment of wavelet threshold. The waveform in the Figure 3 is only a good expression of the processed signal, which is a standard cosine wave approximately. The signal-to-noise ratio (SNR) and root mean square error (RMSE) shown as equation (14) and equation (15) are introduced to evaluate the de-noising performance.
Where x i is the sampling value. → x i is the reconstructed value, after noise reduction, the evaluation index of SNR and RMSE is 122 and 0.032.

FFT algorithm verification analysis
The de-noised signal is analysed by using the Nuttall window interpolation FFT algorithm and measurement results of the harmonics are shown in Tables 2 and 3.
The relative errors are shown in Figures 4 and 5. From the above figures, the amplitude and phase values of the harmonics obtained have high precision till to 10 −8 , the relative error of amplitude is less than 1 × 10 −7 0 / 0 , and the relative error of phase is less than 2 × 10 −7 0 / 0 . From the above two experimental results, the wavelet de-noising method combined with the soft and the hard threshold has a good time-frequency localization characteristic, and it can effectively eliminate the random noise in the signal. Compared with the FFT algorithm  without de-noising, the accuracy of the detected signal obtained by the method combines the wavelet threshold de-noising method with the FFT algorithm is higher and the relative error is smaller.

The effect of frequency fluctuation on the algorithm
Frequency fluctuation can cause the leakage to change, which causing the information of other lines around the   ±0.2 ∼ ±0.5 Hz. We assume the fundamental frequency fluctuates is range from 49.7 to 50.5 Hz, and use the FFT algorithm to analyse the signals. The absolute error of the fundamental frequency is less than 1 × 10 −7 Hz. The amplitude and phase relative errors after calculation are shown in Figures 6 and 7. The Figure shows that the obtained amplitude error is less than 5 × 10 −7 %, and the phase error is less than 2 × 10 −6 %. This algorithm can effectively overcome the influence of frequency fluctuation on harmonic analysis, and then the each harmonics' parameters can be accurately detected.

Conclusion
The FFT algorithm will inevitably cause the data deviation while it solves the amplitudes and phases of the harmonics signals with noise alone. This thesis proposes a harmonic detection method based on wavelet threshold and Nuttall window interpolate FFT algorithm, which can be used to detect the harmonics of signal. This method can eliminate the noise effectively, and improve the denoising effect. The FFT algorithm effectively utilizes the amplitude information between spectra-lines. The simulation analysis and comparison show that this algorithm can effectively remove noise interference and accurately detect the harmonics, meanwhile, which improve the stability of FFT algorithm in practical applications.