From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Input for CD Linear Simulation.vi in a Simulation Loop

Hi I'm new to LabView and I was trying to implement a real time estimator for a linear system, so a steady
state gain is acceptable (estimator doesn't need to be adaptive). It will be
implemented in real time target (cDAQ). The estimator will get the acquired
data (there are 2 inputs and 1 output) from the real system.
 
 I have learned and tried few different ways to do it but finally decided to try using CD State
Estimator.vi (standalone) in a Simulation Loop. My questions are:
 1. I found that the only way to use the estimator model with the acquired input is by
using CD Linear Simulation.vi. Is there another alternative to do the
estimation?
 2. However, with CD Linear Simulation.vi I had problem: According
to the LabView help, if the input signals are more than 1, we have to specify
the input as 2D array with smaller dimension as the number of channels and the
larger dimension as number of points in each channel.
 While for every execution in the loop I will get only 2 x 1 data (see appended array 3 in the
attached example file). How can I be able to use the measured data as the two
inputs for the CD Linear Simulation.vi?
 
 Thank you.
 

0 Kudos
Message 1 of 6
(2,921 Views)

1. I searched the example finder and found a couple of example VIs that may be useful to you: "CDEx Compensator with Estimator" and "CDEx Continuous Observer". While you may not be able to use these VIs exactly, you may find parts of them useful. These may or may not answer your first question.

 

2. The "CDEx Nonlinear and Linear Simulation" example initializes arrays with a constant value to avoid this issue. However, the CD Linear Simulation VI isn't used in a loop.

 

I'd like to help you out further, but. since I'm not a control systems expert by any means, would you mind specifying what exactly you're trying to accomplish?

 

Mike

0 Kudos
Message 2 of 6
(2,885 Views)

Hi Mike,

Thanks for the reply.

 

I browsed through some examples and tried some things; here are the updates, maybe useful for others in the future.

 

About the CD Linear Simulation.vi; In the example finder I found CDEx Kalman Filter.vi which uses CD Linear Simulation.vi to compare the estimation with real system states for two inputs.  The number of samples of the inputs was given as a constant (e.g. N samples), from which the array of N x 2 data is built and fed to CD Linear Simulation.vi. So up to now I can’t see a way of using CD Linear Simulation for feeding input to the estimator model built from CD State Estimator.vi in a “real time “ way.

I look forward to hearing from anyone if it can be done.

 

So, from here I tried another alternative to implement this real time estimator: using Discrete State Space Function. So I generate the estimator state space model in Mathscript and feed it to that function.

 

I use kalman (mathscript) function to generate the estimator model.

 

Interesting thing is, (although irrelevant with my original enquiry), that this kalman command seems not generate correct estimator model with multiple input (e.g. if in the original system there are inputs u1 and u2 with one output y, I expect the generated estimator model would have three inputs i.e. u1, u2, and y. But the generated estimator only has one input (??)).

I remember that the kalman command from Matlab has the same problem which I neglected at that time.

So this time in labView I also did the same thing as the last time, which is taking the gain generated from the same kalman command and build manually the A and B matrices of the estimator.

 

I haven't browsed though to see if someone has used this kalman command for multi input system and noticed this. 

Nevertheless, this alternative seems working well so hopefully it works well too with the RT target.

 

Thanks.

 

0 Kudos
Message 3 of 6
(2,863 Views)

I don't know how helpful I was, but I'm glad to hear that you were able to arrange your code in a satisfactory manner. And, thank you for taking the time to make a second post to document your outcome!

 

Please continue creating new threads/ adding to others as you have more questions and/or you have more experience to share.

 

Mike

0 Kudos
Message 4 of 6
(2,828 Views)

Hi Mike,

Your reply did help me. As trivial as it seems, it got me to see again the examples (which I already did previously) and converge them to only the relevant ones. And as it was my first post as a newbie (just been learning LV for 3 weeks), it's nice to see reply to the question 🙂

 

I posted another question in the forum by the way.

 

Thanks.

 

Cheers,

 

Tian

 

 

0 Kudos
Message 5 of 6
(2,801 Views)

Glad to hear I could help! I made a quick comment on your other post as well.

 

Mike

0 Kudos
Message 6 of 6
(2,772 Views)