12-07-2009 03:02 AM
Hi to all,
I am using the elapsed time function with LabVIEW 8.0 inside a while loop for the timing of my logging function, but I do not get a accurate timing. That means, if the data should be saved every 60 seconds, the time stamps will shift after a while (approx. 1 sec per 3 min.).
configuration of elapsed time function:
target time: 60 sec
reset : each next iteration after tiem has elapsed
iteration while loop: 100 ms
I get time stamp like
12:00:00
12:01:00
12:02:00
12:03:01
12:04:01
...
Any suggestions? Thank you!
Niko
12-07-2009 03:14 AM
Niko,
you are working on Windows?
If you do not work on a real time operating system, there will always be some drift. This is, because your cycle time of 100ms is not deterministic, which will lead to delays when calling the "Elapsed Time" function. This function only checks if the desired time has elapsed, it does not wait exactly this time. So if you want to have 60s elapsed and call it after 10 minutes, the time will be elapsed.
In order to keep track of this drift, you can check the "Elapsed Time(s)" output of the VI. I say that on your machine, most often this time is slightly bigger than 60s.
hope this helps,
Norbert
12-07-2009 03:51 AM
Thank you Norbert,
yes I am working on windows xp prof. and I had a look onto the "Elapsed Time (s)" and the result was, that each cycle the elapsed time has been between 60 and 60.100 sec., so this should not be the reason, that I get a time shift.
But I found out, that the reason for the time shift is the 100 ms delay, between time elapsed and resetting the timer. When I reduce the iteration time of my while loop to 20 ms, I also reduce the time shift. So I will work with "new target time" = "target time" - "iteration period"
Regards, Niko