03-26-2013 06:06 AM
Hello all,
My aim is to simulate a discrete state-space model is the cRIO FPGA (in order to use an observer).
I am currently trying to simulate it on my computer without using the discrete state-space VI from the Control Design and Simulation toolbox (because there is not state-space model VI for the FPGA). However my discrete state-space model representation does not work.
There is below the continuous state-space model:
Then I obtained the discretized model (using the zero-order-hold and t=0.01s):
Below is the discretized state-space model I designed (in order to design a similar model in the FPGA):
Here is the discrete state-space VI I'm using to compare the results:
The graph plots the state X1, which is infinitely increasing. However it should look like a first order, as you can see:
I understand why the state X1 is increasing like this, I know I'm missing something (integration saturation ?).
Thanks in advance
Regards!
PS: Does somebody know if implenting other controller than the PID is doable in the cRIO FPGA? I also asking myself about matrix inversion if I want to use the Kalman gain in my observer.
PS2: I apologize for my disorganized/unclear Labview files, I'm beginning with it.
Solved! Go to Solution.
03-26-2013 09:31 AM
Hi,
I think the problem might be caused by rounding errors in your A and B matrices. Have you tried getting it to display the values with greater precision?
Matlab calculates those values as: A = [0.995, 0.009925; 0 0.99], B = [2.488e-5; 0.004975]
Regards,
Ian
03-26-2013 09:37 AM
Hi,
thanks a lot, it's working very well.
Could you tell me what function did you use with Matlab ?
Regards
03-26-2013 09:44 AM
Hi,
I'm glad that helped. I used:
G = ss([-0.5, 1; 0 -1], [0;0.5], [0 0], 0);
c2d(G, 0.01)
(from the Control System Toolbox)
Regards,
Ian
03-26-2013 10:14 AM
In fact I was reading A and B matrixes through the front panel of the 'CD Convert Continuous to Discret' VI and the display format had just 2 digit of precision... (Shame on me!)
Thanks for your help
Regards