LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to close a while loop in a subvi from a mainvi?

Hi,

Is there a way to close a while loop in a subvi from a mainvi, while the loop is running? I have tried different things, but none of them seems to work. Labview always gets stuck in the while loop of the subvi.
To make my question clear, I have added an example. In this example I want to close the loop in subvi "loop", when I hit the button "stop" in the vi "main".

Regards, Rabbi
0 Kudos
Message 1 of 7
(3,721 Views)
Picture below shows one sollution. One can also use a global variable or a LV Action Engine to transefer the stop value from main.vi to loop.vi.
 
BR
Sture
 
 


Message Edited by sture on 12-01-2007 09:39 AM

Message Edited by sture on 12-01-2007 09:46 AM

Message Edited by sture on 12-01-2007 09:46 AM
Message 2 of 7
(3,709 Views)
Ok it works now, thank you very much!
0 Kudos
Message 3 of 7
(3,681 Views)
Seems a little bit complicated to wire the VI reference and then get the control value by the control name. It is also unreliable, e.g. if you have two controls names "Stop". It is a lot of work to do all that variant conversion with every iteration of the loop.
 
A simper way: Just create a reference to the stop button and read its value in the subVI. 🙂
 
 
 
 
 


Message Edited by altenbach on 12-02-2007 11:22 AM
Message 4 of 7
(3,648 Views)
I find both of these solutions lack a certain... elegance. I have been using references to controls, but on the same vi, and it really seems like a VERY bad idea to have explicit control references shared amongst several subvi's (What if you change the control? You have to go and change every subvi).

Attached is a compacted version of my current solution - using queues (you could probably use notifiers, but I have no idea if they work if you send whilst nothing is recieving - also I wanted to use the queue method to do more than just send stop signals, the technique should be the same). My version has the send stop signal, check for stop and releasing in seperate VI's, that obtain and release the queue as necessary (so no need to feed queue references around the diagrams). I don't know the cost of obtaining a queue, so this could be a terrible idea but there are a few workarounds I can think of.




Message Edited by Xgkkp on 12-03-2007 06:22 AM
0 Kudos
Message 5 of 7
(3,590 Views)
Xgkkp said

I find both of these solutions lack a certain... elegance.
Well, that depends on your definition of "elegant", right? Smiley Wink If by elegant one means compact, and simple, then altenbach's solution is quite elegant. If by elegant you mean something that doesn't rely on control references, then your solution is more elegant. Not very compact, though.

Message 6 of 7
(3,569 Views)

Xgkkp wrote:
I find both of these solutions lack a certain... elegance.
Well, I always prefer code the size of a postage stamp over code the size of a postcard. 😄
 
My suggestion above was an alternative to sture's solution. There's nothing wrong with it. Personally, I would probably use an action engine if really needed.
Message 7 of 7
(3,558 Views)