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: 

while loop or timed loop?

hi all
i am running a control system with data acquisition using a while loop to run as fast as possible.
however is it recommended to run using the timed loop?
is there any benefits of doing so
0 Kudos
Message 1 of 3
(3,394 Views)
The Timed Loop won't really let you run any faster, but it should give you better timing accuracy than the While Loop. If you are now running a While Loop with little or no time delay in it, you're running about as fast as you can already.

You really need to figure out how fast you need it to run. With no time delay in the While Loop, you should be getting several thousand acquisitions each second, of course this is going to depend on the acquisition itself and the machine it’s running on. The number of acquisitions will not be consistent because the OS will grab some CPU time to take care of other needed items, and that will slow it down a bit.

Ed


Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
Message 2 of 3
(3,371 Views)

@leongchuan wrote:
...however is it recommended to run using the timed loop?

.Interesting. Is this just a watercooler remark by a coworker or an official of NI support?
If you don't use any timing and want to run as fast as possible, it is not entirely clear that a timed loop would be generally faster than a regular while loop. However, you should be able to easily create a small benchmark program to verify. This is something you can easily test for yourself and you don't have to take anybodys word for it. 🙂

Timed loops have many advantages, primarily they are more deterministic and the can synchronize with other timed loops, you even have information there were delays.

IF your diagram has multiple parallel loops and all other loops are lower priority tasks (user interface, background processing, etc.), you can assign your control loop a higher priority over the other loops. This fact might have been the idea behind the above statement.

The timed loop is much more important in LabVIEW realtime or FPGA systems. If you really need to have fast control loops, this is the way to go.
Message 3 of 3
(3,353 Views)