LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

flushing element in queue

Solved!
Go to solution

attached is the code. 

0 Kudos
Message 11 of 23
(1,986 Views)

attached is the code!

Download All
0 Kudos
Message 12 of 23
(1,986 Views)

I do not have the FPGA stuff.

 

The consumer loop does not contain any thing out of the ordinary.  The Array to Spreadsheet String only takes a few milliseconds to run with a 1000 x 4 array of DBL which is what it appears that you are feeding it.  Each string is 44000 characters (or larger if minus signs appear).  The file Write could slow down as the file grows due to the OS re-allocating space for the file or fragmenting it as it grows.

 

On the other hand if you are doing that 50 times per second you may have timing issues, especially with the file write.  I ran a little test with the array to string and file write code. It runs 50 iterations (about 1 second of data in your system) in about 150 ms.  I did not do any testing to see what happens as the file size grows.

 

Lynn

0 Kudos
Message 13 of 23
(1,972 Views)

Thanks Lynn for the testing the code. I think this is the file write that slows down the process. Is there any other method for saving data faster?

0 Kudos
Message 14 of 23
(1,968 Views)
Solution
Accepted by topic author far_nia

Text files are slow. Look into TDMS.

 

Lynn

Message 15 of 23
(1,965 Views)

To Have Your Cake and Eat It Too, you need to use two Queue functions.  As you already seen, Flush does not return an array of all of the elements.  However, Get Status can return such an array.  So if you want to do both, i.e. get the Queue elements in an array + empty the contents, do a Status (and ask for all the elements) followed by a Flush.

 

I've used this property of Status to make a convenient "Average the last N elements" VI.  Create an N-element Queue.  As new elements come in, add them to the Queue using Enqueue Lossy.  This ensures that the Queue holds the last N elements (once it gets filled).  Now use the Status command to get all the elements as an Array, do an Array Sum, and divide by the size of the Array (or use the Mean function).  

 

BS

0 Kudos
Message 16 of 23
(1,950 Views)

Bob,

 

I didn't get the idea. could you please post a small sample to represent the idea. 

 

I attached a figure based on your idea, but don't know how to get the all the array from get status block

0 Kudos
Message 17 of 23
(1,942 Views)

Lynn,

 

TDMS is faster but you can have up to 1048576 elements, and it is full after that. with my sampling frequency (51.2 KS) and having 4 channels (12800 samples/sec/ch), it takes only 82 sec to fill the whole TDMS file and losing data after that 😞

0 Kudos
Message 18 of 23
(1,937 Views)

This topic was already being discussed here: No data is saved in queue, labview FPGA/Realtime


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 19 of 23
(1,909 Views)

I will correct my last comment, TDMS is really faster than other txt writing methods (there is no need to change the data into strings which takes time and slows the  logging process), the limited cells in excel is not an issue, it is the excell that has limited cells and doesn't mean that the number of data in tdms cannot be more than 1048576  elements. 

 

I am putting this link for anyone that has the same problem as mine for converting tdms file into readable data in matlab, the simple code easily make the tdms file readable in matlab for further processing of signal.

 

http://www.mathworks.cn/matlabcentral/fileexchange/28771-converttdms--v9-

 

0 Kudos
Message 20 of 23
(1,850 Views)