Harmonic extraction method based on SG filtering algorithm and terminal
By applying the SG filtering algorithm in harmonic extraction and using convolution to calculate the fit coefficient, the problems of large calculation amount and low efficiency in the existing technology are solved, and efficient harmonic extraction is achieved, which is suitable for a variety of system environments.
Patent Information
- Application Number
- CN202411634672.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-15
- Publication Date
- 2025-04-04
AI Technical Summary
The prior art has a large amount of calculation and low efficiency in harmonic extraction, making it difficult to effectively extract harmonics when the system resources are limited.
Using a method based on SG filtering algorithm, the park rotation transformation of three-phase power data is performed, and harmonics are filtered out using SG filters, and harmonics are extracted through comparison. The fit coefficients in the SG filter are calculated by convolution, reducing the amount of calculation.
It improves the efficiency of harmonic extraction, reduces the amount of calculation, and does not require a large amount of data memory. It is suitable for three-phase balanced and unbalanced systems, improving system operation efficiency.
Smart Images

Figure CN119760389A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of harmonic extraction, and in particular to a harmonic extraction method and a terminal based on an SG filtering algorithm. Background Art
[0002] Harmonics refer to components in current or voltage waveforms whose frequencies are integer multiples of the fundamental wave, which are mainly caused by nonlinear loads (such as rectifiers, inverters, and lighting equipment). The presence of harmonics not only affects the operating efficiency of the power system, but may also damage the equipment and increase power loss. Therefore, accurate and effective harmonic extraction is an important part of power quality analysis and management. Harmonic extraction technology has been applied in many fields of power electronics and power systems. For example, in power system monitoring, it is necessary to monitor harmonics in the power grid in real time to protect equipment and reduce losses; monitor harmonics during motor startup and operation to achieve performance optimization and loss reduction; in industrial load management, it is necessary to extract harmonics to evaluate and optimize the impact of nonlinear loads on the power system and improve the efficiency of power use.
[0003] Generally speaking, the existing harmonic extraction methods can be mainly divided into time domain methods and frequency domain methods. The time domain harmonic extraction method mainly includes the active current detection method based on Fryze time domain analysis and the extraction method based on instantaneous reactive power theory. The former realizes the extraction of harmonics by separating the fundamental active component and the generalized reactive component, but this method is sensitive to the grid voltage and is therefore not suitable for application in practical engineering. The latter is a fast harmonic extraction method that uses coordinate transformation to separate the fundamental and harmonics using a low-pass filter (LPF) in a synchronous or stationary coordinate system, thereby realizing the extraction of harmonics. However, this algorithm is mainly applicable to balanced three-phase systems, and due to the introduction of a low-pass filter, the separation process of the fundamental and harmonics inevitably causes a certain delay, and the delay time depends on the performance of the low-pass filter. The frequency domain harmonic extraction algorithm is mainly based on Fourier analysis, generally including fast Fourier transform (FFT), discrete Fourier transform (DFT) and sliding window iterative Fourier transform (SDFT). The frequency analysis method requires a large amount of data memory, and when system resources are limited, the frequency method is limited.
[0004] In addition, with the emergence of artificial intelligence algorithms, new harmonic detection methods such as wavelet transform, Kalman filtering, adaptive filtering, and neural network-based methods have been provided. However, these algorithms are more complex and require more computation and higher hardware performance, so they are rarely used in actual engineering. Summary of the invention
[0005] The technical problem to be solved by the present invention is to provide a harmonic extraction method and terminal based on the SG filtering algorithm, reduce the calculation amount of the filtering algorithm, and improve the efficiency of harmonic extraction.
[0006] In order to solve the above technical problems, the technical solution adopted by the present invention is:
[0007] A harmonic extraction method based on SG filtering algorithm comprises the steps of:
[0008] S1. Acquire three-phase power data, and obtain first power data components of d-axis and q-axis through park rotation transformation, wherein the three-phase power data is three-phase voltage or three-phase load current;
[0009] S2. Filtering the first power data component through an SG filter to obtain a second power data component without harmonic components, wherein the fitting coefficient in the SG filter is calculated by convolution;
[0010] S3. Compare the first power data component and the second power data component to extract harmonics in the first power data component.
[0011] In order to solve the above technical problems, the technical solution adopted by the present invention is:
[0012] A harmonic extraction terminal based on an SG filtering algorithm comprises a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:
[0013] S1. Acquire three-phase power data, and obtain first power data components of d-axis and q-axis through park rotation transformation, wherein the three-phase power data is three-phase voltage or three-phase load current;
[0014] S2. Filtering the first power data component through an SG filter to obtain a second power data component without harmonic components, wherein the fitting coefficient in the SG filter is calculated by convolution;
[0015] S3. Compare the first power data component and the second power data component to extract harmonics in the first power data component.
[0016] The beneficial effects of the present invention are as follows: a harmonic extraction method and terminal based on the SG filtering algorithm of the present invention applies the SG filtering algorithm to harmonic extraction, converts the three-phase power data to the d and q axes, filters out the harmonics therein through the SG filter, and then compares it with the unfiltered data, thereby extracting the harmonics in the filtered data. For the frequency domain harmonic extraction algorithm, the scope of use is wider, not only can the harmonics in the three-phase balanced system be extracted, but also can be used in the three-phase unbalanced system, and the use of the SG filtering algorithm to extract harmonics can reduce the amount of calculation of harmonic extraction, and does not need to occupy a large amount of data memory. In the case of limited system resources, the SG filtering algorithm can improve the efficiency of system operation, and the fitting coefficients in the SG filter are calculated by convolution, which greatly reduces the amount of calculation of the filtering algorithm and further improves the efficiency of harmonic extraction. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 Flow chart of a harmonic extraction method based on SG filtering algorithm according to an embodiment of the present invention;
[0018] Figure 2 A structural diagram of a harmonic extraction terminal based on an SG filtering algorithm according to an embodiment of the present invention;
[0019] Figure 3 The main circuit topology of the three-phase grid-connected inverter according to the embodiment of the present invention;
[0020] Figure 4 This is an equivalent control block diagram of d-axis and q-axis voltage harmonic extraction based on SG filtering algorithm according to an embodiment of the present invention;
[0021] Figure 5 This is an equivalent control block diagram of d-axis and q-axis current harmonic extraction based on SG filtering algorithm according to an embodiment of the present invention;
[0022] Figure 6 The waveform diagram of the three-phase voltages A, B and C after superimposing harmonics in the embodiment of the present invention;
[0023] Figure 7 The waveform diagram of the d-axis and q-axis voltage components without SG filtering in the embodiment of the present invention;
[0024] Figure 8 It is a partial enlarged diagram of the waveform diagram of the d-axis and q-axis voltage components without SG filtering in the embodiment of the present invention;
[0025] Fig. 9 This is a waveform diagram of the voltage component on the d-axis when the SG filtering algorithm is introduced in the embodiment of the present invention;
[0026] Fig.10 It is a partial enlarged diagram of the voltage component related waveform diagram on the d-axis when the SG filtering algorithm is introduced in the embodiment of the present invention;
[0027] Fig.11 This is a waveform diagram of the voltage component on the q axis when the SG filtering algorithm is introduced in an embodiment of the present invention;
[0028] Fig.12 It is a partial enlarged diagram of the voltage component related waveform diagram on the q-axis when the SG filtering algorithm is introduced in the embodiment of the present invention;
[0029] Fig.13 It is a three-phase waveform diagram after the d-axis and q-axis harmonic components are reversed by Park in an embodiment of the present invention;
[0030] Fig.14 is a waveform diagram of the voltage at the common coupling point after compensation using the extracted harmonics in an embodiment of the present invention;
[0031] Fig.15 The waveform diagram of the d-axis and q-axis current components of the grid-connected current in the embodiment of the present invention;
[0032] Fig.16 It is a partial enlarged diagram of the waveform diagram of the d-axis and q-axis current components of the grid-connected current in the embodiment of the present invention;
[0033] Fig.17 The waveform diagram of the d-axis and q-axis current components after SG filtering in the embodiment of the present invention;
[0034] Fig.18 The d-axis and q-axis harmonic component wave diagram of the grid-connected current in the embodiment of the present invention;
[0035] Fig.19 It is a partial enlarged diagram of the harmonic component wave diagram of the d-axis and q-axis currents of the grid-connected current in the embodiment of the present invention;
[0036] Fig. 20 A schematic diagram of three-phase current harmonics of A, B, and C in an embodiment of the present invention;
[0037] Fig.21 A phase current related waveform diagram in an embodiment of the present invention;
[0038] Description of labels:
[0039] 1. A harmonic extraction terminal based on SG filtering algorithm; 2. A processor; 3. A memory. DETAILED DESCRIPTION
[0040] In order to explain the technical content, achieved objectives and effects of the present invention in detail, the following is an explanation in combination with the implementation modes and the accompanying drawings.
[0041] d, q axis: the direct axis (d axis) and the cross axis (q axis) in the rotating coordinate system.
[0042] Park rotation transformation: A mathematical transformation method used to convert a three-phase stationary coordinate system (abc) into a rotating coordinate system (dq).
[0043] Please refer to Figure 1 as well as Figure 2 , a harmonic extraction method based on SG filtering algorithm, comprising the steps of:
[0044] S1. Acquire three-phase power data, and obtain first power data components of d-axis and q-axis through park rotation transformation, wherein the three-phase power data is three-phase voltage or three-phase load current;
[0045] S2. Filtering the first power data component through an SG filter to obtain a second power data component without harmonic components, wherein the fitting coefficient in the SG filter is calculated by convolution;
[0046] S3. Compare the first power data component and the second power data component to extract harmonics in the first power data component.
[0047] From the above description, it can be seen that the beneficial effects of the present invention are: a harmonic extraction method based on the SG filtering algorithm of the present invention applies the SG filtering algorithm to harmonic extraction, converts the three-phase power data to the d and q axes, and filters out the harmonics therein through the SG filter, and then compares it with the unfiltered data to extract the harmonics in the filtered data. For the frequency domain harmonic extraction algorithm, the scope of use is wider, not only can the harmonics in the three-phase balanced system be extracted, but also can be used in the three-phase unbalanced system, and the use of the SG filtering algorithm to extract harmonics can reduce the amount of calculation of harmonic extraction, and does not need to occupy a large amount of data memory. In the case of limited system resources, the SG filtering algorithm can improve the efficiency of system operation, and the fitting coefficients in the SG filter are calculated by convolution, which greatly reduces the amount of calculation of the filtering algorithm and further improves the efficiency of harmonic extraction.
[0048] Furthermore, the calculation of the fitting coefficient by convolution in the SG filter includes:
[0049] S21. For the time series signal y(n), the window width of the sliding window for signal filtering is set to 2M+1, and the data in the window is recorded as x[i], i∈[-M,M];
[0050] S22. Use an N-order polynomial to fit the data in the window, and express the polynomial as:
[0051]
[0052] In the formula, p[i] represents the fitting result, i∈[-M,M], ck represents the fitting coefficient, k∈[0,N];
[0053] S23, taking multiple-order derivatives of the polynomial at i=0, we have:
[0054]
[0055] S24, convolve the time series signal with the unit impulse response of the filter to obtain the output:
[0056]
[0057] Then the fitting coefficients are obtained.
[0058] From the above description, it can be seen that according to the formula of step S23, the process of calculating the fitting coefficient is equivalent to FIR filtering of the original data, which means that the output can be obtained by convolving the input signal with the unit impulse response of the filter. This method uses the convolution method to calculate the fitting coefficient of the SG filter, which greatly reduces the calculation amount of the filtering algorithm and improves the efficiency of the control algorithm.
[0059] Furthermore, before step S23, the following steps are also included:
[0060] S221, judging N and M, if N or M is greater than the corresponding set threshold, then entering step S23, otherwise the fitting coefficient is calculated by matrix solution.
[0061] From the above description, it can be seen that when the fitting order is not high and the window is small, the matrix solving method can be used to calculate the auxiliary matrix and make an auxiliary matrix parameter table. The fitting result can be obtained by simply querying the auxiliary matrix parameters that do not need to be updated in real time through the table lookup method. When the fitting order is high or the window is large, in order to avoid occupying a large data storage space to store the auxiliary matrix parameters, the fitting coefficients are calculated by convolution.
[0062] Furthermore, the calculation of the fitting coefficients by matrix solution includes the following steps:
[0063] The residual sum of squares between the fitting results and the original data is expressed as:
[0064]
[0065] The residual sum of squares E is calculated by comparing the fitting coefficient c k Find the partial derivative. When the partial derivative is 0, the fitting effect is the best. The result is expressed as:
[0066]
[0067] r∈[0,N];
[0068] Among them, c r represents the rth fitting coefficient;
[0069] Further simplification gives:
[0070]
[0071] It can be seen that when the window size M, the fitting order N and x[i] are known, the corresponding fitting coefficient c can be solved k , introduce the matrix to solve the calculation:
[0072] Will It can be represented by a matrix with (2M+1) rows and (N+1) columns:
[0073]
[0074] Then there is A={a[i][r]}, where a[i][r]=i r , i∈[-M,M], r∈[0,N];
[0075] Set up matrix B = A T A, then:
[0076] B = {b[k][r]};
[0077] in:
[0078]
[0079] Will Expressed as matrix X:
[0080] X=[x[-M]…x[M]] T ;
[0081] Will Expressed in matrix C:
[0082] C=[c[0]…c[N]] T ;
[0083] Combining the above formulas, we can get:
[0084] BC=A T AC=A T X;
[0085] The fitting coefficient matrix is expressed as:
[0086] C=(A T A) -1 A T X;
[0087] The polynomial of the fitting result is expressed in matrix as:
[0088] P=AC=A(A T A) -1 A T X=EX.
[0089] It can be seen from the above description that through the above steps, the fitting coefficients are calculated by using a matrix solution method.
[0090] Furthermore, the method further comprises the steps of:
[0091] S4. Perform inverse park processing on the harmonics in the first power data component to obtain harmonics in a three-phase coordinate system.
[0092] From the above description, it can be known that the harmonics in the three-phase coordinate system can be obtained by performing inverse park processing on the obtained d- and q-axis forms of the harmonics.
[0093] Please refer to Figure 2 , a harmonic extraction terminal based on SG filtering algorithm, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:
[0094] S1. Acquire three-phase power data, and obtain first power data components of d-axis and q-axis through park rotation transformation, wherein the three-phase power data is three-phase voltage or three-phase load current;
[0095] S2. Filtering the first power data component through an SG filter to obtain a second power data component without harmonic components, wherein the fitting coefficient in the SG filter is calculated by convolution;
[0096] S3. Compare the first power data component and the second power data component to extract harmonics in the first power data component.
[0097] From the above description, it can be seen that the beneficial effects of the present invention are: a harmonic extraction method based on the SG filtering algorithm of the present invention applies the SG filtering algorithm to harmonic extraction, converts the three-phase power data to the d and q axes, and filters out the harmonics therein through the SG filter, and then compares it with the unfiltered data to extract the harmonics in the filtered data. For the frequency domain harmonic extraction algorithm, the scope of use is wider, not only can the harmonics in the three-phase balanced system be extracted, but also can be used in the three-phase unbalanced system, and the use of the SG filtering algorithm to extract harmonics can reduce the amount of calculation of harmonic extraction, and does not need to occupy a large amount of data memory. In the case of limited system resources, the SG filtering algorithm can improve the efficiency of system operation, and the fitting coefficients in the SG filter are calculated by convolution, which greatly reduces the amount of calculation of the filtering algorithm and further improves the efficiency of harmonic extraction.
[0098] Furthermore, the calculation of the fitting coefficient by convolution in the SG filter includes:
[0099] S21. For the time series signal y(n), the window width of the sliding window for signal filtering is set to 2M+1, and the data in the window is recorded as x[i], i∈[-M,M];
[0100] S22. Use an N-order polynomial to fit the data in the window, and express the polynomial as:
[0101]
[0102] In the formula, p[i] represents the fitting result, i∈[-M,M], c k represents the fitting coefficient, k∈[0,N];
[0103] S23, taking multiple-order derivatives of the polynomial at i=0, we have:
[0104]
[0105] S24, convolve the time series signal with the unit impulse response of the filter to obtain the output:
[0106]
[0107] Then the fitting coefficients are obtained.
[0108] From the above description, it can be seen that according to the formula of step S23, the process of calculating the fitting coefficient is equivalent to FIR filtering of the original data, which means that the output can be obtained by convolving the input signal with the unit impulse response of the filter. This method uses the convolution method to calculate the fitting coefficient of the SG filter, which greatly reduces the calculation amount of the filtering algorithm and improves the efficiency of the control algorithm.
[0109] Furthermore, before step S23, the following steps are also included:
[0110] S221, judging N and M, if N or M is greater than the corresponding set threshold, then entering step S23, otherwise the fitting coefficient is calculated by matrix solution.
[0111] From the above description, it can be seen that when the fitting order is not high and the window is small, the matrix solving method can be used to calculate the auxiliary matrix and make an auxiliary matrix parameter table. The fitting result can be obtained by simply querying the auxiliary matrix parameters that do not need to be updated in real time through the table lookup method. When the fitting order is high or the window is large, in order to avoid occupying a large data storage space to store the auxiliary matrix parameters, the fitting coefficients are calculated by convolution.
[0112] Furthermore, the calculation of the fitting coefficients by matrix solution includes the following steps:
[0113] The residual sum of squares between the fitting results and the original data is expressed as:
[0114]
[0115] The residual sum of squares E is calculated by comparing the fitting coefficient c k Find the partial derivative. When the partial derivative is 0, the fitting effect is the best. The result is expressed as:
[0116]
[0117] Among them, c r represents the rth fitting coefficient;
[0118] Further simplification gives:
[0119]
[0120] It can be seen that when the window size M, the fitting order N and x[i] are known, the corresponding fitting coefficient c can be solved k , introduce the matrix to solve the calculation:
[0121] Will It can be represented by a matrix with (2M+1) rows and (N+1) columns:
[0122]
[0123] Then there is A={a[i][r]}, where a[i][r]=i r , i∈[-M,M], r∈[0,N];
[0124] Set up matrix B = A T A, then:
[0125] B = {b[k][r]};
[0126] in:
[0127]
[0128] Will Expressed as matrix X:
[0129] X=[x[-M]…x[M]] T ;
[0130] Will Expressed in matrix C:
[0131] C=[c[0]…c[N]] T ;
[0132] Combining the above formulas, we can get:
[0133] BC=A T AC=A T X;
[0134] The fitting coefficient matrix is expressed as:
[0135] C=(A T A) -1 A T X;
[0136] The polynomial of the fitting result is expressed in matrix as:
[0137] P=AC=A(A T A) -1 A T X=EX.
[0138] It can be seen from the above description that through the above steps, the fitting coefficients are calculated by using a matrix solution method.
[0139] Furthermore, the method further comprises the steps of:
[0140] S4. Perform inverse park processing on the harmonics in the first power data component to obtain harmonics in a three-phase coordinate system.
[0141] From the above description, it can be known that the harmonics in the three-phase coordinate system can be obtained by performing inverse park processing on the obtained d- and q-axis forms of the harmonics.
[0142] The present invention discloses a harmonic extraction method and terminal based on SG filtering algorithm, which are applicable to harmonic extraction of three-phase system, and are applicable to three-phase balanced system as well as three-phase unbalanced system.
[0143] Please refer to Figure 1 as well as Figures 3 to 5 , Embodiment 1 of the present invention is:
[0144] A harmonic extraction method based on SG filtering algorithm comprises the steps of:
[0145] S1. Acquire three-phase power data, and obtain first power data components of d-axis and q-axis through park rotation transformation, wherein the three-phase power data is three-phase voltage or three-phase load current.
[0146] In this embodiment, a three-phase system is taken as an example. Figure 3 This is the main circuit topology diagram of the three-phase grid-connected inverter of the three-phase system.
[0147] V dc , C dc The DC bus voltage, DC bus capacitance, inverter side inductor L1, filter capacitor C, grid side inductor L2 constitute the LCL filter, L g is the parasitic inductance on the grid side, v pcc is the coupling point voltage, θ' is the real-time phase angle of the power grid. The power grid contains background harmonics.
[0148] The three-phase voltage and three-phase load current of the three-phase system are respectively taken as examples for explanation.
[0149] Three-phase voltage:
[0150] Please refer to Figure 4 The voltage harmonic extraction equivalent control block diagram shown in the figure, the common coupling point voltage v pcc The three-phase voltages va, vb, and vc at the location are transformed by Park rotation to obtain the d-axis and q-axis voltage components vd of the grid voltage. real 、vq real .
[0151] Three-phase load current:
[0152] Please refer to Figure 5 The current harmonic extraction equivalent control block diagram shown in the figure, ia, ib, ic are the three-phase load currents, and the current d-axis and q-axis components id are obtained after Park rotation transformation. real 、iq real .
[0153] S2. Filter the first power data component through an SG filter to obtain a second power data component without harmonic components, wherein the fitting coefficient in the SG filter is calculated by convolution.
[0154] Three-phase voltage:
[0155] In this embodiment, since the three-phase power grid contains background harmonics, vd real 、vq realContains harmonics, so the d-axis and q-axis voltage components vd real 、vq real After the SG filtering algorithm, vd is obtained sg 、vq sg .
[0156] Three-phase load current:
[0157] In the embodiment, the current d and q axis components id real 、iq real , after the calculation link in the SG filtering algorithm, the id without harmonic components can be obtained sg 、iq sg.
[0158] S3. Compare the first power data component and the second power data component to extract harmonics in the first power data component.
[0159] Three-phase voltage:
[0160] Using vd real 、vq real With vd sg 、vq sg By comparison, the harmonics contained in the d-axis and q-axis voltage components can be extracted. The extracted harmonics are vd th 、vq th .
[0161] Three-phase load current:
[0162] Utilize id real 、iq real Subtract the respective id sg 、iq sg. After that, the harmonic id in the d and q axis current components can be obtained. th 、iq th .
[0163] S4. Perform inverse park processing on the harmonics in the first power data component to obtain harmonics in a three-phase coordinate system.
[0164] Three-phase voltage:
[0165] In this embodiment, vd th 、vq th After the inverse Park transformation, the three-phase current harmonics va can be obtained th 、vb th 、vc th .
[0166] Three-phase load current:
[0167] In this embodiment, idth 、iq th After the inverse Park transformation, the three-phase current harmonics ia can be obtained th ib th ,ic th .
[0168] Taking the three-phase load current as an example, the three-phase current harmonic ia is obtained. th ib th ,ic th Then, using the three-phase current harmonics ia th ib th ,ic th By performing harmonic compensation on the three-phase load currents ia, ib, and ic respectively, a three-phase current without harmonic components can be obtained.
[0169] Embodiment 2 of the present invention is:
[0170] A harmonic extraction method based on an SG filtering algorithm. In this embodiment, the construction of the SG filter is specifically described.
[0171] In this embodiment, calculating the fitting coefficient by convolution in the SG filter includes:
[0172] S21. For the time series signal y(n), the window width of the sliding window for signal filtering is set to 2M+1, and the data in the window is recorded as x[i], i∈[-M,M];
[0173] S22. Use an N-order polynomial to fit the data in the window, and express the polynomial as:
[0174]
[0175] In the formula, p[i] represents the fitting result, i∈[-M,M], c k represents the fitting coefficient, k∈[0,N];
[0176] Therefore, 2M+1 equations are constructed to solve N+1 coefficients. In order for the system of equations to have a solution, N≤2M must be satisfied.
[0177] S23, taking multiple-order derivatives of the polynomial at i=0, we have:
[0178]
[0179] In this embodiment, it can be seen from the above formula that the process of calculating the fitting coefficient is equivalent to performing FIR filtering on the original data, which means that the output can be obtained by convolving the input with the unit impulse response of the filter.
[0180] S24, convolve the time series signal with the unit impulse response of the filter to obtain the output:
[0181]
[0182] Then the fitting coefficients are obtained.
[0183] According to this characteristic of SG, the convolution coefficient table can be calculated more quickly to obtain the pseudo coefficients. The fitting coefficients of the Savitzky-Golay filter (i.e., the coefficients of the polynomial) are based on the relative position of the points in the window and the selected polynomial order, and have nothing to do with the specific original data values. These coefficients are designed to smooth and calculate derivatives of data within a given window. In other words, the calculation of the coefficients depends on the window size and the polynomial order, not the data values within the window themselves. This allows the Savitzky-Golay filter to be effectively applied to a variety of data sets, resulting in consistent smoothing and derivative results.
[0184] The parameters M (window size) and N (polynomial order) in the Savitzky-Golay (SG) filter have a significant impact on smoothness and distortion. Using a larger window can effectively smooth the data and reduce high-frequency noise, but it may cause loss of signal details and increase hysteresis effects; a smaller window can better preserve signal details, but may not effectively suppress noise, resulting in poor smoothing effects. A higher polynomial order can better fit complex signals, but may introduce overfitting, which will deteriorate the smoothing effect and cause oscillations; a lower order is usually more stable and suitable for simple trends, but may not capture all features when faced with complex signals. As mentioned in the review, increasing the window size or reducing the polynomial order usually improves smoothness, while a window that is too large or a polynomial order that is too high may cause signal distortion and loss of important information. Therefore, choosing the right M and N requires a trade-off based on the specific application and data characteristics.
[0185] Embodiment 3 of the present invention is:
[0186] A harmonic extraction method based on an SG filtering algorithm. In this embodiment, the construction of the SG filter is specifically described.
[0187] In this embodiment, calculating the fitting coefficient by convolution in the SG filter includes:
[0188] S21. For the time series signal y(n), the window width of the sliding window for signal filtering is set to 2M+1, and the data in the window is recorded as x[i], i∈[-M,M];
[0189] S22. Use an N-order polynomial to fit the data in the window, and express the polynomial as:
[0190]
[0191] In the formula, p[i] represents the fitting result, i∈[-M,M], c k Represents the fitting coefficient, k∈[0,N].
[0192] The difference from the second embodiment is that, in this embodiment, before step S23, the following steps are further included:
[0193] S221, judging N and M, if N or M is greater than the corresponding set threshold, then entering step S23, otherwise the fitting coefficient is calculated by matrix solution.
[0194] In this embodiment, when the order of fitting is not high and the window is small, the auxiliary matrix can be calculated by matrix solving and the auxiliary matrix parameter table can be prepared. When M and N are large, a large data storage space is required to store the auxiliary matrix parameters. In order to improve the efficiency of the SG filtering algorithm when M and N are large, the fitting coefficients are calculated by the convolution method in the second embodiment.
[0195] This embodiment mainly describes how to calculate the fitting coefficients by using a matrix solution method.
[0196] The calculation of the fitting coefficients using matrix solution includes the following steps:
[0197] The residual sum of squares between the fitting results and the original data is expressed as:
[0198]
[0199] Since the SG filter is fitted by the least squares method, the fitting result is optimal when the residual sum of squares is minimized.
[0200] The residual sum of squares E is calculated by comparing the fitting coefficient c k Find the partial derivative. When the partial derivative is 0, the fitting effect is the best. The result is expressed as:
[0201]
[0202] r∈[0,N];
[0203] Among them, c r represents the rth fitting coefficient;
[0204] Further simplification gives:
[0205]
[0206] It can be seen that when the window size M, the fitting order N and x[i] are known, the corresponding fitting coefficient c can be solvedk , introduce the matrix to solve the calculation:
[0207] Will It can be represented by a matrix with (2M+1) rows and (N+1) columns:
[0208]
[0209] Then there is A={a[i][r]}, where a[i][r]=i r , i∈[-M,M], r∈[0,N];
[0210] Set up matrix B = A T A, then:
[0211] B = {b[k][r]};
[0212] in:
[0213]
[0214] Will Expressed as matrix X:
[0215] X=[x[-M]…x[M]] T ;
[0216] Will Expressed in matrix C:
[0217] C=[c[0]…c[N]] T ;
[0218] Combining the above formulas, we can get:
[0219] BC=A T AC=A T X;
[0220] The fitting coefficient matrix is expressed as:
[0221] C=(A T A) -1 A T X;
[0222] The polynomial of the fitting result is expressed in matrix as:
[0223] P=AC=A(A T A) -1 A T X = EX;
[0224] Among them, E is the auxiliary matrix.
[0225] The center value p[0] of the window P is selected as the filtering result.
[0226] It can be seen from the above formula that the auxiliary matrix has nothing to do with the data to be filtered, and the auxiliary matrix parameters are determined by M and N. Therefore, the auxiliary matrix of the SG filtering algorithm is determined. Therefore, the introduction of the SG filtering algorithm can avoid the real-time calculation of the fitting coefficients. It only needs to query the auxiliary matrix parameters that do not need to be updated in real time through the table lookup method to obtain the fitting results. This greatly reduces the amount of calculation of the algorithm, thereby improving the operating efficiency of the entire control algorithm.
[0227] Please refer to Figures 6 to 21 , Embodiment 4 of the present invention is:
[0228] A harmonic extraction method based on the SG filtering algorithm is different from the third embodiment in that, in this embodiment, a hardware platform is built using RT-Box1 and TI LaunchPad XL-F28069M for experiments.
[0229] The following Table 1 shows the three-phase grid parameters in the experiment and the values of M and N involved in the Savitzky Golay algorithm. The sampling frequency of the entire system is 10kHz.
[0230] Table 1
[0231] type Parameters (valid values) type parameter Grid voltage 110V SGFilter window size M 5 Grid frequency 50Hz SGFilter order N 3 Harmonic Amplitude 5V Harmonic frequency 450Hz
[0232] Please refer to Figure 6 , is the voltage of 110V, the fundamental frequency of 50Hz, superimposed with the harmonics of frequency 450Hz, phases of 0, -120°, 120° respectively, A, B, C three-phase voltage waveform. Since the fundamental frequency of the power grid is 50Hz, the condition under v pcc After the voltage at is Park transformed, harmonics with a frequency of 400 Hz will exist on the d and q axes.
[0233] Figure 7 is the dq axis voltage component vd without SG filtering real 、vq real Waveform, it can be clearly seen that vd real 、vq real Due to the harmonic components. real 、vq real After zooming in locally, Figure 8 As shown, it can be found that vd real 、vq real There is a fluctuation with a period of about 2.5ms, that is, a harmonic interference with a frequency of 400Hz, which is consistent with the harmonic frequency existing on the d and q axes in the theoretical analysis.
[0234] like Fig. 9 As shown in the figure, after the harmonic extraction link based on the SG filtering algorithm is introduced, the original voltage component vd on the d-axisreal Decomposed into vd sg With vd th Two parts, which do not contain the harmonic components of vd sg It can be used for feedforward control and other links, and there are also harmonic components of vd th It can be used in the compensation link. Fig. 9 After local magnification, Fig.10 It can be seen that vd th The frequency is 400Hz, and vd sg It is a smooth waveform, so it can be considered that vd real Total harmonics vd th The same method can be used to extract the harmonic component of the q axis. The waveform is as follows: Fig.11 and Fig.12 shown.
[0235] Fig.13 To extract the voltage harmonic components vd on the d and q axes th 、vq th Three-phase harmonic voltage waveform after inverse Park transformation.
[0236] Fig.14 The extracted d and q axis harmonic components vd th 、vq th After the compensation link is introduced, the waveform of the common coupling point. After the harmonic compensation is introduced at time t0, the common voltage waveform is significantly improved. The introduced harmonics can offset the background harmonics, making the voltage waveform closer to a sine wave. Therefore, the extracted harmonic vd th 、vq th Be reliable.
[0237] Fig.15 are the d and q axis current components of the three-phase load current after Park transformation, Fig.16 This is a partial enlarged view. Fig.15 It can be seen that there are 100Hz harmonics on the dq axis current components after stabilization. real 、iq real The id after SG filtering sg 、iq sg Waveform Fig.17 As shown, the d-axis and q-axis current component waveforms after filtering no longer have 100 Hz harmonics.
[0238] Fig.18 The d and q axis current harmonic waveforms are obtained by extracting the d and q axis current components using the SG filtering algorithm. Fig.19The extracted harmonics include a low-frequency harmonic component, and from the enlarged view, it can be seen that the harmonic component also contains a 100Hz harmonic.
[0239] Fig. 20 It is the three-phase current harmonic obtained by inverse Park transformation of the d and q axis current harmonic components. Fig.21 The current waveform of phase A without harmonic compensation and the current waveform after harmonic extraction and compensation using the SG filtering algorithm. The experimental results show that for three-phase current, the SG filtering algorithm can effectively extract the harmonic components in the current.
[0240] Please refer to Figure 2 , Embodiment 5 of the present invention is:
[0241] A harmonic extraction terminal 1 based on an SG filtering algorithm comprises a processor 2, a memory 3, and a computer program stored in the memory 3 and executable on the processor 2. When the processor 2 executes the computer program, the steps of a harmonic extraction method based on an SG filtering algorithm described in any one of embodiments 1 to 4 above are implemented.
[0242] In summary, the present invention provides a harmonic extraction method and terminal based on the SG filtering algorithm, which applies the SG filtering algorithm to harmonic extraction, converts the three-phase power data to the d and q axes, filters out the harmonics therein through the SG filter, and then compares them with the unfiltered data to extract the harmonics in the filtered data. For the frequency domain harmonic extraction algorithm, the scope of use is wider, not only can the harmonics in the three-phase balanced system be extracted, but also can be used in the three-phase unbalanced system, and the use of the SG filtering algorithm to extract harmonics can reduce the amount of calculation of harmonic extraction, and does not need to occupy a large amount of data memory. In the case of limited system resources, the SG filtering algorithm can improve the efficiency of system operation, and the fitting coefficients in the SG filter are calculated by convolution, which greatly reduces the amount of calculation of the filtering algorithm and further improves the efficiency of harmonic extraction.
[0243] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent transformations made using the contents of the present invention's specification and drawings, or directly or indirectly applied in related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A harmonic extraction method based on SG filtering algorithm, characterized in that: Includes steps: S1. Acquire three-phase power data, and obtain first power data components of d-axis and q-axis through park rotation transformation, wherein the three-phase power data is three-phase voltage or three-phase load current; S2. Filtering the first power data component through an SG filter to obtain a second power data component without harmonic components, wherein the fitting coefficient in the SG filter is calculated by convolution; S3. Compare the first power data component and the second power data component to extract harmonics in the first power data component.
2. The harmonic extraction method based on the SG filtering algorithm according to claim 1 is characterized in that: The calculation of the fitting coefficients by convolution in the SG filter includes: S21. For the time series signal y(n), the window width of the sliding window for signal filtering is set to 2M+1, and the data in the window is recorded as x[i], i∈[-M,M]; S22. Use an N-order polynomial to fit the data in the window, and then express the polynomial as: In the formula, p[i] represents the fitting result, i∈[-M,M], c k represents the fitting coefficient, k∈[0,N]; S23, taking multiple-order derivatives of the polynomial at i=0, we have: S24, convolve the time series signal with the unit impulse response of the filter to obtain the output: Then the fitting coefficients are obtained.
3. The harmonic extraction method based on the SG filtering algorithm according to claim 2 is characterized in that: Before step S23, the method further includes the following steps: S221, judging N and M, if N or M is greater than the corresponding set threshold, then entering step S23, otherwise the fitting coefficient is calculated by matrix solution.
4. The harmonic extraction method based on the SG filtering algorithm according to claim 3 is characterized in that: The calculation of the fitting coefficients using matrix solution includes the following steps: The residual sum of squares between the fitting results and the original data is expressed as: The residual sum of squares E is calculated by multiplying the fitting coefficients c k Find the partial derivative. When the partial derivative is 0, the fitting effect is the best. The result is expressed as: Among them, c r represents the rth fitting coefficient; Further simplification gives: It can be seen that when the window size M, the fitting order N and x[i] are known, the corresponding fitting coefficient c can be solved k , introduce the matrix to solve the calculation: Will It can be represented by a matrix with (2M+1) rows and (N+1) columns: The rule is A={a[i][r]}, where a[i][r]=i r , i∈[-M,M], r∈[0,N]; Set up matrix B = A T A, then: B = {b[k][r]}; in: Will Expressed as matrix X: X=[x[-M]…x[M]] T ; Will Expressed in matrix C: C=[c[0]…c[N]] T ; Combining the above formulas, we can get: BC=A T AC=A T X; The fitting coefficient matrix is expressed as: C=(A T A) -1 A T X; The polynomial of the fitting result is expressed in matrix as: P=AC=A(A T A) -1 A T X=EX; Among them, E is the auxiliary matrix.
5. The harmonic extraction method based on the SG filtering algorithm according to claim 1 is characterized in that: Also includes the steps: S4. Perform inverse park processing on the harmonics in the first power data component to obtain harmonics in a three-phase coordinate system.
6. A harmonic extraction terminal based on SG filtering algorithm, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the following steps are implemented: S1. Acquire three-phase power data, and obtain first power data components of d-axis and q-axis through park rotation transformation, wherein the three-phase power data is three-phase voltage or three-phase load current; S2. Filtering the first power data component through an SG filter to obtain a second power data component without harmonic components, wherein the fitting coefficient in the SG filter is calculated by convolution; S3. Compare the first power data component and the second power data component to extract harmonics in the first power data component.
7. A harmonic extraction terminal based on SG filtering algorithm according to claim 6, characterized in that: The calculation of the fitting coefficients by convolution in the SG filter includes: S21. For the time series signal y(n), the window width of the sliding window for signal filtering is set to 2M+1, and the data in the window is recorded as x[i], i∈[-M,M]; S22. Use an N-order polynomial to fit the data in the window, and express the polynomial as: In the formula, p[i] represents the fitting result, i∈[-M,M], c k represents the fitting coefficient, k∈[0,N]; S23, taking multiple-order derivatives of the polynomial at i=0, we have: S24, convolve the time series signal with the unit impulse response of the filter to obtain the output: Then the fitting coefficients are obtained.
8. The harmonic extraction terminal based on the SG filtering algorithm according to claim 7, characterized in that: Before step S23, the method further includes the following steps: S221, judging N and M, if N or M is greater than the corresponding set threshold, then entering step S23, otherwise the fitting coefficient is calculated by matrix solution.
9. A harmonic extraction terminal based on SG filtering algorithm according to claim 8, characterized in that: The calculation of the fitting coefficients using matrix solution includes the following steps: The residual sum of squares between the fitting results and the original data is expressed as: The residual sum of squares E is calculated by multiplying the fitting coefficients c k Find the partial derivative. When the partial derivative is 0, the fitting effect is the best. The result is expressed as: Among them, c r represents the rth fitting coefficient; Further simplification gives: It can be seen that when the window size M, the fitting order N and x[i] are known, the corresponding fitting coefficient c can be solved k , introduce the matrix to solve the calculation: Will It can be represented by a matrix with (2M+1) rows and (N+1) columns: The rule is A={a[i][r]}, where a[i][r]=i r , i∈[-M,M], r∈[0,N]; Set up matrix B = A T A, then: B = {b[k][r]}; in: Will Expressed as matrix X: X=[x[-M]…x[M]] T ; Will Expressed in matrix C: C=[c[0]…c[N]] T ; Combining the above formulas, we can get: BC=A T AC=A T X; The fitting coefficient matrix is expressed as: C=(A T A) -1 A T X; The polynomial of the fitting result is expressed in matrix as: P=AC=A(A T A) -1 A T X=EX; Among them, E is the auxiliary matrix.
10. The harmonic extraction terminal based on SG filtering algorithm according to claim 6, characterized in that: Also includes the steps: S4. Perform inverse park processing on the harmonics in the first power data component to obtain harmonics in a three-phase coordinate system.
Citation Information
Patent Citations
Wide-range gas concentration detection device and method based on TDLAS (Tunable Diode Laser Absorption Spectroscopy)
CN114594070A
Filtering device and method of mining active filter, and mining active filter
CN115912362A
Multi-synchronous rotating coordinate system-based multi-function grid-connected inverter harmonic control method
WO2020019550A1
Cited By
Inspection method and system for hydrogen fuel cell stack
CN120352783A