LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timed Loop - absolute time source cause a huge delay between expected time and actual time instants

Hello everyone,

 

I am facing a very strange behavior when using timed loop structures. At least, with all the tests I already performed I am still not able to explain what causes it.

 

- When I am using a timed loop with an absolute time source a huge delay can be observed between the expected start time of each iteration and its actual start time.

However if I use a relative time source instead, this behavior do not appear, thus, the start time and actual time are the same.

 

To observe this behavior, I built up two similar VIs, both with timed loops (one with an absolute time source and the other with a relative time source), inside the timed loop only the expected and actual time instants are saved into an array, no more actions are performed.

The results are shown below, they show two arrays one with the stored expected time instants and the other with the actual time instants. The time step used in these tests was 10ms. Even with larger time steps the same behavior can be verified (I have tested with 100ms and 1s).

 

Absolute Time source results:

(image will be added as soon as possible...)

 

As you can notice, with an absolute time source, the delays between the expected time instant and the actual time instants are huge and their values are random. In this test case, with 10ms time steps, the delays observed are huge enough to make some of the timed events to be jumped off.

 

Relative time source:

(image will be added as soon as possible...)

 

Here with the relative time source everything worked as I wanted and the expected time and actual time instants are the same!

 

I am using LabVIEW 2012 SP1. I performed the same test on different company computers (similar machines) and the result was exactly the same. I also try to use LabVIEW 2010 and I observed the same behavior.

 

Anyone has any idea to explain this strange behavior??

I know my company's computers are a bit old and have a lot of stuff running on background, but if this was the reason for the delay, Why the same delay is not observed with both relative and absolute time sources?

 

Thank you all.

Regards,

Diogo Ribeiro
0 Kudos
Message 1 of 5
(2,817 Views)

Sorry, I am not able to publish the result images… Company’s machine restrictions!
I will publish them as soon as possible.

Regards,

Diogo Ribeiro
0 Kudos
Message 2 of 5
(2,816 Views)

Sorry for all the repply messages...

Attached follows the results.

Hope this helps understanding my problem.

 

Thanks in advance.

Regards,

 

Diogo Ribeiro
Download All
0 Kudos
Message 3 of 5
(2,792 Views)

Hello,

 

The Timed Loop is a single-threaded structure meaning that it does not allow code within the structure to execute in parallel. It includes error handling, processor affinity, execution timing, feedback and other properties which can be handled and changed dynamically at Run-Time. The timed Loop has a preemptive nature and can monopolize resources of a system. The priority level of the Timed Loop is fixed between time critical and high priority and is usually used when programming on a Real-Time Operating System (RTOS), but it can though still be used when programming on Windows-based targets. If you want to use the Timed Loop in a Windows application it might, if not handled in a manner with respect to the amount of available resources in the system, increase the likelihood of unpredictable behavior. This is because of the preemptive nature of the structure which could monopolize system resources. If you have multiple Timed Loops running simultaneously in your application it may, depending on the amount of Timed Loops used in conjunction to the system resources, enter a deadlock where no time is scheduled to some of your loops, because the processor is occupied and it will seem like part of your application is not executing. It will from a user perspective appear as the application is hanging and not responding properly to various actions. An alternative to using the Timed Loop is to use While Loops with execution timing using the Wait Until next ms Multiple function or Wait (ms) function. Timed Loops/Structures can still be used on Windows targets but consider to minimize the usage of them with respect to available resources such as number of cores and/or processors.

 

 

Regards

Samuel G. | GEMESIS

Certified LabVIEW Architect

Certified TestStand Developer

GEMESIS.EU

0 Kudos
Message 4 of 5
(2,756 Views)

Thanks for your help. I understand all you have mentioned...

 

But in my example I was only running LabVIEW during tests and only one VI, with only one timed loop. I checked the amount of processor used during the execution of the code and it stays arround 7%, 8%. So, I think is not a problem of short resources, the processor is almost in idle state and there were pletty of memory available also. The desktop do not seem to stop at all. The cause of this beahvior must be something else... I am trying to understand it, bacause If I would be able to use the timed loop with the absolute time source, I will be able to synchronize the reading action and avoid polling!!

 

I understand that, as I am using an windows OS, the timed loop may not respond at the exact instant specified, but I have very relaxed demands. But these delyas are too huge.

It does not seem normal to me, that with the relative time source source the code runs at the proper time instants and with the absolute time source it does not... What is the big difference between these two time sources?? As far as I understand they came from the exact same source, they are only seen in a different manner by the timed loop. So, their beahvior should be similar, which is not the case, as I show you previously.

 

Any more ideas??

 

Thanks!!!

Reagrds,

 

 

Diogo Ribeiro
0 Kudos
Message 5 of 5
(2,743 Views)