LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how can I append some data to an array via a case structure?

Basically i want to do the following thing:

do
{
if control=0
else
Data=Data append data1
end if
}while(run=1)

We try to avoid local variable since the size of Data is pretty big. I am pretty sure i can add a shift register in a loop structure.But is it possible to add a shift register in a case structure?

Thank you!
0 Kudos
Message 1 of 6
(3,197 Views)
> is it possible to add a shift register in a case structure?

No, but then there is no need to. The shift register just wires the data back to the next iteration of the loop. Case structures are not loops.

But, to answer your question, simply wire the array into the case structure. In the True case, wire this directly to the output pin without changes. In the False case, wire this input array to the append function, and wire the output of the append to the output pin of the case. This case structure then fits inside your while loop (which has the shift register on the array.)


Les Hammer
Complete Test
0 Kudos
Message 2 of 6
(3,188 Views)
If you know the final size of the array, it's even better to initialize the array before entering the loop, for instance with NaN values, and to use a Replace array subset function, instead of a simple append.

CC
Chilly Charly    (aka CC)
Message 3 of 6
(3,177 Views)
> If you know the final size of the array, it's even better to initialize the array before entering the loop...

If you don't know the final size, but you know a maximum, init the array to the maximum, do the substitution (keeping an item_number counter), then get an array subset at the end to trim it down.

-- Les
0 Kudos
Message 4 of 6
(3,161 Views)
hi guys, thanks for your help!

I tried what you said. it works. but one new problem occurs. The speed!

every 30ms, we generate a new array with size of 1K*33. We need to append it to the data array. At first, the program works well, but after several seconds, appending procedure takes a lot of time (100-150ms). how can we reduce the consuming time since we are doing real time stuffs?

Thanks a lot!
0 Kudos
Message 5 of 6
(3,146 Views)
The best you will be able to do is going to be a variation on what CC suggested regarding replacing array sub-sets.

If you do not know how big it will end up then over-allocate but still use the replace array subset.

The delays you are seeing are due to the memory buffers groing and additional memory need allocated as the array grows. The Replace array subset function operates inplace and re-uses the buffer it is passed. There is no clear KB regarding which array operations operate inplace and which do not.

http://forums.ni.com/ni/board/message?board.id=170&message.id=74847&requireLogin=False

Under Tools >>> Advanced >>> Show buffer allocations will show you where buffers are being allocated (LV 7.1).

If you post a zip or llb of you code I am sure someone will have more to add.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 6 of 6
(3,141 Views)