LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Difference between time waiting functions

Hello,

I am wondering what's the difference between 'wait (ms)' and 'Wait Until Next ms Multiple' functions, especially what's the difference when they are used in loops for delay. According to function helps, looks like the latter function has more advanced function, but I still have no idea what's the exact difference between them, especially in  selecting which one for which situation...

Thanks for advise.
 

Message Edited by Dejun on 10-03-2007 11:15 AM

0 Kudos
Message 1 of 4
(3,131 Views)
Let me illustrate with a hypothetical example.  Let's suppose you have a loop containing code that takes anywhere from 7 msec to execute.  Let's further suppose that you use 10 msec delays with the two different functions, and that you enter your loop at t=2 msec.
 

Scenario A.  Sequencing is used to make sure code execution occurs first, then the delay will start.
1. With "Wait (msec)", the timing will look like:
Iteration i: 0,  1,  2
Code ends:   9, 26, 43
Wait ends:  19, 36, 53
 
2. With "Wait Until Next msec Multiple", the timing will look like:
Iteration i: 0,  1,  2
Code ends:   9, 19, 29
Wait ends:  10, 20, 30

Scenario B.  Delays are decoupled from code and execute in parallel
1. With "Wait (msec)", the timing will look like:
Iteration i: 0,  1,  2
Code ends:   9, 19, 29
Wait ends:  12, 22, 32
 
2. With "Wait Until Next msec Multiple", the timing will look like:
Iteration i: 0,  1,  2
Code ends:   9, 17, 27
Wait ends:  10, 20, 30

You are correct that proper selection depends on the situation.  Very generally, 'wait (msec)' is just a simple delay while 'ms multiple' helps you to sync to a metronome-like beat.  However, if you just barely miss a particular multiple, you get stuck waiting until the next one.

-Kevin P.

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 2 of 4
(3,106 Views)
Kevin, thank you soooooooooooo much for your so clear explanation !!!
-Dejun
0 Kudos
Message 3 of 4
(3,096 Views)
Too late to edit, so here's a correction:
 
For Scenario A, part 2, the "Code Ends:" row should be 9, 17, 27 rather than 9, 19, 29.
 
-Kevin P.
ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 4 of 4
(3,080 Views)