LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Which is better between Wait (ms) and wait until next ms multiple when input is 1 ms

Solved!
Go to solution

Hi Application engineers,

 

I can use either wait(ms) or wait until next ms multiple, using 1 ms input, Can any one tells me which function is a better option in a while loop for data acquisition? or a more even iteration.

edmonton_0-1701546480765.png

The explanations of the two functions are as below

edmonton_1-1701546833717.png

When LabVIEW calls a VI for example, if millisecond multiple is 10 ms and millisecond timer value is 112 ms, the VI waits 8 more milliseconds until the millisecond timer value is 120 ms, a multiple of 10.

edmonton_2-1701546915229.png

When LabVIEW calls a VI for example, if millisecond timer value is 112 ms and milliseconds to wait is 10 ms, the VI finishes when millisecond timer value equals 122 ms.

 

I checked millisecond time value  for both cases, they always give a very large number, for example 610698828, keeps increasing. 
 
Thanks,
Gu

0 Kudos
Message 1 of 24
(2,436 Views)

You shouldn't be using either of them for Data Acquisition, typically Data Acquisition is best when Hardware timed by the instrument used to capture the data.

 

What instrument do you use?

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
Message 2 of 24
(2,397 Views)

I wonder if the Time functions, particularly the difference between Wait (ms) and Wait Until Next ms Multiple from when I wondered about this (maybe 10-15 years ago), looked it up, and said "Oh, that makes sense" ...

 

The "old" explanation was that Wait Until Next (which I'll abbreviate as WTN) was meant to synchronize parallel loops that should run "synchronously". That is, if you have two loops that you want to run once/sec, but to run "in synch", starting at the same time (to the nearest millisecond), you use WTN -- it not only gets the loops to run at 1 Hz, but they stay "in synch" with each other.  I believe the idea is they were triggered when the "time" on the CPU's internal "clock" was a multiple of the number of ms coded in this function, it would "end its wait" and run.  This means that these functions (if set to the same multiple Time) would work even if in different sub-VIs, potentially even in separate LabVIEW executables running at the same time (since there is only one System Clock, so when its "tick time" is first synchronized to a "whole millisecond", all subsequent calls to WTN will execute essentially "in synch".

 

Bob Schor

 

 

Message 3 of 24
(2,388 Views)

To answer your second question, the output of both functions is the same as "tick count", i.e. a relative U32 1khz counter that can be used to calculate relative times by subtracting two such ticks.

 

Message 4 of 24
(2,378 Views)

I think maybe a better option would be to use a timed loop, especially if you want SW controlled 1 kHz data aqusition. 

Anders Pedersen Sekanina
sekanina.dk




Message 5 of 24
(2,354 Views)

I can confirm what Bob wrote in https://forums.ni.com/t5/LabVIEW/Which-is-better-between-Wait-ms-and-wait-until-next-ms-multiple/m-p...

my usecases:

 

## usecase: polling

 I prefer "miliseconds wait" , as the execution time of "miliseconds multiple" is guranteed to be a multiple of the time in ms set, which can result in cpu-% spikes, when working with multiple loops, each one calling multiple wait.  

 

 

## usecase: syncronization

instead of "milliseconds wait/multiple", I use a timed while loop for data generation and queues to do the syncronisation between further loops, as has been already suggested by AndersSekanina.