LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Circular reading a subset from a big array

Hi
I have a big array (60 000 x 32) that I read from a file and I then use in a loop the Array Subset tool to extract the 100x32 (line 1 to 100) first elements. During the next iteration of the loop, I get line 101 to 200 and so on. That part works perfectly. But what I want is that when I get to the 59900 to 60000 lines (iteration 600), the loop continue (without stopping) with lines 1 to 100 (iteration 601). I want that process to go on at lest 200 times (circular array)

I tried doing it using a local variable x and a case box, but I guess I don't really understand how to write this in labview. I never used local or global variables in labview. The code would (in another language) be :
If x>600, then x = 1, else x remain unchanged in each loop, with also x=x+1 in each loop. An example of how to do this would be very appreciated.

I also tough of using the original matrix (60 000 x 32) and merging it a very high number(200) of time with itself, but the resultant matrix would be too large.

Also, since I use these loop to write these values in the buffer of a analog output DAQ card, the creation of this array subset must be very quick.

So, if someone know a good way I can do this, please help me.
Thanks in advance.
Jocelyn
0 Kudos
Message 1 of 5
(3,038 Views)
Just use qotient and remainder, see attached (LabVIEW 7.0).
0 Kudos
Message 2 of 5
(3,027 Views)
First of all, stop thinking in terms of "lines 1 thru 100". All LabVIEW arrays are indexed starting at zero. Always. Every time. No exceptions. Period.

That actually makes things easy.

You MIGHT be able to reshape your array, so that it really is a 1-D array (1800000 x 1), but that would cost you some memory usage. So forget that.

Consider what you want: Your index #0 goes 0, 100, 200, 300, ... 59900, and then 0, 100, 200, 300... 59900 again, while your index #1 goes 0,0,0,0,... 0, and then 1, 1, 1, 1, ... 1, etc., etc.

That is a perfect place to use the MODULUS function (implemented by the QUOTIENT and REMAINDER function in the ARITHMETIC palette).

1... Use a constant of 100 (your segment size). 2... Multiply "i" (your loop iteration number) by this constant. 3... Wire that result into the top input of the Q&R, and wire a 60000 (your dimension size) into the bottom. 4... Use the REMAINDER output as your starting index (it will be 0, 100, 200, 300, ... 59900, 0, 100, 200, 300, ... 59900...) 5... Use the QUOTIENT output as your second index (it will be 0, 1, 2, 3...)

You'll have to decide when you're done by how many elements you actually have.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 3 of 5
(3,024 Views)
Gary Johnson's book, "LabVIEW Graphical Programming," had a section on circular buffers. I think he used the LV2 style global with some extra inputs for read and write markers. If you are interested, I can dig around to see if I can find a copy (the book was published in 1994).

Lynn
0 Kudos
Message 4 of 5
(3,002 Views)

Thanks you all for the fast answers. I totaly forgot about the modulo function...Opps  That is exactly what I needed. Thanks again.

Jocelyn

0 Kudos
Message 5 of 5
(2,999 Views)