## 2 Principles of Improved Harmonic Detection Methods
### Comparison of Bartlett-Hann Windows and Common Windows  
In order to verify the advantages of the Bartlett-Hann window, and compared with several common windows, common window functions include rectangular windows, triangular windows, Hanning windows, and Blackman windows. Different window functions have different effects on the frequency spectrum. The main reason is that different window functions produce different frequency spectrum leaks and different frequency resolution capabilities. The use of the DFT algorithm to calculate the frequency spectrum has a fence effect [18]. Both of the above defects cannot be eliminated. In this paper, we can choose different window functions to suppress their effects. The spectral leakage is related to the side lobes on both sides of the window function spectrum. If the height of the side lobes on both sides approaches 0 and the energy is relatively concentrated in the main lobe, closer to the true spectrum can be obtained. For the selection of the window function, the maximum effect of maintaining the maximum information and eliminating the side lobe should be to make the width of the main lobe in the window function spectrum as narrow as possible and the side lobe attenuation as large as possible [19]. The spectral comparison of Bartlett-Hann window and several common windows is shown in Figure 2.  
It can be seen from the figure that the main lobe of the rectangular window is the most concentrated, but has the largest side lobe peak, and the side lobe attenuation speed is slow, the frequency recognition accuracy is high, and the amplitude recognition accuracy is low. The width of the main lobe of a triangular window is large, about twice that of a rectangular window, and the side lobes are small. The side lobe decays faster than a rectangular window. The width of the main lobe of a Hamming window is similar to that of a triangular window, but the side lobes are smaller and the side fading speed is fast. Both the Hamming window and the Hanning window are cosine windows. The Hamming window is an improved raised cosine window. The width of the main lobe is similar to that of the Hamming window. The decay speed is not as fast as the Hamming window. The main lobe width of the Blackman window is the largest of these common window functions, the side lobe is the smallest, and the side lobe decay rate is the fastest. Based on the comprehensive effect of windowing, the ratio of the Bartlett-Hann window to the rectangular window, Bartlett window, and Hanning window has the maximum side lobe minimum, and the maximum side lobe is \(-36\) dB; compared with Bartlett and Hamming, the Bartlett-Hann window decays faster at farther side; Blackman has the widest main lobe. Although the side lobe decays fastest, its calculation is too large. In general, Bartlett-Hann windows have excellent performance in many aspects and are suitable for window interpolation DFT algorithms. ### Comparison of Bartlett-Hann Windows and Common Windows  
According to the actual situation of the power grid, the ideal fundamental frequency is 50 Hz, and the maximum amplitude of the fundamental wave is 1. According to the literature [20], a list of some harmonic parameters of the grid except the fundamental wave is shown in Table 1.  
Figure 2: Bartlett–Hann window spectrum comparison with several common windows. According to Table 1, select the length of the sampling window in twelve signal cycles, set the number of sampling points to 1024, the sampling frequency to 2000 Hz, and the standard grid frequency of 50 Hz as the standard. A comparison has been made between the ordinary DFT algorithm and the interpolation DFT algorithm of Bartlett-Hann window function. The method of calculating relative error is used to reflect the deviation of the measured data from the actual value of the two methods, reflecting the credibility of the method. The calculation formula of absolute error and relative error is as follows:  
\[\left\{ \begin{array}{l}\Delta=\alpha-\beta\\ \delta=\Delta/\beta\ast 100\%\end{array} \right.