LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

saving data from while loop

Is there an effective way to do this? I'm using the write to spreadsheet subVI. The application is a high speed DAQ card taking data at about 20kS/s. I'm using a producer/consumer pattern, the producer loop acquires the data and the consumer loop does some calculations and plots the data. The problem is, when I used a local variable (in the form of an array) and kept inserting data to the end of the array, my code was extremely slow. I tried using a queue, enqued the elements without dequeing and then flusing the queue when I was ready to save. The flush queue left out large chunks of data. Can I put the write to spreadsheet subVI directly into the producer or consumer loop and use append? Hmm, I will try this now, but any suggestions for better ways of doing this would be greatly appreciated.
Thanks
Tim
0 Kudos
Message 1 of 5
(2,626 Views)
Hi,  putting the write to spreadsheet in the producer loop will slow things down.  The local variable slowed things down because it forced a switch to the front panel thread.  Using the queue is the way to go here.  Have you tried dequeueing one element at a time, and writing each element to spreadsheet as it comes off?  I think this would make the best use of the Producer/Consumer architecture.  You just have to be sure that your queue will not fill up, once it is full you will no longer be able to add elements to it.
0 Kudos
Message 2 of 5
(2,625 Views)
Awesome, I will give that a try. I never really thought to write to spreadsheet while taking data at the same time, I had all the data stored somewhere before writing. Is the write to spreadsheet subVI reentrant?

Thanks for the help.
0 Kudos
Message 3 of 5
(2,618 Views)

Why do you want it to be re-entrant?  Are you planning to write to multiple files in parallel?

R

0 Kudos
Message 4 of 5
(2,613 Views)
Yup, I am collecting data from two devices and would like these to go to different files.
0 Kudos
Message 5 of 5
(2,591 Views)