Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Write large spreadsheet with no delay?

Very briefly ... what I'm doing is having my NI-6031E DAQ card continuously sample four different channels at 1 kHz and populate around 30 seconds of data in its buffer (but not writing this data, at least yet). Then, at the same time, I'm sampling these four inputs at about 10 Hz and writing an average for each second (averaging these ten values per second) to a file.

Then, on occasion (eg operator sees an anomaly) a button is clicked and the 30 seconds of 1kHz data is dumped out of the card's buffer into a spreadsheet. This feature works extremely well, at least in what it outputs.

My problem, though, is that writing this large file (30,000 samples of 4 channels, plus a column for time) takes approximately 3.5 seconds.
From above, you can see that my program is still supposed to be sampling the input stream at 10 Hz and writing the average to a file. But writing this large file temporarily halts execution of my loop.

Does anybody know of any way to kick this spreadsheet writing out of the loop, or somehow have it do some fancy parallel computing to get this done? I'm limited here, I know, since I can't halt the buffer population ... basically the show must go on without delay!

Thanks for any help.

Brett
0 Kudos
Message 1 of 3
(2,243 Views)
Hi Brett,

The best solution is to create a subVI that handles the writing to file. With a subVI handling the writing process, we can assign this subVI a lower priority and have this VI run independantly with your main VI. This means, the writing process shouldn't slow down your acquisition process. There are 3 things we need to do to accomplish this:

1) Create a subVI that handles the writing process.
Since you are writing in your loop, you would have this subVI in your loop to handle this for you.

2) Have that VI run independantly from your main VI.
In this case, we don't want to wait for your subVI to return before your program continues. We want to call that subVI and have it run on its own while your main acquisition continues without waiti
ng.

3) We must select this subVI to run at a lower priority than the main VI.

I have included a couple links that discusses these topics in detail. They should get you started in the right direction. Hope that helps. Have a good day.

Using LabVIEW to Create Multithreaded Applications for Maximum Performance and Reliability
http://zone.ni.com/devzone/conceptd.nsf/webmain/D2E196C7416F373A862568690074C759?opendocument&node=DZ52066_US

How Does LabVIEW Multithreading Compare to Multithreading in LabWindows/CVI?
http://digital.ni.com/public.nsf/websearch/1FEEB6CF199AE16B862565BC006BC9AB?OpenDocument

Ron
Message 2 of 3
(2,243 Views)
Ron -

Thanks a ton for your help. I know that I'm definitely heading in the right direction, I'm now just trying to better learn about subVI's and passing data to/from them, once I've achieved this my problem appears to be solved. Thanks a ton for your help!

Brett
0 Kudos
Message 3 of 3
(2,243 Views)