LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

What is the best way to write 10 channels of data each sampled at 4kHz to file?

Hi DF Gray,

 

Nice to hear from you again... You provided me with considerable support late last year developing the previously attached TMS. vi using multiple loops (1 producer and multiple consumers)and queues to the pass data with no dependencies... (I'm still working at the queued state machine design for this project, which you suggested)...

 

So, you think that TDMS is not essential? And that the "Write measurement to file.vi" OR the low-level open, write, close functions would be ok for writing these data to file?... My only concern is loosing data points due to having too much data being acquired too quickly (buffer filling?) for writing to file...

 

Regards,

Jack

0 Kudos
Message 11 of 14
(653 Views)

At 40kS/s, you do not need to use TDMS.  You can use just about anything and it should be able to keep up. Given your architecture, you will not lose data unless you have a power failure.  A queue is a lossless transfer mechanism.  Your biggest issue would be if the write cannot keep up, leading to constantly increasing memory use.  The LVM write you have used may not be able to.  I would probably open the file and write a header before the loop, then write only data in the loop.  For ASCII writes, you can use the spreadsheet to string functions in the string palette to format your data.  For binary or TDMS, just write it.  Close the file after the loop ends.

 

If you want to monitor whether or not your queue is keeping up, you can check the queue status on each file write to see if the queue size is steadily increasing.

 

Good luck and keep learning.  You will be getting your CLA before you know it.

0 Kudos
Message 12 of 14
(639 Views)

Hi DFGary,

 

Thanks for the clarification... My main concern with using the LVM write was the buffering and difficultly keeping up with the write (hence loosing data points because the buffer has filled; especially for longer writes)..

 

I have tried writing data using the open/create/append function and close function outside of the main loop.... My issue with using this approach here is I would need to stop the VI every time I wanted to close the file.... Preferrably, I want to keep the VI running so that can continously view the charts, and use a button to start and stop data the write to file as needed... Not sure how I can do this?

 

Would a sub while loop work; so that the header etc is written in the main loop, the write occurs when the sub while loop runs, the file close occurs when the sub loop is stopped?

 

Regards,

Jack

0 Kudos
Message 13 of 14
(620 Views)

The easiest way to solve your problem is to change the queue data you send to the write file loop.  Use a cluster containing a command and the data instead of just the data.  The generic form of this uses an enum for the command and a variant for the data, but in your case, and enum and array would probably work better.  The enum would have elements for start, stop, write, pause, exit, ...  In all cases but the write, the data would be an empty array.  Your write loop would then sprout a case structure to handle the different commands.  You could them fairly easily handle all sorts of file operations (e.g. start a new file when the old one gets too big, create a series of numbered files).

 

BONUS - use classes and the command pattern instead of a cluster with enum and data.

0 Kudos
Message 14 of 14
(611 Views)