Paul Posted June 29, 2004 Report Share Posted June 29, 2004 I was wondering if anyone knows how to specificy a user control for saving data to a file every x seconds. It currently does it every 1.7-2 seconds. I was wondering if there was a setting or a control that I am having some trouble finding. Thanks Paul Quote Link to comment
Michael Aivaliotis Posted June 30, 2004 Author Report Share Posted June 30, 2004 How about putting the file saving code inside of a loop with a timed delay? If you give a little more description of what you are using already then I can respond with more information. Quote Link to comment
Paul Posted July 1, 2004 Report Share Posted July 1, 2004 I did that and it works. However the fastest that data can be saved is every .3 seconds. Is that because that's the fastest that the data is received from the insturment or is that a coding error? Any ideas? Quote Link to comment
Bryan Posted July 1, 2004 Report Share Posted July 1, 2004 What function(s) are you using for writing the data to file? If you're using one of the high-level VIs such as "Write Characters to File.vi", that VI opens, writes and closes the file every time you run it. If you're continually saving data in a loop, it's inefficient and unnecessary to keep opening and closing the same file that you're writing to in every iteration. A better way to do it is to use the more advanced file functions. Use "Open/Create/Replace File.vi" to open/create a file refernce outside of your loop and then pass the file reference into the loop. Use the "Write File" function to write your data to the file reference inside the loop. Then after your loop, use the "Close Reference" function to close the file reference when your logging loop has finished running. Note: The Write File function doesn't actually write the data to the file immediately, but merely buffers it until (I believe) either the buffer gets full or you close the reference, you have to use the "Flush File" function to actually write your data to the file, but it may add time to your iterations. I haven't tried it personally, but maybe you can use the "Flush File" VI in a parallel loop to actually write the data to the file reference at timed intervals? Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.