12-02-2023 02:07 PM - edited 12-02-2023 02:15 PM
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.
The explanations of the two functions are as below
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.
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.
.
Solved! Go to Solution.
12-02-2023 08:24 PM
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?
12-02-2023 09:33 PM
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
12-03-2023 12:19 AM
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.
12-03-2023 07:24 AM
I think maybe a better option would be to use a timed loop, especially if you want SW controlled 1 kHz data aqusition.
12-03-2023 09:05 AM - edited 12-03-2023 09:31 AM
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.