LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

moving array to spreadsheet string out of loop to speed up program

Solved!
Go to solution

I'm working on a program that has to save about 1200 numbers of data to a spreadsheet file many times per second (the more the better). Right now, it reads all the data points, puts all the data into a 1-d array of dbl, converts the array to a spreadsheet string, and appends the data to the output file, all inside the loop. The problem is that the loop takes a long time to execute, so it maxes out at about 480 Hz loop execution. I believe that the array to spreadsheet string function is what is bogging it down. I only need to record a couple seconds of data, so I thought I could somehow store the data in memory (maybe an array of arrays?) while the loop runs, and then convert it all to the spreadsheet string and save it outside the loop. I'm pretty new to labview, and I'm not familiar with how to do this. Any suggestions?

0 Kudos
Message 1 of 3
(2,284 Views)
Solution
Accepted by topic author davidhoff

There are quite a few things you can do to optimize this operation:

 

  1. Learn about producer/consumer architectures.  This sort of thing works best with two or more loops.  For example, one takes data and one independently formats and writes the data to disk.  Alternately, you could have one take data, one format the data, and one write the data to disk.
  2. Use queues to pass data between loops.
  3. For best write performance on Windows platforms, write in chunks of about 65,000 characters.  This means you will need to buffer your data and write it in chunks as they become available.  You can use a shift register on your write loop for the buffer and only write when the size is above 65,000 characters.

This is a lot to digest in a short amount of time.  Give it a shot and post your code with further questions so we can help more.

Message 2 of 3
(2,279 Views)

Thanks. Your suggestions took me straight to the information I needed. It seems that the labview program is now running fast enough to capture all the data the sensor can provide. I also found this link https://decibel.ni.com/content/docs/DOC-9617 helpful for determining when the data was done being processed to stop the consumer loop.Thought I would share that in case it helps somebody else.

0 Kudos
Message 3 of 3
(2,258 Views)