LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

write to measurement file VI - every second, is that too fast ?

I use the write to measurement file VI to save 5 values + a comment to a file. The VI is in a loop. The VI adds new values to the same file every time it is called. In one of the tutorials it is said "VIs can be more efficient if you avoid opening and closing the same files frequently". I understand that; the write to measurement file VI does open and close the same file every time it is called.

 

I want the VI called every second to save new data. Tests I did with this rate did show problems. However, what is meant by frequently? Every second? Every millisecond? So my question is: is saving every 1 second, like I want, likely to cause problems, or isn't that time period hardly a problem? Or is there a better solution (although this VI gives me all possibilities I want, including saving a comment and saving to multiple files with nice filenames; I would really like to use this VI).

-- flying dutchman --
0 Kudos
Message 1 of 6
(3,087 Views)

"frequently" is subjective as it depends on your computers available memory and processor.  I can't personally answer that question with much detail but I can suggest an alternative.

 

Instead of writing every measurment to file as it's taken, can you instead save them in groups of 5 or 10 or 50?  this will avoid problems with the file as well as increase the program speed.

0 Kudos
Message 2 of 6
(3,079 Views)

Unless you need to access the file for some reason while the program is running you can use the "Write to Spreadsheet File.vi" outside of your loop. The array of 5 entries passes through the loop via an index tunnel (right click on the tunnel and enable indexing) and the entire file is saved once at the end of the program. 

0 Kudos
Message 3 of 6
(3,073 Views)

Sorry, I see  I made a type mistake, I meant: Tests I did with this rate did NOT show problems.

 

pjr1121: I thought about that as well. Is there an example for that, as I am a rookie

-- flying dutchman --
0 Kudos
Message 4 of 6
(3,048 Views)

Nukem: I thought about that, bit the program comes to an end after 24 hours measuring, so if something goes wrong inbetween I will lose all data.

-- flying dutchman --
0 Kudos
Message 5 of 6
(3,047 Views)

The answer lies halfway between mine and Nukem's answers.  Instead of storing all values in a shift register until the end, you simply store them, for say 1 hour, and append to the file.  This also enables you to save some of your data in the event of a power failure or something.

 

Use a nested for loop, the inner loop will run for say, 50 or 100 iterations, storing values in a shift register array.  Upon exiting this loop, the data is appended to your file.  The outer for loop will run for how many iterations out need.  

 

For some simple examples, lets say you need 10,000 loops and you want to save every 100 iterations.  Have the inner loop run 100 times and the outer loop run 100 times.  

0 Kudos
Message 6 of 6
(3,044 Views)