LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing on large Arrays within an Eventstructure

Solved!
Go to solution

Hello,

I've got a for-loop within an event structure which creates a large array(~650mb) via auto-index-tunnel. In the next step I want to read this array in another event. Every approach I've tried so far copies this large array at some point.


The best I could come up with until now, is to store it in a global variable. But when Labview reads for the global variable it creates a hole copy, even though I only need a small part of this array.

 

I've attached a vi to show my basic structure.

 

Thanks

 

 

Matthias

Download All
0 Kudos
Message 1 of 8
(2,996 Views)

Matthias,

 

you are looking for a shift register....

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 8
(2,994 Views)

I thought about adding shift register to the big while-loop, too. But the "Show Buffer allocation"-Tool indicataes that the auto-index-tunnel creates an array which is then copied to the shiftregister. Or am I wrong?


0 Kudos
Message 3 of 8
(2,987 Views)
Solution
Accepted by topic author steinhagelvoll

If you do everything right, there wont be an additional copy.

 

Make it a rule of thumb: Branching a wire creates copies, as do indicators. But shift registers keep data in place.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 4 of 8
(2,982 Views)

Ok. Sounds good.

 

But when I want to get a certain element using "index array" without loosing my array I have to use branching. Does Labview copy the hole array and extract the element afterwards or does it just copy the single element?

0 Kudos
Message 5 of 8
(2,968 Views)

Since you are not going to manipulate the whole array itself, LV will not copy the array.

Depending on the code following the "index" function, the specific element is copied out of the array and the manipulation is done on that copy.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 6 of 8
(2,955 Views)

If I only use the index-array-function to access my array wouldn't the method with the global variable be equivalent? It's just a much smaller code.

 

0 Kudos
Message 7 of 8
(2,941 Views)

each instance of a Global read mandates a buffer for each. SInce LV does not know which global will be read when (due to multithreading) any time a global gets written a copy is stashed away for every global read.

 

Read this to learn about why globlas are concidered evil.

 

"Go, and sin global no more."

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 8 of 8
(2,933 Views)