LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to improve timing of first while loop iteration?

Hi,

I'd like to use a while loop to aquire data from a DMM.
Date should be read all x seconds.
If I use "Wait Until Next ms Multiple", I get the problem I already know from similar tasks:
The first (sometimes also the second) iteration of the loop is much shorter than the desired value.

I know that this is due to synchronization and adaption to the executed code in the loop, but isn't there a way to at least improve this behaviour??

I tried it with self-made wait loops, but they are not as precise as the "Wait until next ms..." as I always have to check an abort criteria for my wait loops. I can't do this too often in order to save processor time.

Hope you know some approaches...

Regards,

A
ndreas
0 Kudos
Message 1 of 8
(3,083 Views)
Use the "Wait MS" vi instead or use the event structure timeout with your code in the timeout frame. You can add other frames that will execute if you want to abort.
0 Kudos
Message 2 of 8
(3,083 Views)
If you're using the while loops to control the acquisition timing and timing is critical, you should probably switch to buffered acquisition in order to use hardware timing. You can use Help->Search for Examples and search for "continuous" to see some examples. Otherwise Eh's (are we Canandian?:) approach is better or use Tick Count for timing (eg run TC outside the loop to get an initial value and then continuously use TC in the loop. TC in loop minus initial TC is time elapsed.)


2006 Ultimate LabVIEW G-eek.

0 Kudos
Message 3 of 8
(3,083 Views)
Call Wait Until Next ms Multiple with the same delay before entering the loop.

Try attached example.
0 Kudos
Message 4 of 8
(3,083 Views)
Wow, this seems to work quite well. The only problem is that if your using longer wait times the loop won't execute before completing this "pre-Wait-Until-Next-ms-Multiple"-function...

Thanks,

Andreas
0 Kudos
Message 5 of 8
(3,083 Views)
Yes this is unfortunately the price to pay !
0 Kudos
Message 6 of 8
(3,083 Views)
I try it at LabWIEW 6i and I didn't notice it to be working. Your example need version 6.1, I can't try.

But I tried to manage delay using programmable Wait(). I calculate how long to wait to get the same result as using "Wait Until Next ms Multiple". It has worse precision, but above 50 ms it seems OK (depends on hardware). See example.
0 Kudos
Message 7 of 8
(3,083 Views)
Maybe something like this is what you are looking for.

The use of the occurrence is optional. The timer will exit prematurely if the occurrence is set.

Beware: The timing is valid only within a "series" of calls without setting the occurrence. This is not a finished VI.

By splitting the total wait time into smaller portions, the maximum deviation of the first loop from the wished time is equal to this value. I have set the loop time minimum to 5 to free up the CPU.

Regards

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 8 of 8
(3,083 Views)