05-13-2019 01:47 PM
Is there a better way to do this, or what I am really trying to figure out if there is a programmatic way to do this.
There are 30 items in the queue, each item is a 1D array contains 200 elements. Currently there are three channels in the program, but this code will be used in other programs with varying channels (hopefully user selectable), and it sure seems like there is a cleaner way to do this.
[img]https://live.staticflickr.com/65535/32899261117_0fe0368c4d_b.jpg[/img]
Thanks!
Solved! Go to Solution.
05-13-2019 04:08 PM - edited 05-13-2019 04:10 PM
Please embed images into the post using the given tools (camera icon in toolbar of edit window). Linking to offsite places is discouraged.
Your code does not make a lot of sense. I am sure there is a 10x easier way (At least combine the two FOR loop into one).
We cannot run pictures. Can you attach the actual VI instead? What are typical values and array sizes?
05-13-2019 04:37 PM
I am using the queue as a pre-trigger, and when the data is triggered I need all the items in the queue. I am sampling at 2KHz and read 200 samples at a time, so that is what each item in the queue is. When I get the items from the queue, they are 1D arrays, and the final data structure I need is a 3*2000 array. The array from the queue looks like this:
Channel 1 200 samples
Channel 2 200 samples
Channel 3 200 samples
Channel 1 Next 200 samples
Channel 2 Next 200 samples
Channel 3 Next 200 samples
I have tried reshaping the array several different ways, but I can't get it to where all of channel 1 data is in the first row, channel 2 is in the second row and so on. I wrote a simulated VI so you can understand what I am trying to do.
05-13-2019 04:44 PM
Can you guarantee that all arrays have the same length and that the number of rows is divisible by the number of channels? Is the number of channels variable or constant?
05-13-2019 05:06 PM
Here's one quick alternative. Seems simpler. Same result.
(That said, the overall code does not feel right, with the queue filling up to 30 elements and you never actually remove anything from the queue. I am sure there is a better way overall, but I don't know the rest of your code)
05-13-2019 05:50 PM
Yes, all the arrays will have the same length as they are coming from DAQmx and I have specified the number of samples to read (200). The number of channels will be constant in each program.
The sample VI I attached does nothing with the queued data, the real program is different.
05-28-2019 12:54 PM - edited 05-28-2019 01:01 PM
@altenbach wrote:
Here's one quick alternative. Seems simpler. Same result.
...
(That said, the overall code does not feel right, with the queue filling up to 30 elements and you never actually remove anything from the queue. I am sure there is a better way overall, but I don't know the rest of your code)
Back from NI week and looking at this again and I came up with a programmatic way to do this. I changed the numbe of channels of 5 to check that the solution I came up with worked for a different number of channels! Thanks for the help Altenbach!