LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Add waveform and array

While looking at this thread, I discovered an undocumented "feature" of LV which can cause severe performace problems with modest sized arrays and waveforms.

 

In the original thread an attempt was made to remove the DC component from a waveform by subtracting  an array (rather than a scalar). Both the Y array in the waveform and the array of DC components were the same size with less than 15000 elements. Attempting to run that part of that VI resulted in severe slow down of not only LV but the OS and everything else running on the computer because it was paging data to/from disk.  The only thing wired to the output of Subtract was a graph.

 

The result of subtracting an array of numerics from a waveform is an array of waveforms having the same number of elements as the array of numerics. The size of the Y array in the waveform does not seem to matter. The attached VI has the array of numerics and the Y array of the waveform the same size.

 

The same thing happens with Add.

 

The Detailed Help for Add and Subtract do not mention this combination. The example linked on those help pages also does not show this combination.

 

The Profiler gives this data for the attached VI:

Samples Bytes

10               15 kB

100           295 kB

1000          24 MB

2000          97 MB

3000        217 MB

4000        385 MB

5000        602 MB

6000        866 MB

7000      1178 MB

8000      1538 MB

 

At 7000 samples I start to hear the disk drive while the VI runs and at 8000 the disk is very busy.

 

After some thought I decided that this is not a bug, but because of the way the data size explodes, it should be documented.

 

Clearly this is not a common use case, but I could see someone trying to do baseline correction on data from an instrument this way, as that is essentially what the thread linked above was trying to do.

 

Output configuration is not available after a waveform is wired, probably because of the polymorphic VI used for waveforms. An output configuration option to create a single waveform with element by element addition/subtraction might be useful.

 

Lynn

0 Kudos
Message 1 of 5
(2,850 Views)

Wow, that is kind of weird.  The way I see it, when you subtract a waveform and a numeric array, the subtraction should just be done on the Y component of the waveform.  So you should still just have a single waveform out.  So by subtracting a waveform with an array of numerics, it should act the same as if you extracted the Y, did the subtraction, and put the Y back in.  This could lead to a shortened size of Y, but I see no reason why you should get an array of waveforms out.

 

But after running your VI, I guess I can see what LabVIEW is doing.  It is as if you used a FOR loop with just the numeric array autoindexed and then you autoindex the output waveform.

 

I can see the intent, but it just doesn't sit right with me.


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 2 of 5
(2,845 Views)

That is the way I felt when I first saw it.  I would have expected a single waveform with array subtraction just as you did.

 

I can live with it, but would like to know what it expected and why.

 

Lynn

0 Kudos
Message 3 of 5
(2,839 Views)

If subtracting an array from the Waveform (for some reason) isn't "legal", what does seem to work is to "unbundle" the Y data with Get Waveform Components, do the subtraction, then re-assemble with Build Waveform bringing the original Waveform in on the Waveform Input.  I just found that there's even the simpler In-Place Element Unbundle/Bundle Waveform function that I bet will be (a) very fast and (b) do what you want.

 

Bob Schor

0 Kudos
Message 4 of 5
(2,827 Views)

@Bob_Schor wrote:

I just found that there's even the simpler In-Place Element Unbundle/Bundle Waveform function that I bet will be (a) very fast and (b) do what you want.


Which is what I have been doing for a while now when manipulating waveform data.  It forces the inplaceness, which helps the speed.


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 5 of 5
(2,816 Views)