LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timed Loop skew

I've been experimenting with LabView Timed Loops on Windows XP platform. I noticed a small bias in the timing of this structure. If you run a timed loop for a full day, you will be off by about -0.64 seconds. At least, this is what happens on my machine. I've attached a LV2009 vi for illustration. If some could give it a try and confirm.

 

If you look inisde the VI, you will notice the use of QeryPerformanceFrequency() and QueryPerformanceCounter() which, I believe, are used under the hood by the Timed Loop structure. I'm not sure how LV/windows performs the scheduling of loop, but it is as if the period had been rounded down somewhere. Normally, using integer division, the timing of each step should be adapted to prevent any long term bias to the loop. Unless something like this costs too much CPU time or is imposible to implement...

 

Regards,

-Julien

0 Kudos
Message 1 of 4
(2,941 Views)

Hi Julien,

 

I believe that the following articles will shed some light on your problem.  First, note that you are on a Windows operating system, and so the determinism is not 100% guaraunteed.  If you need this, I would recommend using a RT OS.  While timed loops are supported on a Windows OS: Timing Sources Available for LabVIEW Timed Loop by Platform; it should also be noted that they are not completely deterministic, as stated in the article Why is a Timed Loop Slower than a Regular While Loop in LabVIEW?

 

Cheers, 

Marti C
Applications Engineer
National Instruments
NI Medical
0 Kudos
Message 2 of 4
(2,902 Views)

Dear Marti,

Thank you for you answer. I understand that Windows will not give me a deterministic behavior. And I don't think that I am blaming non-determinism in my example. My concern is more on the accuracy of the task scheduling than on the execution itself. I imagine that LabView must be using something like SetWaitableTimer (http://msdn.microsoft.com/en-us/library/ms686289(v=VS.85).aspx) in the periodic timer mode, which advertise a minimum period of 1ms (exactly 1kHz). If that's the case the issue is indeed within windows itself, and I will have to calibrate the drift.

-Julien 

0 Kudos
Message 3 of 4
(2,892 Views)

Hi Julien,

 

As far as I know, LabVIEW operates off of your operating systems clock.  If you would like for an operation to occur every 100ms or so, I would recommend using the "Wait until next ms Multiple" instead of a timed loop.  How often do you want this code to execute?

 

Cheers, 

 

 

 

Marti C
Applications Engineer
National Instruments
NI Medical
0 Kudos
Message 4 of 4
(2,870 Views)