From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

elapsed time function - inaccurate timing

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

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

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 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 3
(2,813 Views)

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

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