LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

each for loop as a new array column

Hello all,

 

I am rather new to labview and I have this problem: I want to take 256 samples of data using a daqmx device. I want to do this 50 times so I will end up with 256x50 values. I take each of my 256 samples after a trigger is sent to the PFI0 channel of the daq. Therefore I send 50 triggers. So far so good. The problem is when I try each loop (each trigger) to store it to a different array-table column. In the best case I end up having each 256 set of values appended to my table. I am sure that is not complicated to achieve having a 50x256 table and for each for loop the new 256 values to be written to a new column but I am unable to find a way to do this.

 

In addition I would like to use the last row of each column to substract it from each value in the same row so I would somehow need to do some looping after having the samples. How is this done?

 

Thank you in advance for any help,

Andreas

0 Kudos
Message 1 of 17
(3,705 Views)

Andreas,

 

Measurements.PNG

 

If you need the columns/rows switch around, please use "transpose 2d-array".

 

hope this helps,

Norbert 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 17
(3,698 Views)
I added the shift register and added the build array. You may still have to transpose the 2D array to get the data into columns.
Tim
GHSP
0 Kudos
Message 3 of 17
(3,683 Views)

Norbert, thank you for your quick reply. Unfortunately what I need to do does not involve 2 loops as my 256 data sampling is aquired using the data sampling in daq. Furthermore when I put an array outside the "50 loop" it does not give me any data in the array. What am I doing wrong?

 

Please see the attached vi and make any suggestions.

 

P.S.: The table I have inside the loop displays the data but it does it by appending it in every loop not by storing it in a new column.

 

aeastet thank you for you help but the vi you posted is in labview 8.6 and I have 8.5 is there any way to open your vi with my labview as I get an error message about the versions of labview.

 

Thanks,

Andreas

Message Edited by idipous on 07-13-2009 08:17 AM
Message Edited by idipous on 07-13-2009 08:19 AM
0 Kudos
Message 4 of 17
(3,682 Views)
Here ya go for 8.5
Tim
GHSP
0 Kudos
Message 5 of 17
(3,675 Views)

Andreas,

 

the inner for loop is only to simulate your DAQmx read, which already returns an array. So please focus on the outer loop.

Implementing the way aeastet suggests works for your application, but is not recommended.

"Build array" in such way is the quick'n'dirty solution which wastes memory during execution. Since you are working with only few samples, it does not have much impact on your system. But if you have large amount of data, your system will very likly run into memory issues.

Autoindexing tunnels in for-loops have the advantage that LV knows during compilation, how much space the VI has to allocate to keep the data; so there is no need for reallocation and copying of data (waste of speed&memory).

 

hope this helps,

Norbert 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 6 of 17
(3,670 Views)

Thank you very much that was exactly what I was searching for. I would like your help with another quick thing. I need each 255 elemnt from each row to be substarcted from all previous element from the same row and all 256 results to be stored in a 1d array. How is this done. Are there any tutorials in array manipulation out there as I might need heavy work on arrays.

 

Nobert I trided to do it with the way you suggested and it says that I need a 3d array as the data is 3d. If i change the array to 3d it works but I am not sure the third dimension what is used for.

 

Thanks

Andreas

Message Edited by idipous on 07-13-2009 09:09 AM
0 Kudos
Message 7 of 17
(3,664 Views)
0 Kudos
Message 8 of 17
(3,651 Views)

Andreas,

 

i asume that simply subtraction is not what you want. Example:

23

23.5

23.3

23.3

23.4

 

An overall subtraction will result here in  -70.5. This is a value which i dare to say is worthless.

I asume that you need an average. You can propably do the averaging already after the acquisistion:

 

Averaging.PNG

 

 I think your 3d-issue is created by the way you are reading the measurements. You read multiple values in multiple channels. So you already have a 1d array for each channel resulting in 2d array for all channels. Using autoindexing increments the dimension of the array, so you get a 3d array..... 

 

hope this helps,

Norbert 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 9 of 17
(3,648 Views)

aeastet, sorry, your algorithm does not work. The resulting "array2" consists of the values contained in column 255 of the 2d-array.

The reason for this is that the inner for loop runs 256 time, so the index 256 (incremented zero based value) is the last index you are reading. This value does not exist, so nothing is subtracted.

Another thing is that the inner for loop has only an outputtunnel, so only the last written value is passed on. So you pass on index 255 (unmodified as explained) and build a new array including this value.....

 

hope this helps,

Norbert 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 10 of 17
(3,643 Views)