LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

while loop does not stop

Hi all.
 
I wonder how can I stop the inside loop. I got one while wich is like a main loop. Then, I got a button that is a condition to enter in another loop. I read this 2 threats:
 
There is an example vi example that I though that could help me, but it is a little bit diferent from what I want, since the button is also a condition. The example I mention makes the 2 buttons inside the inside looper. making a OR condition to stop the inside loop. And one of the buttons goes to the outside loop.
 
I tried to make a NOT, but seems that he wants the button inside the inside loop, like the example I mentioned.
 
What I want is: The condition to enter in the case, is the same to exit. So, when I switch off, I want the loop to stop and back to the ouside loop. It happens, this is, the case is breaked and it get back to the outside loop but the inside loop stills working...Smiley Very Happy
 
Here is my vi.

Message Edited by marcoadf on 09-11-2006 06:04 AM

0 Kudos
Message 1 of 16
(5,033 Views)

Good morning,

I cannot see your attached vi.  Can you repost it?  (In LV7.1 if possible)

I think I understand what you are trying to do.  I'll try to prepare an example.

RayR

0 Kudos
Message 2 of 16
(5,024 Views)

Sorry. Thanks.

0 Kudos
Message 3 of 16
(5,018 Views)
Hi, Marcoadf:

When the program enters the inner loop, your boolean has always TRUE value, so you'll never end the inner loop.

If you want to close the inner loop with the "comando manu" button, then you should insert a local variable of "comando manu" inside the inner loop and read that value.

Hope it helps,
Aitortxo.
0 Kudos
Message 4 of 16
(5,011 Views)

Another approach is to use a Property Node inside the inner loop and read the Value.

I am curious.  What is the False Case?  Is it empty?  If so, the only difference between the two would be the Query device & initialize Joystick,right?

Because, as soon as the boolean is False, the inner loop stops.   In this case, in order to run, it has to be true because of the Case Statement.

Is this piece of code called from another higher-level vi?

I'll explain...  It may be possible to simplify this vi by moving the switch to the inner loop, especially if you do not intend to use it to stop the outer one.

If you do not want the subvi (inside the inner loop) to run even once, then place a case statement inside the while loop which would contain the sub-vi and the indicator element.  Doing so would provide similar functionality and cleaner code without having to use Local Variables or Property Nodes, thus being more efficient with memory.

And a bit more fun to implement...  😉

RayR

0 Kudos
Message 5 of 16
(5,000 Views)

Thank you both for the help.

Aitortxo:

That's true, when it enter in the inner block it has true value, that's why I make the NOT, because the condition is "stop if true".

JoeLabView:

Yes, the only diference is because of the query and initialize, because it takes a lot of time, and I just need to make it one time. The loop is to read data frm joystick.

"It may be possible to simplify this vi by moving the switch to the inner loop, especially if you do not intend to use it to stop the outer one" Indeed, I use another button to the out loop (like a main loop mentioned). Should I put modify the "Comando manu" inside the inne loop? and this also works for the condition in the case statement?

0 Kudos
Message 6 of 16
(4,983 Views)

Hello,

What I described is how to simplify the vi.

Actually, I would move the Query & initialize joystick completely outside the loops.  Unless you want this to be done each time the outer loop executes..

There are many ways to implement a solution.  The important part is to implement the solution in a way you expect it to run.

Have you done a state machine for this?  Just to look at the logical flow?

RayR

0 Kudos
Message 7 of 16
(4,969 Views)

Well, my idea was that it only execute the outsider loop one time(when I turn button true). Then it was always in the inner loop reading data. When I wanted him to stop, just turned button off.

I think taking the those block off the loops wiil be the best solution. The idea was that I could have the button off for a long time. When I plugged the joystick I would see if there was a joystick present. But you awared me to the outside loop. Is it running at the same timeas the inner loop?I mean, the outer loop will only repeat a loop when the case statement ends right?

0 Kudos
Message 8 of 16
(4,964 Views)

From the sounds of it, it appears that you may not need the outer loop, unless, like you said, you want it to run and monitor when a device is plugged in.

That being said, you could keep the outer loop.  Then simply mode the Commando Manu switch inside the inner loop and use it to stop the outer loop.

RayR

0 Kudos
Message 9 of 16
(4,956 Views)
In that way, Labview doesn't let me use as condition of the case structure.
0 Kudos
Message 10 of 16
(4,951 Views)