Friday, 27 March 2015

discrete signals - How to include phase in a sinusoidal Kalman Filter


I start with the equation for sinusoidal motion with an offset and differentiate to get the 2nd order ODE describing the motion of the object.


x=Asin(ωt+ϕ)+O˙x=Aωcos(ωt+ϕ)¨x=ω2Asin(ωt+ϕ)¨x=ω2(xO)=ω2x+ω2O


In matrix form this becomes:


[˙x¨x˙O]=[010ω20ω2000][x˙xO]



the system dynamics matrix F is:


[010ω20ω2000]


then by performing A(t)=L1(sIF)1


I get the following discretised A matrix:


[cos(Tsω)sin(Tsω)ωcos(Tsω)+1ωsin(Tsω)cos(Tsω)ωsin(Tsω)001]


This works to filter a sine wave of a know frequency with an offset, it predicts the correct phase, amplitude and even if a change the amplitude of the signal being filtered half way in it corrects for this very quickly and fits to the true signal. However if I shift the phase of the true signal part way through it does not correct for it. How might I include phase ϕ in my Kalman filter model such that it can still track the signal with sudden changes in phase?


If I try with my current filter I get the following result:


Kalman filter trying to track a sine wave with a phase change



Answer



The answer is that the filter I detailed can correct for the phase, the issue was that the values in my Q matrix were too small and therefore it was overly trusting of the model and was correcting for the change in phase very slowly. By increasing the values in the Q matrix this model can quickly correct for the change in the phase of the oscillator!



The output now looks like the following:


Output of Kalman filter tracking the phase change


No comments:

Post a Comment

readings - Appending 内 to a company name is read ない or うち?

For example, if I say マイクロソフト内のパートナーシップは強いです, is the 内 here read as うち or ない? Answer 「内」 in the form: 「Proper Noun + 内」 is always read 「ない...