09-19-2010 03:42 AM
Hi,
Starting it isnt a problem, in my main while loop I have the button hooked up to a case structure and when its pushed the case structure goes off, and the sub-while loop inside the case structure starts.
But then if I release the button, I want the while loop to stop running.
09-19-2010 04:23 AM
Hello... You can use the inverse input of the same button to stop by using the property node or local variable.....
09-19-2010 08:24 AM
Hi !
I've attached the solution !!!
It's not very diffivult to understand but if you have problems please don't hesitate to comment here.
P.D:don't forget Kudos 🙂
09-19-2010 01:24 PM
@kklvuyovb wrote:
I need to use one button to start AND end a while loop.
Starting it isnt a problem, in my main while loop I have the button hooked up to a case structure and when its pushed the case structure goes off, and the sub-while loop inside the case structure starts.
But then if I release the button, I want the while loop to stop running.
Is there any way to do this? I know it could easily be done with 2 buttons (one in the main while loop hooked up to the case structure and one in the sub-while loop to end it) but is there any way to do it with one? Its a hastle to have 2 buttons for the purpose im using this for.ThanksRaman
Raman,
You might want to redesign your program layout from scratch, because what you are trying to do is probably misguided. It is typically not a good idea to stack interactive while loops. Take two steps back and think about the overall program flow.
What you need is a simple state machine with one global loop, the code of your inner while loop is then just one of the states of the outer while loop.
Can you attach some of your code so we get a better idea what you are trying to do. What's happening in the inner loop?
What is your LabVIEW version?
@jordi wrote:
I've attached the solution !!!
It's not very diffivult to understand but if you have problems please don't hesitate to comment here.
This is not very good code and just complicated the overall program design. It also needs at least a wait in the FALSE case else it consumes 100% of the CPU while not doing anything useful.
09-19-2010 04:07 PM
Yes, I agree with you.
A fast solution for that could be the following...
09-19-2010 04:34 PM
It's still not good, because the VI cannot be stopped with the stop butten while the inner loop is executing.
Here's what I meant (LV8.0).
(Even better would be an event structure, switching the timeout from infinity to a finite value and vice versa if the boolean is operated)
09-19-2010 04:58 PM
altenbach wrote:(Even better would be an event structure, switching the timeout from infinity to a finite value and vice versa if the boolean is operated)
Here's an example for that.
09-20-2010 11:31 AM
Another solution is to use two while loops. One to wait for the button to be pressed in order to start the program. The other is to run the program itself.