Academic Company Events Community Support Solutions Products & Services Contact NI MyNI
52 ratings:
 2.98 out of 5     Rate this Document

The Difference between the Wait (ms) Function and the Wait Until Next ms Multiple Function

Primary Software: LabVIEW Development Systems>>LabVIEW Base Development System
Primary Software Version: 1.0
Primary Software Fixed Version: N/A
Secondary Software: LabVIEW Development Systems>>LabVIEW Full Development System, LabVIEW Development Systems>>LabVIEW Professional Development System

Problem:
What is the difference between the Wait (ms) and Wait Until Next ms Multiple functions in LabVIEW?

Solution:

Wait (ms)
The Wait (ms) function is typically used as a programmatic delay between code segments. For example, you could place a Wait (ms) function in a Sequence structure between two segments of code.

  • Example 1: There is a While Loop with code that takes 5 ms to execute. The While Loop also includes a Wait (ms) function with 10 ms wired to it. The While Loop takes 10 ms total to execute because the code finishes after 5 ms and then the Wait (ms) function finishes 5 ms later. In this case, the Wait (ms) function executes in parallel with the code.
  • Example 2: The While Loop is the same as in the previous example, but the code takes 15ms to execute and the Wait (ms) function has 5 ms wired to it. Because the time wired to the Wait (ms) function is less than the time it takes the code to execute, there is no delay after the code finishes, and the code returns to the beginning and immediately repeats at 15ms.

Refer to the attached VI for an example of how the Wait (ms) function works in parallel with the executing code.

Wait Until Next ms Multiple
The Wait Until Next ms Multiple function is typically used as timing control for a While Loop to prevent LabVIEW from using too much of the processor.  As the name suggests, it will cause the loop to wait until the next multiple of that number of milliseconds before running. Wiring a value of 0 to the milliseconds multiple input forces the current thread to yield control of the CPU.

  • Example: There is a While Loop with code that takes 10 ms to execute and a Wait Until Next ms Multiple function with 100 ms wired to it. The While Loop executes at every 100 ms multiple of the millisecond clock.

Refer to the LabVIEW Help (linked below) for more information about the differences between the Wait (ms) function and the Wait Until Next ms Multiple function.





Related Links:
Tutorial: Software Timed Loops using Wait (ms) and Wait Until Next ms Multiple
KnowledgeBase 2G27ANEW: Wait Until Next ms Multiple.vi Does Not Wait Properly on First Loop Iteration
LabVIEW 2013 Help: Wait (ms) Function
LabVIEW 2013 Help: Wait Until Next ms Multiple Function

Attachments:

Wait_ms_example (LabVIEW 7.1).vi
Wait_ms_example (LabVIEW 2010).vi




Report Date: 10/16/1995
Last Updated: 04/10/2014
Document ID: 0EF854SG

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit