From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

A question about local variable

I want to create a local variable for a boolean button ('Stop'), and use the local variable as a condition of a while loop.
But then the labview will send me an error message saying that "Boolean 'stop': boolean latch action is incompatible with local variables".
So what should I do if I want to control two while loop with one boolean? Many thanks!!
0 Kudos
Message 1 of 7
(3,606 Views)
There's a number of options..  You can change the latching method of the control to switching, which is acceptable for boolean variables.  You could also use a property node (right click->create->property node->value) to obtain the value of the control.

If you want to get fancy, queues are usually the way to go.
0 Kudos
Message 2 of 7
(3,600 Views)
Hello:

Just to complement the previous comment. If you want to change the mechanical action of the button, in the front panel right click the button, select Mechanical Action and then choose one of them. Switch is compatible with local variables while Latch is not. Look in the LabVIEW Example Finder for the VI called Mechanical Action of Booleans to see and example of the use of each mechanical action.

Hope this helps!

Robst.



Robst - CLD

Using LabVIEW since version 7.0


0 Kudos
Message 3 of 7
(3,595 Views)

You can also use a functional global such as the one attached.  You write a value to the functional global in one loop and read from it in the other loop.  This is also good because it allows you to use other conditions for stopping the program, if desired.

Make sure that you write a value of false prior to starting your reader loop so that your second loop doesn't stop prematurely.

0 Kudos
Message 4 of 7
(3,590 Views)
Personally, I perfer event structures, they allow you to keep the latch action. See attached (LabVIEW 7.0).
 
.
Message 5 of 7
(3,575 Views)

Altenbach,

I didn't realize that you could have multiple event structures monitoring the same control.  That's a good way to do it.  I gave you some stars.

With regard to the latching problem, I have in the past made "latching" functional globals for this purpose, but this only works if there is only one reader (as soon as it's read it returns to False).  To accomplish this all that is necessary is to send a False out the right shift register upon any read.

Message Edited by John Rich on 10-06-2006 03:38 PM

0 Kudos
Message 6 of 7
(3,566 Views)
Thanks!
 
One very big advantage of the event approach is in cases where some of the loops run very slowly. For example if a loop only runs once every 10 seconds, it might take a long time to stop the VI using local variables.
 
If you use events as in my example and determine the loop timing with the event timeout, the stop happens immediately, even if the timeout case only executes once a minute. 😉
 
0 Kudos
Message 7 of 7
(3,550 Views)