LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Save data using a revolving buffer

Hi,

 

I am trying to save data plots into a text file which is tab separated. An array of data is added to the end of the file every second. This is to be done until it reaches a revovling buffer target time, which is currently 3300secs (55mins). At this point the newest data point will overwrite the oldest point in the file. 

 

If an error occurs the effect off the revolving buffer stops and the data is still to be saved to to file for a further 300secs (5mins).

 

The issue I believe I  am having is when the data in the array differs from a previous data array. (number of decimals in an element). A lot of empty elements get added to the end of the file. Could anyone please suggest a way of saving the data without having this problem.

 

I have attached a .vi to simulate the revolving save buffer. I have reduced the time from 3300 secs to 5secs and, 300secs to 2secs.

 

In order for the .vi to work a folder muist be created in the following directory-  C:\cycles\results

 

The examples of the results have been attached and can be veiwed in notepad or microsoft excel.

 

Thank you

 

 

0 Kudos
Message 1 of 3
(2,717 Views)

I would just use the Data Queue PtByPt VI to create your circular buffer and then just overwrite your file whenever new data comes in.


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 2 of 3
(2,711 Views)

Some more hints:

  • You overuse local variables, and lots of unnecessary things are in the VI
  • Keep in mind, in case of error (from the VI) you need to handle the error and shut down the application properly, including closing the file reference.
  • Depending how you write the data to the file, you might lose data in case of OS/PC failure, since Windows usually writes data physically to the file in a buffered way. You need to keep this in mind.
  • I would use TDMS files instead of ascii, much better to program and you can open it into Excel with a free plugin.

I strongly suggest you to learn how to program a proper State Machine, and go through the online tutorials or teaching material. Here is some more reading:

http://www.ni.com/newsletter/51735/en/

0 Kudos
Message 3 of 3
(2,693 Views)