08-25-2005 11:19 AM
Hello everyone,
I am using a while loop timed 50 mecs to access sensor data. I would like to use this loop to write data every 1000 msecs to a file. However I have 2 problems in the VI I have attached :
1)I want the user to be able to start writing to the file when ever he wants. That is to say , I don’t want the saving to start when the program starts ( like the attached program does ). So I tried to put the "open file" in the while loop and use structure events so that it doesn’t "open the file" every 50 ms but just writes in it. But I couldn’t make it work correctly. Would u have any idea how to do this?
2)My second problem is that it seems that the writing timed to occur every 1000ms does one more 50 ms turn. That’s why I sometimes record every 2 secs instead of 1 sec. I have made many changes ( changing the initialisation, ….) without any success.
Any help would be really great
Regards,
David
08-25-2005 12:14 PM
Hi Mark,
I can't look at your posted vi because I don't use LV at work (at the moment). However, you should use the Open File vi and pass the file reference into the while loop. At the exit of the while loop, you can use the Cloe File vi.
Please note that there is a time delay for each iteration of the while loop, including the time delay for the write to file process. What you can do is have a "delta" counter that keeps track of the time spent in the while loop and subtract the delay to the time to write value.
Ex: TimeToWrite = 1000 ms
whileDelayTime = 10 ms
TimeToWrite = TimeToWrite - whileDelayTime
It may not be 100% accurate, but it's an easy way to correct the next write cycle and should average out to give you reasonable accurate samples... Unless you need something more accurate.
Regards,
JLV
😄
08-25-2005 01:18 PM