LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I write data to file continuously?

Hi all,

I wrote a data-acquisition program which is acquiring a certain number of data points continuously after starting the program over a more or less long period of time.

I need to save these data points in a 1D array point by point i.e. so I am not loosing my data if the system crashes.

I think what I have to do is the folowing: first, create a file with file name; than open the file and writing my first data point into it; close the file; open the file; ADD the second data point AFTER the first data point to the file ..... finally close the file.

May be there is an other way to accomplish the same?

This is my first time with real-time data logging because I am relatively new in labview. It would be great
if somebody could help my with this problem.

Thank you very much,

beam
0 Kudos
Message 1 of 7
(4,024 Views)
The simplest format you can use is to open a file outside your data acquisition loop, perform write operation within the loop, and close the file outside your data acquisition loop when you are done with acquiring data. This is not the most efficient ways, but as I mentioned earlier this is the simplest way to get you started.
0 Kudos
Message 2 of 7
(4,024 Views)
Hi Beam,

the same thing as you discribe does the "write to spreatsheet.vi". It
opens a file, saves an array to it and closes the file.
But if you vi is running fine you did the right thing.

Niko
0 Kudos
Message 3 of 7
(4,024 Views)
beam,

Another technique is to leave the file opened as long as acquisition occurs and use the Flush File function once in a while to force any buffered data to be written on disk and the file directory entry be updated. Flush File does the same work as Close File except it doesn't destroy the file refnum, leaving the file opened. If the system crashes, you will recover data written prior to the last Flush.

When opening a file for a long period of time, you should open the file setting the mode to "deny read/write". That will prevent other file sweeping applications (backup, anti-virus, Fast Find) to open the file simultaneously and temporarly deny you write access to the file.


LabVIEW, C'est LabVIEW

0 Kudos
Message 4 of 7
(4,024 Views)
But if the system crashes, data migth be lost because the file hasn't been properly closed.


LabVIEW, C'est LabVIEW

0 Kudos
Message 5 of 7
(4,024 Views)
Thank you very much for this suggestion. The data logging procedure is now working perfectly.

Thanks
0 Kudos
Message 6 of 7
(4,024 Views)
Thank you very much for your example program. It was the right help for me getting started. My program is now working fine.

Thank you
0 Kudos
Message 7 of 7
(4,024 Views)