LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

write data to a file with high rate(200 KHz)

Hi,

I have different Sin wave(with different frequencies: 4.3 KHz, 8.4,13.3,17.55 KHz
). I wanna to acquire these signals and write the data points in a LVM file. For this reason I use 200KHz for Rate but with DAQ assistant give me error 200279. I tried to read data more frequently and change buffer size manually. You can see the final file that I have in the attached file . But this file just write for me for 0.0001sec. When I change the rate in this file to 200000, it writes data just for 1 sec and after that gives  the minus data for time.I don't know how I can solve this problem.

Marmar

0 Kudos
Message 1 of 7
(3,315 Views)

Please someone give me a solution.

0 Kudos
Message 2 of 7
(3,274 Views)

Writing data to a file takes longer than the data you have coming in is acquired.  So by the time the data is written to the file, the buffer has already overrun in the DAQ acquisition task.  Particularly if you are only acquiring a 1000 samples at a 200kHz rate, that is a small fraction.

 

You should look at Producer/Consumer (search the forums and look under File / New.... templates).  There you pass the data off from the acquisition loop to a file writing loop by way of a queue.  You should also acquire a larger number of samples in each acquisition to make an efficient sample of data to pass to the file writing loop.

 

In the end, if you still have a hard time with the file writing keeping up with the acquisition since that loop will run slower, you should look at saving the data in a binary file format such as TDMS rather than saving to a text file which is a much less efficient way of storing data.

0 Kudos
Message 3 of 7
(3,244 Views)

The LVM format is not designed for high-performance logging. You might want to try TDMS instead.

Herbert

0 Kudos
Message 4 of 7
(3,206 Views)

Hi Herbert,

Thank you so much.

I did it and it's ok.But the problem is importing the TDMS file to Matlab. With LVM file I didn't have any problem. For TDMS I am using a Matlab function (

Function to load LabView TDMS data file(s) into variables in the MATLAB workspace.
%An *.MAT file can also be created.  If called with one input, the user selects
%a data file.  This function was submitted to MATLAB Central's File Exchange by
%Robert Seltzer on 15 JUL 10 (File ID #28212).

Function to load LabView TDMS data file(s) into variables in the MATLAB workspace.%An *.MAT file can also be created.  If called with one input, the user selects%a data file.  This function was submitted to MATLAB Central's File Exchange by%Robert Seltzer on 15 JUL 10 (File ID #28212))That the structure gives me just the data for one channel(I have data for six channel).I couldn't attach the function here. It gives me the error that the extension is not valid.

 

Thanks again,

Marmar

0 Kudos
Message 5 of 7
(3,202 Views)

Not sure what you mean by that.

 

You can import TDMS into MatLab using this.

 

Herbert

0 Kudos
Message 6 of 7
(3,193 Views)

Thank you Herbert,

I tried it before but it gives me error 

Error in ==> ReadFile at 30
loadlibrary(NI_TDM_DLL_Path,NI_TDM_H_Path);

 

Error in ==> ReadFile at 30loadlibrary(NI_TDM_DLL_Path,NI_TDM_H_Path);

Marmar

0 Kudos
Message 7 of 7
(3,185 Views)