07-13-2009 06:30 AM
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
07-13-2009 06:57 AM
Andreas,
If you need the columns/rows switch around, please use "transpose 2d-array".
hope this helps,
Norbert
07-13-2009 08:15 AM
07-13-2009 08:16 AM - edited 07-13-2009 08:19 AM
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
07-13-2009 08:26 AM
07-13-2009 08:35 AM
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
07-13-2009 09:00 AM - edited 07-13-2009 09:09 AM
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
07-13-2009 09:13 AM
07-13-2009 09:17 AM
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:
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
07-13-2009 09:26 AM
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