LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview: How can I alter an array element directly in RAM at its ori. location?

Dear Sir or Madam,

the question I have is simple but important (and I guess it's not only important for me).

As you know Labview becomes very slow if it has to handle large arrays or large strings.

A workaround NI suggested [1] works fine on initializing a large string, but also becomes slow if you want to alter portions of that already built large string.

The soulution I am looking for is the following: Take a reference to an existing array, and overwrite the element/subarray which are to be altered directly in the RAM at their original locations with the new values - without making a temporary work copy of the entire array, and without outputting a copy of the new array. The nex
t time the user is going to read this array via a local variable, he will see the new array, which in fact is "just" the physically original array with the altered element/subarray.

This way the replacement process should be very fast and - equally important - independent of the size of the array, so that replacing just one element of a 1000 x 1000 array is exactly as fast as updating an element in a 10 x 10 array.

[2] gives you an idea of what I mean and how it could work, but for some reason the given example there ("replace.zip") works also very slow on very large arrays.

Is there a way to address array elements in a given array directly within Labview? Or do you have a CIN compiled to a Labview VI which can do this?

Thank you very much in advance for your help!

With kind regards,

Martin Sindermann
Software Development Engineer
Aachen Institute of Technology

___

Sources:

[1] http://digital.ni.com/public.nsf/3efedde4322fef19862567740067f3cc/ad91d8fe13c350
5286256c010056f2e0?OpenDocument

[2] http://sine.ni.com/apps/we/niepd_web_display.DISPLAY_EPD4?p_guid=B123AE0CBA76111EE034080020E74861&p_node=DZ52026&p_submitted=N&p_rank=&p_answer=&p_source=External
0 Kudos
Message 1 of 7
(2,725 Views)
Look at functional globals. Also called LV2 globals.
In fact a subvi with a while loop surrounding a case statement in which you can handle the data in a shiftregister so you don't have to copy it.
in each case you can have a different action on the shiftregister say replace an element, a column or even 2d subset.
greetings from the Netherlands
0 Kudos
Message 2 of 7
(2,724 Views)
> As you know Labview becomes very slow if it has to handle large arrays
> or large strings.
>

As pointed out by Albert, dealing with large strings or large arrays
doesn't have to be slow provided you let the dataflow do its job. Do
not store data into controls or globals or anything else unless it is
really needed. And in that case, you want to use shift registers when
possible. They have more restricted access and allow the LV compiler to
do a better job in reusing memory, with less protection needed.

So, for your main diagram, use shift registers, if sharing stored data,
look at using functional globals, or LV2 style globals. There was also
a Dr VI article about this on LabVIEW Zone.

Greg McKaskle
0 Kudos
Message 3 of 7
(2,724 Views)
Hi,
I've recently experienced similar problems whilst developing a labview RT application. In a control loop I needed to replace successive columns of data in a (preallocated) 2d array for data storage. The larger the array, the longer it took to replace elements.
Instead, I used a RT fifo queue to store data elements. Once the queue is full the oldest data is overwritten. When the control loop has finished the queue can be read back and a 2d array assembled. It seems significantly quicker than using the 'replace element' method, with no slowdown for larger queue/buffer sizes.
Hope this helps,
Pete C
0 Kudos
Message 4 of 7
(2,725 Views)
How exactly did you assemble a 2d array from the RT FIFO? I'm having a problem writing several 1d arrays to a file using the Write File [I16].vi. I'd like to get several array of numbers, put it into a 2d array and write to a file.
0 Kudos
Message 5 of 7
(2,702 Views)
Try using the Build Array.vi to take multiple 1-D arrays and make them into a single 2D array. Once the data is in a 2D array, you can use the Write to Spreadsheet File vi (Functions palette->File I/O) to write a 2D array to a file. If you plan to continuously stream data to file, I would break apart the Write to Spreadsheet File VI (open it up as any subVI) and use the lower level VI's instead. Then you won't be continuously opening and closing the file in a loop.

Hope this helps.

Regards,

Kristi H
National Instruments
0 Kudos
Message 6 of 7
(2,694 Views)
Kristi,

Thanks for the speedy reply. I think I got the 2D array part, but my file is being written very slowly. I'm going to post my vi and question in a new thread.
0 Kudos
Message 7 of 7
(2,687 Views)