LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Better Array Manipulation?

Hi everyone.

I'm trying to stream some data directly to arrays in memory (instead of the
disk), and I was wondering if anyone had come upon an efficient way to do
so. My problem is that:
1. I have relatively high data rates (multiple channels at around 20kHz)
and it's not efficient to use the Build Array element to tack on data to my
buffer array (Since Build Array allocates a new memory buffer everytime).

2. I could preallocate my memory needs using Initialize Array, but then I
can't get my new data into the array fast enough using Replace Array Element
because this requires me to replace memory element by element (i.e. if my
data acquisition reads in100 bytes at a time, then I have to use a for loop
to get these 100 bytes in
to my array)

I could be mistaken in my use of Replace Array Element, however. Ideally
has anyone written any Win32 native code to replace sections of Labview
arrays quickly, or provide fast dynamic memory allocation? I'm using
LabView 5.0.

Any help or pointers would be invaluable...

Virantha
0 Kudos
Message 1 of 3
(5,298 Views)
> I'm trying to stream some data directly to arrays in memory (instead of the
> disk), and I was wondering if anyone had come upon an efficient way to do
> so. My problem is that:
> 1. I have relatively high data rates (multiple channels at around 20kHz)
> and it's not efficient to use the Build Array element to tack on data to my
> buffer array (Since Build Array allocates a new memory buffer everytime).
>
> 2. I could preallocate my memory needs using Initialize Array, but then I
> can't get my new data into the array fast enough using Replace Array Element
> because this requires me to replace memory element by element (i.e. if my
> data acquisition reads in100 bytes at a time, then I have to use a for loop
> to get these 100 bytes into my array)
>
> I could be m
istaken in my use of Replace Array Element, however. Ideally
> has anyone written any Win32 native code to replace sections of Labview
> arrays quickly, or provide fast dynamic memory allocation? I'm using
> LabView 5.0.
>

If you are using buffered I/O, it won't matter as much how much time replace
array takes, and it doesn't take that long either. To best use the double
buffering, read the available elements, rather than a fixed amount. This
will help to balance the time spent storing with the time to acquire the
next points.

Another approach is to put off the consolidation of the arrays until the
DAQ is completed. Collect the DAQ arrays into an array of cluster of arrays.
The replace or build array will only be happening on a small array at this
point and is much like assigning pointers. When the arrays need to be
consolidated, you can use either technique mentioned above.

Greg McKaskle
0 Kudos
Message 2 of 3
(5,298 Views)
>> I'm trying to stream some data directly to arrays in memory (instead of the
>> disk), and I was wondering if anyone had come upon an efficient way to do
>> so. My problem is that:
>> 1. I have relatively high data rates (multiple channels at around 20kHz)
>> and it's not efficient to use the Build Array element to tack on data to my
>> buffer array (Since Build Array allocates a new memory buffer everytime).
>> 2. I could preallocate my memory needs using Initialize Array, ...

In <378D450C.CE250D39@austin.rr.com> Greg McKaskle writes:
>If you are using buffered I/O, it won't matter as much how much time replace
>array takes, and it doesn't take that long either.
^^^^^^^^^^^^^^^^^^^^^^^^^
I _think_ that's because when you pre-allocate storage for the
shift-register in your loop, that storage isn't truncated (released)
until you exit the loop even if you call Build Array within the loop.
That's the idea behind preallocating a shift register. Someone correct
me if I'm wrong.

>Another approach is to put off the consolidation of the arrays until the
>DAQ is completed.

If you're using National's DAQ drivers, you can even pre-allocate an
intermediate buffer for your A/D data. Data in the driver's buffer
is stored in U16 format, so it's more memory efficient than storing
it in the LabView application. There are two modes:

1) Allocate an intermediate buffer for the entire dataset. You can
still use indexes to move back an fourth within this data array. And
you can start reading the array from where you left off or from
any intermediate point.

In one application, I actually read this buffer twice. Once in
small blocks for displaying the data as it was collected (in
semi-real-time) and a second time in very large blocks for heavy
numerical processing. If you're doing this, one loop should be
inside the other so you don't mix up the pointers into this
"file" buffer. If you want to want to have _separate_ file buffer
pointers on the READ vi, that's okay too, but then you need to
declare that READ vi as "reentrant" so separate data spaces for
each instance of these READ vi's is established for independant
file pointers.

2) Allocate a ring buffer smaller than the entire dataset, then let
let LabView read out of this ring as the A/D hardware writes into
it. The catch here is that the size of the ring buffer must be
large enough so the A/D hardware doesn't overwrite it if LabView
gets too far behind.

If you really have a lot of data, then it many be best to write it
directly out to disk as it's collected and let the disk's driver
worry about concatenating it altogether (prehaps with LabView doing
some preprocessing on it). But this is a last resort. It also
requires a SCSI disk to be fast. An EIDE disk will suck up all the
CPU time from LabView causing it to be slow. Get the biggest Ultra-2
or Ultra-3 SCSI drive and controller you can buy and be sure not to
mix Ultra SCSI drive types on the same controller or it will demote
the controller's speed to your slowest SCSI device.
--
/\ Mark M Mehl, alias Superticker (Supertickler to some)
<><> Internet: mehl@IAstate.edu
\/ Preferred UUCP: uunet!iastate.edu!mehl
Disclaimer: You got to be kidding; who would want to claim anything I said?
0 Kudos
Message 3 of 3
(5,298 Views)