06-04-2015 04:15 PM
Hi folks,
here I am with another question. I want to implement an prediction discrete state space observer which is going to run on a CRIO real time target. I am going to do it just like in the example which comes with LV.
I have some questions regarding the input and outputs which in the example those are "dummy".
My model is a SISO model, but the function "Construct SS model" returns parameters (A,B,C,D Matrices) as 2D arrays, so once you connect the cluster model into the Discrete Observer model, it takes y and u as 1D arrays despite of the fact that there is a SISO model.
I realized that the function I am using in the simulations, uses 1D arrays but with only one element filled:
Does anyone knows how to implement such 1D arrays in Real Time? I guess the way to do it is preallocating one array of zeros of size 1, and then recirculating it through some SR, and replacing the element with my real input and output, but at the dummy.vi, they are using a simple "build array"
function.
06-04-2015 10:32 PM
Take a constant and use build array. Now you have a 1 element 1-D array.
I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours
06-05-2015 08:02 AM - edited 06-05-2015 08:03 AM
But using build array, how do you prevent the array to grow indefinitely, and thus have a memory problem in the target?
P.S.: By the way, I´m also member of the Raven´s nation ... 🙂
06-05-2015 10:01 AM
@Javi-R wrote:
But using build array, how do you prevent the array to grow indefinitely, and thus have a memory problem in the target?
You have a scaler going into a Build Array with just 1 items. The array is not growing.
The only time Build Array is an issue is with loops and shift registers where the array is actually growing (ie, you are concatinating onto the array you already have).
06-05-2015 11:10 AM - edited 06-05-2015 11:14 AM
Hi crossrulz,
this would be another scenario, but suposse I have a function (which is going to be executed in a SCTL in a real-time proccessor) which one of its outputs is an array of four complex numbers, and I would want to use this parameters at any point of the execution of my program.
In that case, I would have to:
1) Initialize an array of size 4 of complex datatype
2) Feed it through a Shift Register to the SCTL
3) Inside of the loop, then took the array from the function and use replace array subset
4) then I could use that complex numbers in any other state of my machine
that procedure would be correct? Here the array won´t be growing or I am wrong...
Addendum:
I am looking at this reference document and the problem would be the shif registers
http://zone.ni.com/reference/en-XX/help/370622M-01/lvrtconcepts/avoiding_shared_resources/
06-05-2015 11:30 AM
You have a scaler going into a Build Array with just 1 items. The array is not growing.
In the reference document I post before, it says that build array introduces jitter, due to the LV memory manager, that´s not a situation I would want too.
06-05-2015 11:52 AM
@Javi-R wrote:
You have a scaler going into a Build Array with just 1 items. The array is not growing.
In the reference document I post before, it says that build array introduces jitter, due to the LV memory manager, that´s not a situation I would want too.
That only happens if you build an evergrowing array (e.g. in a shift register). In the suggestion, the final array size is fully known at compile time and there is no problem.
06-05-2015 01:30 PM - edited 06-05-2015 01:56 PM
Ok, I did it that way. But I am facing another problem right now...
At some point the Discrete Observer return a NAN array, you will see the code in the code snippet?
I get rid of that component by component, but the observer gets "stuck" in it. So my Control law is zero... but the state stimate is NAN.
Also I am attaching the VI.
I do not know why, since in the simulation program all runs well. any thoughts? Maybe the internal numeric precision of the State Space Model?
06-05-2015 04:04 PM
You don't need the indices on the Index Array. By default, they'll be 0, 1, 2, 3, ....
Replace Array subset is resizable as well, so you don't need 4 of those.
I would probably use an in place element structure for the replacement of those 4 elements.
I've never had or used the simulations toolkit, so I can't comment on how that is causing you problems.
06-05-2015 05:54 PM
Easier would be a single replacement as you have in the other place, then wrap an autoindexing FOR loop around it. Much less code!