LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stream two acquired channels to binary

Solved!
Go to solution

I appologize if this is incredibly straightforward, but I seem to be at a dead end. My goal is simple. I want to use Labview to collect two channels of acoustic data (sampling at 50k per channel)  from an NI DAQ card. I want to stream these two channels to binary files (either one file containing both channels, or one file per channel). I then wish to be able to use a separate vi to open these files and convert the data to .wav (or anything really; .wav seems appropriate for acoustic data).

 

My trouble is that the 'write waveform to file' tends to create very large files that cause memory issues when opening. 

 

I have tried several variations of using Write to Binary and Read from Binary that have resulted in very mixed up data. 

 

Any help would be much appreciated. 

 

0 Kudos
Message 1 of 5
(2,942 Views)
Solution
Accepted by Brad10

what about using tdms files as the intermediate binary? they are standardized, so you don't need to create parser vi-s and have quite good performance

The NI TDMS File Format

__________________
Engage! using LV2015
0 Kudos
Message 2 of 5
(2,935 Views)

I'm not sure why you are having a problem.  As I understand it, you are sampling 2 channels at 50 KSamples/sec.  You should be able to write pairs of numbers (I'm assuming you are working with a 16-bit A/D, so that's a rate of 200KB/sec -- you should be able to keep up this rate for a long time (unless you are using a 1.44MB floppy).  To achieve reasonable data rates, buffer your data (i.e. send 1000 points at a time instead of 1 at a time) and use something like the Producer (A/D converter)/Consumer (Disk I/O) pattern.

 

BS

0 Kudos
Message 3 of 5
(2,907 Views)
Solution
Accepted by Brad10

I also highly suggest using TDMS.  And if you are using DAQmx (which you should), there is a DAQmx Configure Logging VI.  Use this VI to have your DAQmx task streamed straight to a TDMS file.  You don't have to do anything else with the data or file.  That is by far the simplest solution.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 5
(2,879 Views)

Thank you all; I don't know what was wrong with the binary; but I dropped TDMS in its place and the whole thing works beautifully. Thanks!

0 Kudos
Message 5 of 5
(2,866 Views)