LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to make 1D Array but with only one element filled in Real Time

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.

 

CDEx Predictive Observer and Controller Implementation_BD.png

 

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:

 

FP.png

 

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.

LabVIEW Enthusiast
0 Kudos
Message 1 of 14
(4,527 Views)

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

0 Kudos
Message 2 of 14
(4,495 Views)

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 ... 🙂             

LabVIEW Enthusiast
0 Kudos
Message 3 of 14
(4,456 Views)

@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).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 14
(4,443 Views)

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/

LabVIEW Enthusiast
0 Kudos
Message 5 of 14
(4,435 Views)

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.

LabVIEW Enthusiast
0 Kudos
Message 6 of 14
(4,430 Views)

@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.

0 Kudos
Message 7 of 14
(4,424 Views)

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?

 

RT - Pole Placement + Complete Observer_BD.png

 

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?

 

 

LabVIEW Enthusiast
0 Kudos
Message 8 of 14
(4,406 Views)

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.

0 Kudos
Message 9 of 14
(4,381 Views)

Easier would be a single replacement as you have in the other place, then wrap an autoindexing FOR loop around it. Much less code!

0 Kudos
Message 10 of 14
(4,368 Views)