LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Easy Question about Polling a Bool Button

I have a while loop that executes until a certain flag comes up. I have two such loops for two different modes. So at any given point i time my program is in one of the two loops. I want a boolean button that gets read for each iteration of either loop. If I put it outside of the loops it just gets read at the beginning of the program execution and while the vi is in one of the loops it will not get checked. And if I put it in one of the loops obviously it can't get checked by both. If possible could someone post an example vi or point me the right direction?

I've only been using labview for a week and normally I just plan around things like this but I've already written a large program and didn't plan for this button. I also realize that I should NOT have to plan around little things like this, but Im still getting used to this kind of programming and don't really have a good grasp on the flow of things and am missing a lot of fundemental knowledge that would help me with things like this.

I'd be glad to post an example vi. I need to keep working though 🙂 Let me know if I'm not being clear and I'll go make one.

Thanks

Cason Clagg
SwRI
LabView 7.1, Windows XP
0 Kudos
Message 1 of 7
(2,490 Views)
Create one button and put it in one while loop. Left click on the button and select Create - Local variable. Put the local variable in the other loop. Because of the local variable, the button's mechanical action cannot be any of the latch types. Therefore, you have to use another local at the end of your program to reset the button to False.
- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 7
(2,481 Views)
Is there no way to make a latching button with this setup?
Im not quite sure what you mean about setting the bool to false at the end of the program.

Cason Clagg
SwRI
LabView 7.1, Windows XP
0 Kudos
Message 3 of 7
(2,469 Views)
You cannot have a latching button when local variables are involved. Labview cannot handle it. See attached vi to see example of resetting boolean after loops are done. If you don't do this, next time you start the vi, the boolean will be True and the loops will execute only once. You can delete the resetting code to see what I mean.
- tbob

Inventor of the WORM Global
0 Kudos
Message 4 of 7
(2,463 Views)
I posted a simple vi. I want to be able to set the randomness switch so that the CIN's will know whether or not to be random. Each loop runs until some condition from a subvi is met. The other switch selects which loop is to run. In reality this switch is another subvi which takes in numbers and outputs a bool, so i modeled it with a switch.

The Randomness is the bool switch I am trying to get shared between the two loops.

Cason Clagg
SwRI
LabView 7.1, Windows XP
0 Kudos
Message 5 of 7
(2,457 Views)
You don't need two loops to perform this action. Just put the code in the lower loop inside the false case of the upper loop. Delete the lower loop entirely. You can also eliminate the inverter on your Flag From Selecting VI by reversing the True/False cases. See attached vi. Then you don't have to worry about the other boolean, there will only be one loop to control.
- tbob

Inventor of the WORM Global
0 Kudos
Message 6 of 7
(2,451 Views)
You just need to rearrange the loops and simplyfy everything. Have a look at the attached quick modification as a guideline. Modify as needed.
0 Kudos
Message 7 of 7
(2,449 Views)