07-06-2014 04:13 PM
attached is the code.
07-06-2014 04:14 PM
attached is the code!
07-06-2014 05:50 PM
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
07-06-2014 05:56 PM
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?
07-06-2014 06:02 PM
Text files are slow. Look into TDMS.
Lynn
07-06-2014 08:14 PM
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
07-06-2014 08:29 PM
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
07-06-2014 08:41 PM - edited 07-06-2014 08:42 PM
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 😞
07-07-2014 08:03 AM
This topic was already being discussed here: No data is saved in queue, labview FPGA/Realtime
07-09-2014 11:23 PM
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-