10-23-2008 10:50 PM
Hi All,
I am using labview 8.2.
I have two while loops in my code (one called the main loop and the other average loop - seen on the screen shot file). I just want to stop both the while loops at the same time (it is ok it the average loop takes a little longer). I am using global variables to stop (as i tried the local one, but I don't think LabView sees it in the middle of the subroutine).
Please give me some suggestion on this.
Attached is a screenshot and my labview code
Solved! Go to Solution.
10-23-2008 11:20 PM
10-23-2008 11:28 PM
Hi Lordsathish,
Thanks for your quick reply. How can I create a functional global? Could you give an example (perhaps a screenshot)
Thanks
10-23-2008 11:36 PM
10-23-2008 11:48 PM - edited 10-23-2008 11:52 PM
Using a 'functional global' is pretty much the same as using a 'global variable'. In fact, before 'global variables' existed, a functional global was how people got that functionality.
The usual way to stop a loop containing a 'wait for queue' is to destroy the queue and use the error out terminal of the 'wait for queue' straight into the stop terminal. That way you don't have to queue some sort of stop command to stop it.
Add a destroy queue after the 'main while loop' stops. Then delete the global variable and wire the error out of the 'wait for queue' in the 'average loop' to it's stop terminal.
General advice, always try to avoid using local and global variables.
10-24-2008 12:06 AM
Hi zientist,
A local should have worked as well as a Global, though, with the Dequeue timeout at -1 (wait indefinately) the loop may never stop no matter what type of variable you used.
Follow Troy's advice - see example attached!
Cheers.
10-24-2008 12:14 AM
10-24-2008 12:24 AM - edited 10-24-2008 12:30 AM
I'm pretty sure it is the way it is done in the training manuals. Least amount of overhead. I doubt you'd loose points in a CLD exam by doing it that way.
The best way to do x... who knows! How long is piece of string? It's always debatable what is the best way to do something.
In software there are good ways to do things and bad ways to do things. There is almost never only one way to do something.
If you want to be amused by some really bad ways of doing things, search this forum for 'rube goldberg code'.
10-24-2008 02:19 AM - edited 10-24-2008 02:20 AM
Troy K wrote:The usual way to stop a loop containing a 'wait for queue' is to destroy the queue and use the error out terminal of the 'wait for queue' straight into the stop terminal. That way you don't have to queue some sort of stop command to stop it.
Yes, I would go with this too. Here's a simple example that show the basics.
10-24-2008 05:41 PM
Thanks Troy and Altenbach
It works!!
Just wanted to ask, Troy why do you recommend to AVOID using global and local variables?