LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Build 2D array with DAQ values

Solved!
Go to solution

Need to gather data from various sources, 6 lines in total and average values over 30 seconds. So I have used a 2D array with 6 x Insert into array functions and shift registers on each to fill the array. I have used an elapsed timer to activate a case statement around this lot that clears the arrays after 30 seconds and then re-starts gathering next block of data. This does work fine, but.....

 

The question I have is that the code looks overly complicated and a mess. I have tried indexing with for loop and while loops etc but the data enters the loop and the loop only 'grabs the first lot, ignoring the rest so the array gets filled with the same value, I know this is obvious really given the rules of loops etc.

 

It feels like there is a much better way of doing this, any suggestions to a neater method?

Labview Version 8.5
Labview Version 8.6
Labview Version 2014
0 Kudos
Message 1 of 5
(3,133 Views)

It would be better if you can attach the vi.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 5
(3,131 Views)

Oops missed that, sorry...

 

Basic idea but without timer, summation etc

Labview Version 8.5
Labview Version 8.6
Labview Version 2014
0 Kudos
Message 3 of 5
(3,126 Views)
Solution
Accepted by topic author jack1

You are initializing the array with a size of 10, you really don't need it becuase you are simply inserting the new elements to the array its nothing but building the array. Since you are inserting array and then building everything again to a 2D array all the time you are duplicating the values so it will eat up the memory and you will end up in memory leakage error. What you can do is initialize a 1D array in the initialization with the number of channels and in all the iterations just replace the values with the new one, so you will always have the latest single value of all the channels. Al the same time write the array to a queue. In other place where you want to log or display the data you can read the data and also you can log it easily by reading the queue.

 

BuildArrayDAQ-1.png

 

BuildArrayDAQ.png

 

ReadDAQData-1.png

 

ReadDAQData.png

 

Edit: Sorry I forgot your 30 second average requirement. This decides how much of data you can hold in memory and also it depends on the rate at which you acquire the data. If you can give those details it would be good.

(Correct me if I am wrong)

-----

The best solution is the one you find it by yourself
0 Kudos
Message 4 of 5
(3,118 Views)

Because I can make all of the data to be logged available in just one while loop I have taken the EnQueue loop and placed it inside the main while loop where the case statement now also resides. The Enqueue loop only runs once (as per your diagram) but I have removed the Queue elements.

 

The main loop runs at 150 milliseconds and I will probably gather data for around 8 seconds, worst case would be 30 seconds which I make to be 200 points?

 

It works fine though and does look a lot neater,

 

Many thanks

 

Jack

Labview Version 8.5
Labview Version 8.6
Labview Version 2014
0 Kudos
Message 5 of 5
(3,108 Views)