08-19-2009 12:43 PM
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?
08-19-2009 12:55 PM
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
08-19-2009 01:37 PM
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.
08-19-2009 01:41 PM - edited 08-19-2009 01:41 PM
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!
08-19-2009 02:55 PM
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?
08-19-2009 03:46 PM
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
08-19-2009 04:31 PM
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.
08-19-2009 05:30 PM
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
08-19-2009 10:16 PM
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.
08-19-2009 10:23 PM