LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to select two specific amount of data alternately from a large 1D Array?

Solved!
Go to solution

Hi Guys, 

I have a 1D array with 100,000 row. I need to get data in the following order. 

 

96 byte voltage and current

32 byte address data

96 byte voltage and current

32 byte address data

96 byte voltage and current

32 byte address data

until the end of the data in the 1D array. 

I need to put each 96 byte data and 32 byte data in two specific 1D array that I have to process later. 

I used a while loop but it does not give me correct result and I am not sure were to connect the resultant two output array. 

Moreover the boolean selector pin in the attached VI should also be operated automatically depending on the count number of each 96 and 32 number

96+32+96+32.... and so on. 

Hk637_0-1734546746307.pngHk637_1-1734546781324.png

 





0 Kudos
Message 1 of 11
(245 Views)

Hi Hk,

 


@Hk637 wrote:

I have a 1D array with 100,000 row.


A 1D array only has elements, it doesn't have rows or columns…

 


@Hk637 wrote:

I need to get data in the following order. 

 

96 byte voltage and current

32 byte address data


  1. Place a FOR loop, with N set to ArraySize modulo 128 (=96+32).
  2. In the loop use ArraySubset to get 128 bytes at index "i"*128.
  3. Use SplitArray to split those 128 bytes into 96 and 32 bytes.
  4. Output both arrays at an output tunnel.

So you will receive two 2D arrays, one with rows of "voltage and current" and the other with rows of "address data"…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 11
(223 Views)

Well for starters, the lower input on your "array subset" is wrong.

 

It's a "length" value, not a "end of selection" value.  So you should be just using a constant 96 or 32 there, not i+96 or i+32.

 

Also, your input array is of type I16.  That's two bytes for each.  Did you maybe want that to be an I8 or U8, or are these actually two bytes?

 

This is what I would suggest, if I have understood your problem right:

Kyle97330_0-1734549393780.png

 

Message 3 of 11
(221 Views)

Thanks.

I implemented but I guess the Vi only give one chunk of 96 and 32 byte set of data from the total 14,319 data set (Array Size (Size=1,832,962) / 128 = 14319) 

 

Hk637_0-1734618726374.png


How about the remanining data set ? Although the for loop iterate for 14319 times, it only gives me one chunk of 96 and 32 byte of data. 

To include rest of the data set I try to use another "for loop" and case structure. But I am not sure how to include all 1,832,962 set of data into 96 and 32 byte data chunk one after another until there is no data left dynamically. 

Hk637_1-1734618886212.png

 

Download All
0 Kudos
Message 4 of 11
(57 Views)

Thanks. 

 

I implemented but the VI gives only one chunk of 96 and 32 set of data out of 14,319 iteration.

Array size (1,832,962) / 128 = 14,319. I need to get all the data in 96 set then 32 set serially until there is no data left. 

I tried the following but not sure how to get the array with all 96 chunk and 32 chunk from the  remaining data set.

Thanks in advance for the reply. 

Hk637_0-1734619809997.png

 

Download All
0 Kudos
Message 5 of 11
(147 Views)

Hi hk,

 


@Hk637 wrote:

I implemented but the VI gives only one chunk of 96 and 32 set of data out of 14,319 iteration


Is it so hard to follow my suggestion?

To keep the "remaining bytes" you just need to use the remainder of the modulo function to know how many bytes will remain at the end of the input array…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 11
(135 Views)

@GerdW wrote:

Hi hk,

 


@Hk637 wrote:

I implemented but the VI gives only one chunk of 96 and 32 set of data out of 14,319 iteration


Is it so hard to follow my suggestion?

To keep the "remaining bytes" you just need to use the remainder of the modulo function to know how many bytes will remain at the end of the input array…


Since the OP apparently wants the output as two 1D arrays, this can be fixed my making the two output tunnels concatenating.

0 Kudos
Message 7 of 11
(121 Views)

Sometimes you don't even need a loop....

 

altenbach_0-1734629320350.png

 

Message 8 of 11
(110 Views)

Can you please attach the VI? 

 

Thanks in advance. 

0 Kudos
Message 9 of 11
(106 Views)

Sorry, it might be a smiple fix but actually I fear that I am not getting all the data from the 2D array into the 1D array in the following order

2D array 

1    2   3    4  5 
6    7   8    9  10
11 12 13 14  15

1D array = 1 2 3 4 5 6 7 8 9 10 11 12 13 14  15


I tried to do the following but out of the total total number of data, I am getting only 1st 95 data properly and rest of them are zero:

Hk637_0-1734635294618.png
I would really appreciate if someone point me in the right direction with possibly with example VI.

 

0 Kudos
Message 10 of 11
(88 Views)