10-26-2012 06:51 AM
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
Solved! Go to Solution.
10-26-2012 07:03 AM
Matthias,
you are looking for a shift register....
Norbert
10-26-2012 07:40 AM
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?
10-26-2012 07:47 AM
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
10-26-2012 08:40 AM - edited 10-26-2012 08:42 AM
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?
10-26-2012 09:19 AM
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
10-26-2012 10:24 AM
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.
10-26-2012 10:59 AM
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