LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Discrete Kalman Filter Matrix settings for higher order system

Solved!
Go to solution

I am trying to use the Discrete Kalman Filter Block in the Control and Simulation Toolkit for a second order system. I went through all the example for this block in the NI Examples but most of the examples are mainly using a first order system.

 

I think I have set the matrix G, H, Q, R and E correctly for a 2nd order system. However, I am still getting message of saying E(w) improper and E(v) is no the same dimension with the output.

 

" Error -41693 occurred at NI_CD_Stochastic Systems.lvlib:cd_verify m Q R N.vi "

 

Thus, I need help to configure the setting for the block in both the Stochastic and Discrete Kalman Filter block in order for the Kalman Filter to work in my VI. Attached is a simple VI that i am trying to learn about this Kalman Filter Block

 

Thanks in advance

0 Kudos
Message 1 of 7
(4,872 Views)

oh, I have so many questions!

 

Why the wait (ms).vi?

 

When do you init the FB node?

 

You know? I;d like you to state why a Kalman filter is apporpiate?-- you don't use the output.

 

 


"Should be" isn't "Is" -Jay
Message 2 of 7
(4,858 Views)

Jeff,

 

Attached is the corrected version VI

 

I apologize of confusing VI that I attached in the first post. You are right on the output as I forgot to re-wire the output to the Kalman filter block as I was simplifying my VI. The goal for this VI is basically for me to learn how to configure the matrixes correctly for the discrete kalman filter to work for a second order system.

 

Like I mentioned, I am totally new to this block and wanted to learn how to use it right before deploying to a real time target.

 

Thanks in advance.

0 Kudos
Message 3 of 7
(4,839 Views)

Hello,

 

You were nearly done with the matrices... the problem was the following: the E{v} had one extra row. Since you have only one output, that number has to be [0]. you have two numbers... To remove, just right click to the second element and go to 'data operations' and delete element. Then, if you try to run, it will say that you Matrix N is incorrect. That matrix has to have the number of states as rows and number of input as columns, which in your case is 2x1. you can just enter zero. And then, your covariance matrix has incorrect size... since you have two state, then it should be 2x2 which you can define as identity matrix.

 

Notice that, to avoid dealing with all of those matrix with zero, you can just use the function "CD Construct Noise Model" which you just need to enter Q and R matrix on your case instead of the the matrices.

 

After doing those changes, the VI should be able to run. Also, we have a very detailed manual available on your product. Just need to go to the LabVIEW directory and under the "manuals" folder, you can find the "CD_User_Manual.pdf" where we discuss all those features in detail.

 

Hope this helps.

Barp - Control, Simulation, RTT and HIL - National Instruments
Message 4 of 7
(4,817 Views)

Hi Barp,

 

Thank you for your suggestions.

 

I did according to what you suggested but it is still unable to solve the problem. Attached is the VI that I corrected based on your suggestions. I tried tweaking a few of the matrixes according to the dimension of my I/O states but still I cannot get it running right.I went through a few example like the LQG LQR, and other example in the labview, but all of them are in a first order system.

 

Sorry to disturb you again, but does NI has a second or higher order example on how to implement this simple kalman block as I just wanted to learn how to run this Kalman block before deploying the kalman or EKF block to a CRIO?

 

Thank you

0 Kudos
Message 5 of 7
(4,806 Views)
Solution
Accepted by topic author CW81

Hello,

 

The problem now is that you created matrices that are wired to the "CD Construct Noise Model". If you don't want to change, just do not wire anything. Then, if you create a Q and R matrices with Q=[0.01,0;0;0.001] and R[0.1] you should have your noise model correctly created for you. Notice that Q depends of the size of G and R depends on the size of H.

 

Also, you have to make your Initial Estimation Error Covariance" Matrix a 2x2 since you have two states.

 

Try this and see if that makes sense....

 

 

Barp - Control, Simulation, RTT and HIL - National Instruments
Message 6 of 7
(4,786 Views)

Barp,

 

Thanks a lot. I realized that the dimension of my initial estimation error coviriance was not properly set.My fault ..

 

Thanks

Message 7 of 7
(4,781 Views)