Research on Dynamic Modeling of KF Algorithm for Detecting Distorted AC Signal

Kalman filter (KF) is often based on two models, which are phase angle vector (PAV) model and orthogonal vector (OV) model, in the application of distorted grid AC signal detection. However, these two models lack rigorous and detailed derivation from the principle of dynamic modeling. This paper presents a phase angle vector dynamic (PAVD) model and an orthogonal vector dynamic (OVD) model, which are combined with Kalman filter for detecting distorted grid AC signal. They reveal that the state noise covariance of the dynamic model−based KF is related to the sampling cycle, and overcome the defect of more detecting error for conventional model−based KF. Experiment and evaluation results show that the proposed KF algorithms are reasonable and effective. Therefore, this paper contributes a guiding significance for the application of KF algorithm in harmonic detection.


Introduction
The Kalman filter (KF) plays an increasingly important role in the real−time detection of grid AC signal [1]. It was first applied to the power signal processing field by Dr. A. A. Girgis in 1981 [2][3][4]. It mainly applies to the following fields: fundamental and harmonic components detection of grid voltage/current [5][6][7][8][9][10], phase−locked loop synchronization [11][12][13][14][15], power quality detection and compensation equipment [16][17][18][19][20], power disturbance feature extraction and machine classification [21][22][23][24], and etc. In these applications, two conventional models, phase angle vector (PAV) model and orthogonal vector (OV) model, are mainly used. The phase angles were used as vectors to establish a state-space model which could be called the phase angle vector (PAV) model through cosine expansion [3]. The orthogonal vector was used to establish a state-space model that could be called the orthogonal vector (OV) model [4]. However, the state noise covariance of the two models is only a given value based on empirical statistics of the AC signal. It is selected as a fixed value, such as Q = 0.05 × I (I represents the unit matrix), when AC signal is the grid voltage [10,11]. It is selected as a fixed value, such as Q = 0.01 × I, when the AC signal is the sampling current [20]. It is mainly to avoid big tracking error and enable to detect response without time delay. With the development of computer hardware and sensor technology, the sampling cycle is getting smaller, and the accuracy requirements are getting higher. The detecting accuracy of the fundamental and harmonics components for the conventional detecting model−based KF algorithm cannot meet the requirements of modern engineering applications.
The current issue is that the detecting accuracy of the fundamental and harmonics components for the conventional detecting model-based KF algorithm cannot meet the requirements of modern engineering applications. There is no fixed rule as references (1) We derive the discretization model from the continuous differential equation in accordance with stochastic process theory, to find the value law of fixed value of covariance under different sampling cycles. (2) We greatly improve the detecting accuracy of fundamental and harmonics components, enabling the detection results to meet the requirements of modern engineering applications of AC current and voltage signal.
Section 1 introduces the Kalman filter mainly applies to the following fields and model−based KF existing problems. In Section 2, the related works about conventional PAV and OV model are introduced. In Section 3, the PAVD and OVD models are rederived according to of stochastic process theory. Then, the PAVD−KF and OVD−KF algorithms are proposed. In Section 4, the performances of PAVD−KF and OVD−KF algorithms are evaluated and compared by the experimental current and voltage sampling data. Section 5 concludes the paper.

Related Work
In this section, we proposed the expression of distorted AC signal first, and introduce the conventional PAV−KF and OV−KF algorithms then.

Distorted AC Signal
The waveform of the distorted AC signals sampled at time t can be expressed as where i = 1, 2, 3, · · · , N, T denotes the sampling cycle. For the fundamental frequency of 50 Hz, ω 0 = 100π.
represents the fundamental and harmonic components.
is the state noise of fundamental and harmonic components.

PAV Model
The vector of fundamental and harmonic components is expressed as X k = x 1 y 1 · · · x n y n T , where x 1 = A 1 cos θ 1 , y 1 = A 1 sin θ 1 ,x n = A n cos θ n , y n = A n sin θ n .
The measurement equation of model is expressed as [3]  The state equation of model is expressed as The covariance matrix of state noise W k can be expressed as

OV Model
Considering a signal A k sin(ω k t k + θ k ) with amplitude A k , angular frequency is ω k and phase is θ k [4,11]. Let x k = A k sin(ω k t k + θ k ), y k = A k cos(ω k t k + θ k ), initially, consider A k+1/k ≈ A k , ω k+1/k ≈ ω k and θ k+1/k ≈ θ k . At the time t k+1 = t k + T, the signal x k can be expressed as where, T is the sampling cycle. Additionally, the state−space is extended for detection of distorted AC signal existed n frequencies harmonic components. The vectors are expressed as X k = x 1 y 1 · · · x n y n T k , where, x 1 k = A 1 k sin ω k t k + θ 1 k , y 1 k = A 1 k cos ω k t k + θ 1 k , x n k = A n k sin nω k t k + θ n k , y n k = A n k cos nω k t k + θ n k .
Then, the state and measurement equation is expressed as [4] where, the state transition matrixes Φ i are shown below as The covariance matrix of state noise W k i can be expressed as in (4) and (9), I 2n×2n is a unit matrix. σ 2 PAV and σ 2 OV are selected as 0.05, when AC signal is sampling voltage [10,11]. σ 2 PAV and σ 2 OV are selected as 0.01, when AC signal is sampling current [20].

PAV-KF and OV-KF Algorithm
The discrete PAV−KF and OV−KF algorithm for detecting distorted AC signal can be expressed as follow by combining PAV and OV model.
The amplitude and the phase angle for the fundamental and harmonic components can be calculated as follows.

PAVD-KF and OVD-KF Algorithm
In Section 3, we construct the AC signal continuous differential equation of phase angle vector and orthogonal vector, and derive the discretization PAVD and OVD model in accordance with stochastic process theory. Next, we combine the proposed models with KF algorithm, to obtain PAVD−KF and OVD−KF algorithm.

PAVFIGURE D-KF Algorithm
The phase angle vectors of fundamental components in (2)−(3) are expressed as The first derivative can be expressed as d dt where, w x (t) and w y (t) are the input white noise, w x (t)⊥w Equation (11) is discretized, and the state equation can be obtained as follows [25]. where, The covariance matrix of state noise W k can be expressed as from (18), an important conclusion can be known that Q w is related to sampling cycle T. The state−space dimension of the distorted AC signal is extended under the consideration of fundamental and harmonic components. The state-space formulas of PAVD model are the same as the conventional PAV model (2)−(3). The difference is that the state noise covariance in (4). The state noise covariance of the PAVD model is (19) where, σ 2 PAVD is the state noise covariance of PAVD model. ρ ≤ 1 is a coefficient. When high detection precision is required, ρ is selected as a small value. When dynamic fast detecting is required, ρ is selected to a large value. Then, the discrete PAVD−KF algorithm can be obtained by combining model (2), (3), (15) and KF algorithm.

OVD−KF Algorithm
In the two−dimensional space, the circular movement of the object along the midpoint is projected on the x, y axis as a pure sine and a pure cosine waveform. It is shown in Figure 1.
consideration of fundamental and harmonic components. The state-space formulas of PAVD model are the same as the conventional PAV model (2)−(3). The difference is that the state noise covariance in (4). The state noise covariance of the PAVD model is where, 2 PAVD σ is the state noise covariance of PAVD model. 1 ρ ≤ is a coefficient. When high detection precision is required, ρ is selected as a small value. When dynamic fast detecting is required, ρ is selected to a large value. Then, the discrete PAVD−KF algorithm can be obtained by combining model (2), (3), (15) and KF algorithm.

OVD−KF Algorithm
In the two−dimensional space, the circular movement of the object along the midpoint is projected on the x, y axis as a pure sine and a pure cosine waveform. It is shown in Figure 1.
It can be expressed as where, m A is the amplitude, 0 ω is the angular frequency, and θ is the phase angle. The first derivative of (10) can be expressed as where, . The state equation can be obtained from (21).
Equation (22) is discretized, and the state equation can be obtained as follows [25].
where, It can be expressed as where, A m is the amplitude, ω 0 is the angular frequency, and θ is the phase angle. The first derivative of (10) can be expressed as .
where, w x (t) and w y (t) are the input white noise, The state equation can be obtained from (21).
d dt Equation (22) is discretized, and the state equation can be obtained as follows [25].
where, The state noise covariance matrix can be expressed as from Equation (16), an important conclusion can be drew that Q w is related to the sampling cycle T.
The state-space dimension of the distorted AC signal is expanded under the consideration of fundamental and harmonic components. The state and measurement equations of OVD model are the same as the conventional OV model (4) and (5). The difference is that state noise covariance matrix of the OV model in (6). That is where σ 2 OVD is the covariance of OVD model. ρ ≤ 1 is a coefficient. When high detection precision is required, ρ is selected as a small value. When dynamic fast detecting is required, ρ is selected to a large value.

Experiment and Evaluation
In this section, we conduct the detection of the current and the voltage with the sampling cycle of 10 µs and 40 µs. Then, comparing the detecting results for fundamental and harmonics components in PAVD−KF and PAV−KF algorithm, and in OVD−KF and OV-KF algorithm. At the last, we come to a conclusion of these results.

Experiment Settings
As an experimental example, we sample the AC distorted current signal. Experiment platform consists of AC grid (380 V, 50 Hz), oscilloscope (Tektronix GDS−2102) and nonlinear load (the three−phase rectifier, R = 100 Ω and L = 1.5 mH). It is shown in Figure 2. The AC current signals are sampled by the oscilloscope. Sampling cycles are selected as 10 µs and 40 µs. The experiment sampling current data and spectrogram are shown in Figures 3 and 4. The HRI of harmonic components are measured to be approximately 24% of 5th, 10% of 7th, 10% of 11th, 5% of 13th, 5% of 17th, 4% of 19th by spectrum analysis.  HRI is defined as follows HRI n = I n I 1 × 100% where I 1 is the voltage rms value of fundamental component, I n is the voltage rms value of n−th harmonic components.   . The state noise covariance is selected as 14 14 0.01 in (4). The state noise covariance is selected as 14 14 0.01

Detection Results for PAVD−KF Algorithm
Two algorithms of PAV−KF and PAVD−KF are evaluated and compared. The evaluation results for sampling cycle 10 µ s and 40 µ s are shown in Figures 5 and 6.
Three-phase rectifier    . The state noise covariance is selected as 14 14 0.01 in (4). The state noise covariance is selected as 14 14 0.01

Detection Results for PAVD−KF Algorithm
Two algorithms of PAV−KF and PAVD−KF are evaluated and compared. The evaluation results for sampling cycle 10 µ s and 40 µ s are shown in Figures 5 and 6.
Three-phase rectifier The measurement noise covariance R of the algorithms is all selected as 0.06 A, that is the measurement error of the sensor. The initial covariance matrices are selected as P 0/0 = 1000 × I 14×14 . The state noise covariance is selected as Q k = 0.01 × I 14×14 in (4). The state noise covariance is selected as Q k = 0.01 × T × I 14×14 in (19)

Summary for AC Current Detecting
It can be seen from Figures 5 and 8, when Q = 0.01 × I, the detecting errors of the conventional PAV−KF and OV−KF algorithms are big. In particular, the detecting errors of the conventional algorithms for sampling cycle 40 μs are rather big. The errors are too big to affect the normal operation.
Corresponding to it, when Q combines with the sampling cycle, Q = 0.01 × T×I, regardless of the fundamental or harmonic components, the proposed detecting accuracies in PAVD−KF and OVD−KF algorithm are much higher than the conventional algorithms.

Experiment Settings
The AC signal is grid voltage as an experimental example. Experiment platform is shown in Figure 9. The experiment of superimposing harmonics in fundamental voltage is carried out through a programmable power supply device. The AC voltage signals are sampled and the sampling cycles T are selected by the oscilloscope of Tektronix GDS−2102.
The harmonics ratio for voltage (HRU) is defined as follows

Summary for AC Current Detecting
It can be seen from Figures 5 and 8, when Q = 0.01 × I, the detecting errors of the conventional PAV−KF and OV−KF algorithms are big. In particular, the detecting errors of the conventional algorithms for sampling cycle 40 µs are rather big. The errors are too big to affect the normal operation.
Corresponding to it, when Q combines with the sampling cycle, Q = 0.01 × T × I, regardless of the fundamental or harmonic components, the proposed detecting accuracies in PAVD−KF and OVD−KF algorithm are much higher than the conventional algorithms.

Experiment Settings
The AC signal is grid voltage as an experimental example. Experiment platform is shown in Figure 9. The experiment of superimposing harmonics in fundamental voltage is carried out through a programmable power supply device. The AC voltage signals are sampled and the sampling cycles T are selected by the oscilloscope of Tektronix GDS−2102.
where 1 U is the voltage rms value of the fundamental component, and n U is the voltage rms value of n−th harmonic components. Experiment voltage data for sampling cycle 10 μs is in Figure 10. Experiment voltage data for sampling cycle 40 μs is in Figure 11, and the HRU of harmonic components all are set as 5% of 3rd, 10% of 5th, and 8% of 7th. The harmonics ratio for voltage (HRU) is defined as follows where U 1 is the voltage rms value of the fundamental component, and U n is the voltage rms value of n−th harmonic components. Experiment voltage data for sampling cycle 10 µs is in Figure 10. Experiment voltage data for sampling cycle 40 µs is in Figure 11, and the HRU of harmonic components all are set as 5% of 3rd, 10% of 5th, and 8% of 7th.    The R of the algorithms are all selected as 3.11 V, that is the measurement error of the sensor. The initial covariance matrices of algorithms are selected as P 0/0 = 1000 × I 10×10 . The state noise covariance matrix of algorithms is selected as Q k = 0.05 × I 10×10 . The state noise covariance matrix of algorithms is Q k = 0.1 × T × I 10×10 .

Summary for AC Voltage Detecting
It can be seen from Figures 12 and 13 that the amplitudes of the fundamental components of the conventional model−KF algorithm detecting are fluctuating, the stability of its detection shows poorly. Specifically, when we use the sampling cycle 40 μs, the error is too big to be ignored. From Figures 14 and 15, we know that detecting errors of the harmonics components for the conventional OV−KF algorithm are also big, though the error seems smaller compared to PAV−KF. Corresponding to it, the detecting accuracies of the fundamental and harmonic components for the OVD−KF algorithm are higher than that of the OV−KF algorithm.
Generally, when Q = 0.05 × I, the conventional algorithms could basically meet the engineering requirements with some big errors under different sampling cycle conditions. When Q =0.05 × T × I, all the novel algorithms could fulfill the requirements.

Summary for AC Voltage Detecting
It can be seen from Figures 12 and 13 that the amplitudes of the fundamental components of the conventional model−KF algorithm detecting are fluctuating, the stability of its detection shows poorly. Specifically, when we use the sampling cycle 40 µs, the error is too big to be ignored. From Figures 14 and 15, we know that detecting errors of the harmonics components for the conventional OV−KF algorithm are also big, though the error seems smaller compared to PAV−KF. Corresponding to it, the detecting accuracies of the fundamental and harmonic components for the OVD−KF algorithm are higher than that of the OV−KF algorithm.
Generally, when Q = 0.05 × I, the conventional algorithms could basically meet the engineering requirements with some big errors under different sampling cycle conditions. When Q = 0.05 × T × I, all the novel algorithms could fulfill the requirements.

Summary for Experiment and Evaluation
In general, when using the fixed value, the error of PAV model is the biggest, neither current nor voltage can meet the demand. OV model performs better, when using the sampling cycle 10 µs, the voltage can be used normally, and the current error is too big to be used. But when using the sampling cycle 40 µs, both current and voltage cannot operate normally.
The proposed algorithms in this paper, whether it is PAVD model or OVD model, it is related to the sampling cycle, so the voltage and current detecting results can meet the engineering requirement.
Take PAV model with 40 µs in current and voltage tracking for example, the conventional methods produce big errors when Q = 0.01 × I detecting the current and Q = 0.05 × I detecting the voltage. Only when Q = 0.00001 × I detecting the current, the accuracy of it would be almost close to that of our proposed algorithm, as Figure 16 shows. When Q = 0.0005 × I detecting the voltage, the accuracy would satisfy the requirement, as Figure 17 shows. Take PAV model with 40 μs in current and voltage tracking for example, the conventional methods produce big errors when Q = 0.01 × I detecting the current and Q = 0.05 × I detecting the voltage. Only when Q = 0.00001 × I detecting the current, the accuracy of it would be almost close to that of our proposed algorithm, as Figure 16 shows. When Q = 0.0005 × I detecting the voltage, the accuracy would satisfy the requirement, as Figure  17 shows.

Conclusions
This paper presents the PAVD−KF and OVD−KF algorithm derived from the stochastic process theory. It enhances the knowledge about the Kalman algorithms applied to the harmonic detection of the distorted AC grid. It gives a rule that the KF algorithms in the application of distorted grid AC signal detection is related to the sampling cycle and their state noise covariance cannot be simply considered as a constant. conventional methods produce big errors when Q = 0.01 × I detecting the current and Q = 0.05 × I detecting the voltage. Only when Q = 0.00001 × I detecting the current, the accuracy of it would be almost close to that of our proposed algorithm, as Figure 16 shows. When Q = 0.0005 × I detecting the voltage, the accuracy would satisfy the requirement, as Figure  17 shows.

Conclusions
This paper presents the PAVD−KF and OVD−KF algorithm derived from the stochastic process theory. It enhances the knowledge about the Kalman algorithms applied to the harmonic detection of the distorted AC grid. It gives a rule that the KF algorithms in the application of distorted grid AC signal detection is related to the sampling cycle and their state noise covariance cannot be simply considered as a constant.

Conclusions
This paper presents the PAVD−KF and OVD−KF algorithm derived from the stochastic process theory. It enhances the knowledge about the Kalman algorithms applied to the harmonic detection of the distorted AC grid. It gives a rule that the KF algorithms in the application of distorted grid AC signal detection is related to the sampling cycle and their state noise covariance cannot be simply considered as a constant.
This paper applies the actual current and voltage data of the sampling cycle 10 µs and 40 µs to detection and evaluation. The conventional algorithms have big errors in general and unable to meet engineering requirements. When using a fixed value of covariance, if we are going to obtain the ideal results, we need to spend a lot of time debugging (trying to make up) the parameters. Also, there is no theoretical source to set the fixed value of covariance. To solve it, we propose the algorithms to save much time and workload to get the ideal results. Besides, we make the algorithms more feasible and effective based on stochastic process theory. From which the results show that the proposed PAVD−KF and OVD−KF algorithms are effective and improve the dynamic detecting accuracy of grid AC signal significantly. This paper would provide a reference for the application of KF algorithms to harmonic detection, power quality control and grid synchronization in the future.