LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Save chart data to the file constantly

Solved!
Go to solution

I am aqcuiring analog data from DAQ USB 6000 and outputing it on the chart. I have to save all the data to a file as well (text or excel...or at least some file). It is easy to configure it so, that the data is saved after the stop button was pressed- so only at the end of the run. However, I need to write to a file during the programm running because it might be running for days. In a such long time, the buffer is overloading, and the data is lost. 

Could you please advise any way of how to write data to a file constantly during the measurement, wthout saving it into the buffer?

0 Kudos
Message 1 of 15
(4,119 Views)
How much data are you acquiring? How often are you reading it?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 15
(4,103 Views)

At the moment it is one measurement per second from two channels of USB6000. In the future I am aming on more channels and higher sampling rate, but need to figure out how to do it at least in that confirguration.

 

**The measurement might take a day, or several days.

0 Kudos
Message 3 of 15
(4,100 Views)
The basic technique is to open a file reference outside your loop, write to it as often as you need to inside the loop and then close it when the loop stops. How often to write can be tricky. You might want to use a buffer of limited size so you are only writing to the file (for example) every 10 samples.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 4 of 15
(4,081 Views)

Thank you for your answer.

As you can see in the attached screen, I do as you proposed. However, I am not sure of how to write every 10 samples only. Could you please advise that?

Also in that configuation, as I mentioned before, I think it writes to a file only when I stop running the program. Isn't it so? If I open the file during the execution, it will be empty before I stop...That is why I am thinking that it writes to some buffer, and when it is overloading, the data is deleted, if the programm wasn't stopped before overloading.

0 Kudos
Message 5 of 15
(4,072 Views)

Have you looked at the Write to Measurement File.vi

 

I tend to avoid express vis generally but apparently NI have put some effort in to making this vi a bit more intelligent than it used to be (ie. it now doesn't continuously open and close a file reference each iteration, etc.) A nice feature is that it will automatically re-start a new file at defined intervals (number of samples, every hour, etc.) which sounds useful in your long-running application. Not used it myself yet but it was highly recommended by an NI instructor on one of the advanced courses I recently attended.

0 Kudos
Message 6 of 15
(4,042 Views)

Yes, I tried  Write to Measurement File.vi already. After 3-4 seconds of measurement it gives an error 200297 saying that "The application is not able to keep up with the hardware acquisition. Increasing the buffer size, reading the data more frequently, or specifying a fixed number of samples to read instead of reading all available samples mightcorrect the problem".

I trying different sampling rate, but it affects only the time after which the error appears. Fixed number of samples is not an option in my case as I need to read as many of them as they are. 

0 Kudos
Message 7 of 15
(4,037 Views)

Personally, I would use the DAQmx Configure Logging function.  This will make DAQmx stream the data to a TDMS file as you read the data.  You just tell it where to put the file.  It is extremely simple and fast.  There is a free add-on to view TDMS files in Excel, if that is a concern.

 

EDIT: Just noticed that you are useing the DAQ Assistant.  There is a Logging tab in there to set up the streaming to TDMS.  I recommend getting away from the Express VI and learn the actual DAQmx API.  You can make things a lot more powerful and efficient if you do.  They will also be easier to debug since you do not have to open up a configuration window just to see your settings.


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
Message 8 of 15
(4,016 Views)

... After 3-4 seconds of measurement it gives an error 200297 saying that "The application is not able to keep up with the hardware acquisition. Increasing the buffer size, reading the data more frequently, or specifying a fixed number of samples to read instead of reading all available samples mightcorrect the problem".


Something odd here as you said earlier you were only taking one measurement per second - yet your application is not able to keep up???

 

Suggest checking the sample rate and number of samples in your DAQ setup! I also second using the API as crossrulz mentioned - it is much easier to see what is going on when you can see all the vis and parameters on your diagram and you have much more control.

0 Kudos
Message 9 of 15
(4,004 Views)

Hi,

Did you try save to measurement file, please see the snippet.

because I have similar application, acquiring data and save it, the sampling rate is 5000 Hz and number of sample is 1000  for 6 channels. 

So I save the data for each minute, in that case the size will be300000 * 6.

Any way I try too much methods, at last the predescribed setting is working well.

For example: from 8th of May to 12th of June the system is working so nice without loosing the data.

One more point, if you post your VI it will be helpful.

Thanks

 

0 Kudos
Message 10 of 15
(3,986 Views)