Analysis and Application of Taylor-Kalman Filters Under a Distorted Grid Condition

The Taylor-Kalman filter (TKF) is a linear filter that can be modeled using either an accurately modeled TKF (known as the modified TKF) or an approximately modeled TKF. The higher-order TKF can not only adapt to the small frequency deviation condition but also prevents certain harmonics leakage. It has been increasingly widely applied in power grid synchronization and other power system fields. However, to the best of authors’ knowledge, systematical analyses of the impact of different models on the estimation performance and the methods for extraction of the shifted grid frequency have not been reported to date. The aim of this paper is to examine the TKF-based phase estimation algorithms (PEA) with regard to aspects such as the steady state, dynamic state and computational cost. Comparisons were carried out to evaluate the effects of the model and the order of TKF on the dynamic response and steady-state error. A strong tracking algorithm was also introduced to enhance the dynamic response. Several approaches for reducing the computational burden are given. Finally, combined with the moving average filter (MAF), which is a typical low-pass filter, an application example of TKF-based PEA was developed, and its performance was verified by experiments.


I. INTRODUCTION
Recently, fast and robust techniques for fundamental frequency positive sequence (FFPS) detection have played an important role in applications such as grid harmonic compensation and control of the grid connected converter for distributed energy and island detection.
A large number of new algorithms for FFPS estimation have been proposed in recent years under different steadystate and dynamic conditions. They can be divided into the frequency domain and time domain algorithms. DFT (Discrete Fourier transform)-based methods [1]- [3] are wellknown techniques for spectrum analysis of grid signal in the frequency domain. However, these techniques often assume that the grid voltage waveform is periodic and repetitive, which may lead to spectrum leakage problem due to the unsynchronized sampling effect, giving rise to errors in frequency and phase angle detection [4]. The time domain methods can be classified into the phase locked loop (PLL)based algorithms [5], [6] and the non-PLL algorithms. The underlying concept of the PLL-based algorithms is obtain a balance between the steady state accuracy and the transient The associate editor coordinating the review of this manuscript and approving it for publication was Wenjie Feng. response [7]. Many researchers have also devoted efforts to improving the PLL estimation performance by preventing the interferences arising from harmonics, and flickers. For the non-PLL methods, the different approaches are based on their operational principles. Least square (LS)-based algorithms [8], [9], Newton algorithms and modern signal processing-based algorithms [10], [11] are some examples of these techniques.
The concept of state space is used to describe the mathematical formulations of the Kalman filter (KF) [12]. Based on whether or not the prediction model is linear, Kalman filters are classified as traditional linear Kalman filters and nonlinear Kalman filters. The Extended Kalman filter (EKF) and the Unscented Kalman filter are two typical nonlinear Kalman filters. Both of these are Gaussian nonlinear models; the EKF transforms a nonlinear problem into a linear problem by using linearization methods, while the UKF approximately estimates the statistical characteristics of random variables by analyzing limited data sets. EKFs and UKFs are highly accurate and have been widely used. However, the use of nonlinear models affects their dynamic performance and gives rise to a significant computational cost. The grid signal is relatively stable, and its estimation should be performed rapidly. Thus, EKF and UKF are more likely be used in state estimation [13]- [15] and other power grid applications [16], [17].
The conventional KF has been widely applied in power systems [18]- [21]. It is a linear minimum variance estimation algorithm that is not only suitable for nonstationary processes but is also recursive. Many Kalman filters have been proposed in the previous studies, and these differ mainly in their different modeling approaches. A second-order and a third-order linear KF-based adaptive PLL algorithms were proposed in [19] and [22], respectively. By tuning the Kalman gains to a series of certain constant values, the KF-based adaptive PLLs can be obtained to be equivalent to some traditional PLLs [23]. However, the KF-based PLLs may show poor performance under harmonic conditions. To address the harmonics, several KF-based harmonic-decomposition methods have been developed [24]- [28].
As a linear KF, The Taylor Kalman filter (TKF) signal decomposition algorithm that uses the Taylor polynomial for the k th approximation of the dynamic phasor was proposed in [26], [27]. TKF has been applied not only in grid synchronization but also in many other fields [29], [30]. All of these TKF methods have simplified the rotating dynamic phasor model. An accurate model of TKF called the modified TKF (MTKF) was proposed in [31]. To distinguish the above two TKF methods, the approximately modeled TKF is called ATKF in this paper.
Tests results have shown that both high-order ATKF and MTKF can meet the low frequency deviation condition, but systematic analyses of the methods for the estimation of the shifted grid frequency have not been reported to date. The main purpose of this paper is to compare and analyze the TKF-based algorithms. The paper focuses on TKFs and makes the following contributions.
1) The mathematical basis of TKF is derived 2) The frequency responses of both ATKF and MTKF are presented. A mathematical analysis is also performed to illustrate how ATKF and MTKF can track the FFPS component under the frequency deviation condition.
3) The effects of the model and its order on the dynamic response are analyzed. A strong tracking algorithm is provided. The enhancement of the TKF dynamic performance is also explained based on the strong tracking algorithm and the comparison of traditional TKFs. 4) The computational cost of different TKFs in the steady state and two approaches for reducing the computational burden are presented. 5) An example of a design of a prefilter-based TKF algorithm is provided, and several tests are conducted to evaluate its performance.

II. BASIS OF k th ORDER TKF
Generally, the grid signal can be expressed as: where V DC is the direct current (DC) component, and V m (t) and ϕ m (t) are the dynamic magnitude and the dynamic phase of the m th harmonic, respectively. ω m = 2π mf n t is the angular frequency, and f n is the nominal frequency of the grid. M is the maximum order of the harmonics. The state vector can be expressed as . r m is the matrix form of rotating dynamic phasor which is defined as r(t) = p(t)e j2πft and p m is the k th Taylor polynomial matrix form of the dynamic phasor p m (t) = V m (t)e jϕ m (t) that is defined as [26]: where p(n) = p(n) p (1) (n) · · · p (k) (n) T , τ is the interval of each sample, and T(τ ) is the state transition matrix of the dynamic phasor: and the order of TKF depends on the order of the Taylor polynomial.
In most TKF studies reported in the literature, r m is approximated as [26], [27]: Strictly, r (k) m is not the k th derivative of r m . The Process model and the measurement model of ATKF can be obtained by: . . . where and To obtain the full accurate model, it is helpful to start with the connection between the dynamic phasor and the rotating dynamic phasor: and M m is an invertible matrix defined as: Thus, the state equation of the m th harmonic component in MTKF can be obtained as: where The transition matrix of m th harmonic component can be rewritten as: . (13) Hence, each component of the grid signal can be extracted by the Kalman filter, and the estimated grid signal at a given instance (n) is obtained as follows: a) Calculate the Predicted state matrix b) Obtain the Predicted error covariance matrix c) Compute the Kalman gain K d) Drive the Estimated state matrix e) Update the Estimated error covariance matrix where u(n) is the input grid signal, and Q and R are the covariance matrices of the process and the measurement noise, respectively.

III. STEADY STATE ANALYSIS OF TKF
Under the steady state, the Kalman gain K depends only on the ratio of the state variable covariance matrix Q to the measurement noise variance matrix R and is not affected by the initial error covariance matrix P [26]. Hence, the frequency response of T k KF (the kth order Taylor Kalman Filter) can be easily obtained by taking z transform of its update state equation that is derived in the appendix to save space.  An analysis of this curve easily leads to the following conclusions: Regardless of the order of MTKF, the characteristic reflected by r 1 extracts the FFPS component and eliminates the other harmonics when the grid frequency is at its nominal value and all of the harmonic models are included in the transition matrix. With the increase in the number of harmonic models, the computational cost will increase, and the computation of the Kalman filter can be reduced by designing an appropriate prelow-pass filter.
As the order of MTKF increases, the magnitude-frequency and phase-frequency curves become increasingly flat near the nominal frequency and other integer harmonics, implying that MTKF can accurately extract the target component and eliminate other harmonics under the frequency deviation condition.
The frequency response of ATKF is depicted in FIGURE 1 (b) and is similar to that of MTKF. The high-order ATKF has a smaller flat region (compared to MTKF) around the nominal frequency, indicating that the high-order ATKF can also track the FFPS component when the grid frequency varies slightly.
Analyses are carried out below to illustrate that both MTKF and ATKF can fit a small frequency deviation.
Since the nominal frequency of the rotation factor e j2πft is a constant value, the frequency offset is reflected by the phasor change under steady state. When the real frequency varies from the nominal frequency f tof , the dynamic phasor p(t) will change according to: The rotating dynamic phasor can be rewritten as: Then, the derivative of the rotational dynamic phasor r (1) (t) can be written as: Therefore, the real frequency at instant n can be esti- Noticing that both r (0) and r (1) are state variables of the Kalman filter, the order of the Kalman filter should be 1 or higher.
For ATKF, we take the derivative of (19) to obtain: Then, we rewrite the expression for the rotating dynamic phasor as: The real frequency can be estimated byf The frequency response of r (1) /2π is shown in FIGURE 2. The r (1) /2π of MTKF estimates the real frequency, and the r (1) /2π of ATKF reflect the difference between the real frequency and the nominal frequency, which is consistent with the results of the mathematical analysis.
Two tests were carried out to analyze the influence of the grid frequency on the estimated performance of TKFs.
Test 1: the grid voltage is a pure sinusoidal signal with an amplitude of 311 V.
As is shown in FIGURE 3, the following conclusions can be drawn: 1) The error increases with increasing frequency deviation.
2) The order of the Kalman filter plays a leading role when the grid voltage is a pure sinusoidal signal (see FIGURE 3 (a)). A higher order implies a higher estimation accuracy. MTKF and ATKF have a very similar estimation performance if they have the same order. 3) The error also increases when the voltage is contaminated with harmonics, as shown by the comparison of FIGURE 3(a) and FIGURE 3(b). This is because when the frequency is varied, the order of the harmonics will not be an integer for the nominal frequency. Lowerorder MTKF and ATKFs cannot completely filter all of these harmonics. 4) Under harmonics condition, frequency deviation has the greatest influence on AT 1 KF, followed by MT 1 KF and AT 2 KF, and finally MT 2 KF. The Taylor-based Kalman filter with an accurate model and higher order has larger flat regions in its frequency response, enhancing its estimation performance under the frequency deviation condition.

IV. DYNAMIC PERFORMANCE ANALYSIS OF TKF
A. DYNAMIC PERFORMANCE ANAYLSIS   As shown by (14), (15) and (17), the Kalman gain is independent of the state vector X (see appendix). The Kalman gain becomes increasingly small with time, leading to a worse frequency response under the steady state condition [27] and a long-time adjustment under the dynamic conditions.
The abovementioned problem can be solved using two approaches: 1) Fix the Kalman gain when the Kalman filter reaches its steady state. 2) Use the strong tracking algorithm; here, the Predicted error covariance matrix must be adjusted with the change in the grid condition. Inspired by the introduction of the suboptimal scaling factor in [32] to improve the filter's tracking ability and response speed under dynamic conditions, (15) need to be rewrite as: where λ is the suboptimal scaling factor. By introducing the suboptimal scaling factor, the error covariance matrix P will increase when the grid signal changes dynamically, and then the Kalman gain will also increase, so that a fast response can be realized. The enhanced MTKF and ATKF are called STMTKF and STATKF, respectively, in this paper.
Dynamic analysis is developed to evaluate the performance of the two strategies mentioned above (see FIGURE 5). A sinusoidal signal at 50 Hz with unit amplitude is tracked by the Kalman filter. The real and imaginary signals of the state variable that estimate the FFPS component are employed to represent the trajectories in a four-quadrant XY plane (the blue line). When the signal is accurately traced, the trajectory is a unit radius circle (overlap with the red line).
The initial point of the trajectory is (X, Y) = (0, 0). Figures 5(a-d) depict the performance of ATKF and MTKF with constant Kalman gains that are obtained after the first fundamental cycle., The comparative group adopts the strong tracking algorithm (Figures 5(e-h)).
Analysis of the results presented in FIGURE 5 shows the following: 1) The overshoot increases with increasing order of the Kalman filter. An accurate model of the Kalman filter also contributes to a poorer dynamic response ability. 2) The strong tracking algorithm can improve the response speed for at least half of the fundamental cycles compared to the constant Kalman gain method. Therefore, the dynamic response ability is clearly enhanced by introducing the strong tracking algorithm at the expense of a small additional computational cost.

B. COMPUTATIONAL COST
It is assumed that there will be no significant offset in the frequency of the power grid. Once the Kalman gains of ATKF are established, the filtering algorithm is performed using only the state prediction equation in (14). Therefore, it takes only ((k+1)(k+2)/4+1)N multiplications to obtain the entire filtering for AT k KF containing N blocks (harmonic models) for each iteration [27]. Unlike for ATKF, matrix in (12) of MTKF does not have the submatrix diagonal nature and superior triangular form requiring (k + 1) 2 multiplications. Thus, the computational cost of a state transition is (k + 1) 2 N /2 and the cost of the entire filtering is ((k + 1) 2 /2 + 1)N .
For the strong tracking algorithm, additional computation must be performed to calculate the suboptimal scaling factor λ that requires four more operations in the steady state.
Considering the characteristics of Kalman filter, two approaches can help to alleviate the computational burden: 1) Simplification of the model: as mentioned above, the computational cost of an approximately modeled Kalman filter is lower than that of an accurately modeled Kalman filter. 2) Application of a prefiltering stage: by using prefilters, harmonics can be eliminated or at least attenuated to a certain extent so that the order of harmonic models can be reduced, and moreover, the harmonic models can be removed from the transition matrix of the Kalman filter. If the order of the T k KF's harmonic model is reduced to zero, only ((k + 1)(k + 2)/2 + 3N /2 − 1) multiplication operations are sufficient for the entire filtering in each sampling period. For AT k KF, only ((k + 1) 2 + 3N /2 − 1) multiplications are required.

V. A MAF-TKF BASED PHASE ESTIMATION ALGORITHM
In this section, examples of MAF-TKF algorithms are proposed to provide a reference to the design of the TKF-based FFPS component estimation algorithm.
It is important to note that using a prefiltering stage is an alternative approach, and high-order TKFs for signal decomposition can meet the frequency deviation condition. The aim of this section is to analyze the influence of prefiltering stage used for TKF, so that we do not perform comparisons between the proposed method and the PLL/FLL-based algorithm.

A. WHOLE STRUCTURE OF THE MAF-TKF
The whole structure of the MAF-TKF is shown in FIGURE 6.
The MAF used as a prefiltering stage is a linear-phase finite-impulse response filter with the s-domain transfer function given by where T w is the window length that determines the filtering and response ability of MAF. Since the Taylor-based Kalman filter has a certain intrinsic filtering ability, the window length T w = T /2 (T is the fundamental period of the grid voltage) is considered in this paper. Based on the previous mathematical works [33], the input-output transfer function of the filter can be described asv where ω n = 2π/T is the nominal angle frequency of FFPS. It can completely filter all of the odd harmonics up to the aliasing frequency and give rise to a half-cycle delay. FIGURE 7 depicts the frequency response of the transfer functions G α and G β . As shown in FIGURE 7, both G α and G β have a 0 dB magnitude gain at the nominal frequency, and can completely block out the dc component and all of the odd harmonics when the frequency is at its nominal value. However, when the frequency of the grid voltage varies from its nominal value, the magnitude attenuation and phase shifting of the FFPS component will arise accompanied with the ''leakage'' of the other harmonics. Fortunately, the components in G β always show a −90 • difference from the same order components in G α at all frequencies.
As observed from FIGURE 7, G β has better filtering ability than G α : the amplitude of the signal from the β-axis will be attenuated by at least 20 dB when the frequency is higher than 200 Hz but is 600 Hz in the α-axis. A higher filtering ability of the prefilter stage leads to a lower computational burden for the calculation of the state matrix of TKF. Therefore, the input of TKF is taken from the β-axis. VOLUME 8, 2020  As mentioned above, the magnitude and phase must be compensated.
Suppose that V is the FFPS component of the grid voltage. The outputs of the MAF-based prefilter equal to |G β (jω g )|V in the steady state. Meanwhile, the transfer function will not be equal to 1 under the frequency deviation condition. Therefore, the signalV estimated by TKF should be divided by |G β (jω g )| to correct the magnitude attenuation: The amplitude gain of the transfer functions G β (jω g ) can be approximated by taking their Taylor series expansion: where ω g = ω g − ω n = 2π f g is the difference between the grid angle frequencies ω g and ω n .
As indicated in (29), the phase difference in the β-axis is given by: Therefore, the phase should be compensated by adding (T w /2) ω g + π/2.

B. SIMULATIONS
The FFPS grid signal in all tests is a cosine function that has a magnitude of 380 V, initial phase of 0 • and frequency of 50 Hz. It can be expressed as y 1 (t) = 380 cos(100π t).
The sampling frequency is 1 × 10 4 Hz and all of the tests are assumed to reach their steady state in the beginning of the test.
Test 1: in this test, a 30 • phase jump occurs om the signal at 0.2 s.
Test 2: the grid voltage experiences a sag with a magnitude of 0.3 p.u.
Test 3: in this test, the frequency of the signal will jump from 50 Hz to 49.5 Hz at 0.2 s. This test is also repeated under harmonics condition: the grid voltage is contaminated with 5 th -order and 7 th -order harmonics (0.1 p.u. and 0.73 p.u., respectively). FIGURE 8 and FIGURE 9 show the simulation results for tests 1 and 2, respectively, and it can be observed that all of the MAF-TKFs are free from any steady-state offset errors under voltage sag and phase jump. The first-order TKFs require shorter setting times than the second-order TKFs. Moreover, the strong tracking algorithm improves the dynamic response of TKFs in contrast to the fixed Kalman gain algorithms.   This is due to the delay caused by the MAF prefiltering stage and the slight error caused by frequency offset that may lead to the incorrect direction of the correction.
In summary, the prefilter can filter out the harmonic components and strongly reduce the computational cost, but this leads to some delay. When the prefilter stage is applied, the fixed Kalman gain algorithm is superior to the strong tracking algorithm. The simulation results show that the accurately modeled TKFs have higher accuracy than the approximately modeled TKFs, while their response speeds and computational costs are similar. Therefore, MTKF is recommended. With regard to the order of TKF, the first-order TKFs have shorter setting times than the second-order TKFs (approximately 25 ms for the first-order TKFs and 40 ms for the second-order TKFs). However, the second-order TKFs have lower steady state error offset under the frequency deviation condition. A comprehensive consideration is necessary for the choice of the order of the TKF.

C. EXPERIMENTS
MAF-MTKFs are implemented on a DSP TMS320F28335 control board for a further evaluation of their performance characteristics, and the condition type of each test is designed to be the same as that used in the simulation tests.
As shown in FIGURE 11, the magnitude and phase error detected by the proposed PEA are displayed on the oscilloscope and are in agreement with the simulation results.

VI. CONCLUSION
In this paper, the Taylor-based Kalman filter was analyzed using two approaches: the estimation performance in the steady state was evaluated by mathematical analysis and frequency domain analysis. In dynamic condition, the convergency of Kalman gain was analyzed. Then, the fixed Kalman gain algorithm and strong tracking algorithm were proposed and their effects in the dynamic condition were analyzed using the XY plane trajectories. The computational cost was also discussed. The conclusions can be summarized as follows: 1) The MTKF has higher estimation accuracy, but its response is slower than that of ATKF.
2) The higher-order TKFs have higher estimation accuracy, but require a greater computational cost and longer setting time compared to the lower-order TKFs.
3) The strong tracking algorithm based on TKFs can achieve fast response at the expense of a heavier computational burden. Therefore, it is not suitable for the case with the prefiltering stage. 4) The prefilter can filter out the harmonic components and strongly reduce the computational cost but gives rise to a certain delay.

APPENDIX
Since the linear Kalman filter theory is the mathematical basis of T k KF, the frequency response of T k KF can be obtained by analyzing the update state equation of linear Kalman filter: X(n) = X (n − 1) + K(n)(y(n) − H X (n − 1)) (34) Takeing z-transform of (34), we obtain X(z) = z −1X (z) + K(y(z) − H z −1X (z)) and solving forX(z), we have Thus, the transfer functions of input and output are given by The frequency response of the state filters can be obtained by replacing z by e j2πf τ . WEN XU received the B.S. degree in electrical engineering and automation from Hainan University, Hainan, China, in 2016. He is currently pursuing the Ph.D. degree with the Department of Electrical engineering, Hunan University, Hunan, China.
His research interests include phase-locked loop and nonlinear filtering techniques for power engineering applications, power quality measurement and improvement, estimation of power system parameters, and microgrid.
CHUN HUANG received the B.Sc., M.Sc., and Ph.D. degrees in electrical engineering from Hunan University, Changsha, China, in 1988China, in , 1991China, in , and 2005 He is currently a Professor of electrical engineering with Hunan University. His current research interests include analysis and control of power quality, relay protection, and the application of signal processing technology in electrical engineering.
XING XIE received the B.Sc. degree in electronics and information engineering from the Guilin University of Technology, Guilin, China, in 2011, and the M.Sc. degree in electronic circuits and system from Shenzhen University, Shenzhen, China. He is currently pursuing the Ph.D. degree with the College of Electrical and Information Engineering, Hunan University, Changsha, China.
His current research interest includes power quality analysis and control. VOLUME 8, 2020