LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VI of the Day (8/19/09)

I am on travel, so an easy (but very important) function for today.  Wait (ms)

 

In my opinion, a while loop to this function is like water to a fish.  Somebody should mention the importance of this combination and why there is a near-daily rant about it on this forum.   Any tips about cutting the number of clicks required to get a while loop plus Wait function wired to a reasonable value.  What is a reasonable value?

 

Is wiring 0 the same as leaving it out?  hmmm...

 

A limitation to this VI would seem to be the maximum wait time, of course you see an easy fix.  You should calculate the length of the maximum wait, I'd love to know if anybody has ever tried to exceed this.

 

Bonus fun tip:  Ever notice the paintbrush tool on the tools palette for the BD?  Any serious (or not-so-serious) uses?

 

 

0 Kudos
Message 1 of 14
(3,686 Views)

Wiring 0 is not the same as omitting the Wait function.  LabVIEW's internal scheduler will check to see if there are parallel nodes which are ready to execute after each iteration of a loop with a zero ms wait.  The loop without the wait will try to run to completion without sharing CPU resources with other nodes.

 

Lynn 

0 Kudos
Message 2 of 14
(3,673 Views)

Darin.K wrote:

Any tips about cutting the number of clicks required to get a while loop plus Wait function wired to a reasonable value. 

 


 

I have three VI's on my personal palette configured for "Place VI Contents" (old-school users will remember that feature as "Merge VI)". These VI's will place a small, medium, or large while loop on the BD with a 50mS timer already in it.

 


Darin.K wrote:

... Ever notice the paintbrush tool on the tools palette for the BD?  Any serious (or not-so-serious) uses?


I use it quite a lot. My state machines often have "visual separators" which I might paint in order to see them (avoid them) quickly as I'm cycling through the cases. I might paint a "to-do" area. I might paint a disable cases red, to remind me of something come Monday morning. Notes to myself are often a bright color. etc etc.

Richard






0 Kudos
Message 3 of 14
(3,654 Views)

Even better than the standard issue Wait is the Wait function from OpenG.

This includes an error in/out cluster, so no more sequence structures just to put waits in some frames!

Message Edited by Cory K on 08-19-2009 01:41 PM
Cory K
Message 4 of 14
(3,648 Views)

Bonus fun tip:  Ever notice the paintbrush tool on the tools palette for the BD?  Any serious (or not-so-serious) uses?


What tools palette?

--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 5 of 14
(3,624 Views)

For "idle" loops where I have one or two boolean controls, I typically use either 50 or 100 ms.  However, I don't buy the "water to a fish" statement because I have some much more involved loops that don't need any additional delay due to the execution time of the code in the loop (typically multiple instances of instrument communications over the GPIB).

 

Also, I used to enclose (almost) all of my main executables in a while loop so that they repeatly run until I tell them to stop.  But I had found a few of them experiencing a noticeable screen flicker when I did this.  Eliminating the loop in favor of using the "run continuously" button eliminated the flicker.  Not using stand-alone exes for that, of course.  Also, the issue may be related to the processor speed of my old clunker (a pentium 3 system) - I haven't spent much time on it.

 

Regards,

 

Michael Tracy

Synergy Microwave

 

0 Kudos
Message 6 of 14
(3,608 Views)

Tim, I am referring to the Block Diagram Tools Palette.  In a BD window, View -> Tools Palette.

 

Mike, You can have water (while loop) with no fish (wait), but I am curious if you ever have the fish but no water.  A convoluted way of saying I really have never used the wait function outside of a while loop.

0 Kudos
Message 7 of 14
(3,590 Views)

I have used Wait between a VISA serial write and read in case the instrument needs a little time to respond after being queried, thus usage is not within a while loop.

 

-AK2DM

~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~
0 Kudos
Message 8 of 14
(3,579 Views)

Lynn,

 

So does this mean that to enable the while loop to run as fast as possible (if that's what you want to do) without causing problems (i.e. race conditions) is to include a Wait ms but to wire 0 to it?

 

Thanks,

 

Battler. 

0 Kudos
Message 9 of 14
(3,549 Views)
A 0 ms wait will allow the loop to run with no delay, but will still yield just enough time to the CPU so it can handle other tasks.  This has nothing to do with Race conditions with is a whole other animal.
0 Kudos
Message 10 of 14
(3,547 Views)