LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Streaming data to disk, need help reading data into Power Spectrum/Octave vi

I'm streaming data to disk in one loop, however once this finishes I'd like to read the data into power spectrum vi/Octave analysis vi in another loop. The data from the read vi is a string and power spectrum vi needs 1d waveform. Does anyone have experience with this process?
0 Kudos
Message 1 of 4
(2,844 Views)
From your general description, I gather you are streaming to a text based file (comma or tab separated spreadsheet format) and would like to analyse this data with a power spectrum or octave analysis when you finish. Since you are streaming, I assume you have a lot of data. Do you have more than one channel?

In any case, you have two simple options (and lots of complex ones). You can either read the data back from disk and convert it to a 1D array (try the Read From Spreadsheet File.vi - will get a 2D array, take the first column or the column of your choice if you have more than one channel) or you can use the Spreadsheet String to Array primitive to create an array from your text data before you save it to disk.

If your data rate is slow enough, you can analyze as you acquire and store.

Taking your data as text is very inefficient. What you really want to do is read the data as binary, use that for your analysis, and use something like the Write to Spreadsheet File.vi to save text data to disk.
Message 2 of 4
(2,827 Views)
Yes multiple channels. I'm streaming 10 channels of data from the NI4472 and writing the data to binary file in one while loop. The other while loop I'm having trouble getting the data from the read vi to my analysis vis.

How can I analyze as I store the data? Srate is 51.2kHz.

Once data is processed I write to spreadsheet file. No problem there. I was taking data, processing the data, and then writing to spreadsheet file in one loop. Alot of work on the cpu (have trouble running other programs while running my code). Just trying to make it more efficient.
0 Kudos
Message 3 of 4
(2,817 Views)
At 512S/sec (all channels combined) you may not be able to analyze as you acquire, but it's worth a try. Use a queue to pass data from your acquisition to your analysis. Just pass the data into the queue as well as storing it. In your analysis loop, read the queue instead of reading from a file. If the analysis gets ahead, the queue will cause it to block, waiting for the next data set. If the data acquisition gets ahead, the queue will buffer the data. You may want to specify a maximum number of data sets when you initialize the queue so you don't run out of memory if the analysis is much slower than the acquisition.

One final note, to exit the analysis loop, you will probably need to close the queue with force destroy set to TRUE.
0 Kudos
Message 4 of 4
(2,811 Views)