06-20-2012 01:35 AM
Hi everybody,
my question is about a VI which aquires data from a DAQ-device and writes it to as "spreadsheet file" for interpretation later in Excel.
In a "while loop", every 100 ms the data should be logged. Please have a look to the attatched block diagramm.
The problem: I think it is very insufficient because every time we log data, the spreadsheet file must be opened, data must be written and the file must be closed...
Is there a way to "buffer" the data and write all data after aquisition? What is the common way to accelerate that? Any idea?
Thanx to all!!
Markus
06-20-2012 02:37 AM
I would advice you to look into the programming architecture of Producer Consumer, see http://www.ni.com/white-paper/3023/en.
You can use the shown loop to generate data every 100 ms and send this by a queue to a second loop which is saving the data. Hereby you seperate the data acquisition and storage, such that if the data storage turns out to slow down, your acquisition remains running reliably. The queue is than acting as the buffer you mentioned.
06-20-2012 05:26 AM
1. Dont open and close the file ref. keep the ref and use the same in between writes (place the open/close outside the main loop and send it through a shift register)
2. Gather all data to an array and save all at once afterwards. If it's not too long gathering time it's a good and common solution.
3. Middle of the road: Gather data in an AE in one loop, have another save to file and empty array every second.
4. Prettier solution of 3 is sending the data as queue in a producer/consumer and have the consumer write at it's own leasure.
/Y