View Single Post
  #3   Spotlight this post!  
Unread 12-01-2009, 21:47
Russ Beavis Russ Beavis is offline
Registered User
no team
 
Join Date: Nov 2005
Location: Manchester, NH - DEKA R&D Corp.
Posts: 341
Russ Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond repute
Re: Wait.VI on basic motor tutorial, need clarification.

In LabVIEW, EVERYTHING runs in parallel as long as its inputs are ready (and as close to "parallel" as a single-threaded machine can really be).

If you have a while loop that keeps repeating, the innards will execute as quickly as the machine can operate unless you force the loop to execute at a fixed rate.

There are a number of ways to force loop timing in LabVIEW but the easiest are using "wait.vi" and "wait until ms multiple.vi". If you place either of these within your while loop, a new parallel process is created in your VI. The loop iteration cannot end until that wait routine is done. So... if you've got a little snippet of code that executes in 1ms and a wait VI with a 10ms control input, your loop iteration will start at t=0 and, at t=1ms your code will finish then at t=10ms the iteration will be done and will restart (if that's warranted based on the conditional for the loop).

To really understand how the above works, I'd encourage you to create a while loop that's set to execute forever and plop down 2 wait VIs - one with 500ms timer and one with a 1 second timer. View the output from the loop's iteration counter (right-click - create indicator on the the "i"), turn on highlight execution mode and then click run. Watch how the two wait VIs operate in parallel and how the 1 second wait VI rules.

The relatively new Timed Loop construct can really help as well. It's not too hard to use and provides some nice features (eg did my loop actually run as fast as I requested?).

My final comment - a while loop without any delays can be a SERIOUS CPU hog. If you create a simple while loop on a PC, it could run at a few MHz and won't allow you to do anything else on your PC while it's running.

Russ
Reply With Quote