LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stop a sub VI from main VI

Solved!
Go to solution

Hi,

I have an application that command a DAQ via tcp.

In the main loop I wait for instruction (listening for new tcp connection) and, if i read a particular string, I start the acquisition using a sub VI.

If I read another string I need to stop the subVI and return a result.
I'm able to do that, but only with a push button (switch when pressed), and I don't understand why it doesn't work with boolean values (in the pentagon: if I read "OF0" I will stop the program)..

I attach an image of my program.
Thanks to all,
Veronica

 

(The main VI is a modify of Multiple connections - server.vi example.)

 

Download All
0 Kudos
Message 1 of 41
(5,099 Views)

Is there anyone?

0 Kudos
Message 2 of 41
(5,052 Views)

Dear Veronica,

 

Thank you for providing those screenshots of your program.  As a word of advice I wouldn't put while loops or event structures in a sub-vi.  You will run into difficulties such as the ones you describe.  Looking at your code; I think you are making life difficult for yourself with this architecture.

 

The common use for booleans and event structures are inside a while loop with the boolean control inside the event structure.  If you see Example 1 - RW.vi when the button Generate Data is pressed it returns to it's false state.  Whereas in Example 2 - RW.vi the button has a switch behaviour even though it has a latch mechanical action.

 

I hope this information is useful.


Kind Regards,

Robert Ward
Applications Engineer, NI
Download All
0 Kudos
Message 3 of 41
(5,049 Views)

@Rob_Ward wrote:

Dear Veronica,

 

Thank you for providing those screenshots of your program.  As a word of advice I wouldn't put while loops or event structures in a sub-vi.  You will run into difficulties such as the ones you describe.  Looking at your code; I think you are making life difficult for yourself with this architecture.

 

<snip>



I disagree.  As long as you really understand event structures and while loops, you are actually making life difficult by NOT placing them in sub-VIs.  But perhaps you meant that those particular structures inside a sub-VI should be as independant as possible from events occuring outside of it?  That would make more sense  :).

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 4 of 41
(5,031 Views)

Iwould be in some serious trouble if I couldn't put event structures of while loops in subVIs.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 5 of 41
(5,007 Views)

Thanks for replies.

I can't open these examples because I have labview 2010.

A practical idea? I hope that what I want to do is possible, because this is a little part of a big project and I hope that I will not have to change everything!

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

Who said me that is possible, can explain me how?? Please!!

0 Kudos
Message 7 of 41
(4,936 Views)

Anyone that can help me??? PLEASE!!
I don't understand why I can stop a while into a subVI with a button (and references) and not with a variable!
I wait for an expert Smiley Sad

0 Kudos
Message 8 of 41
(4,871 Views)

@Skeggy88 wrote:

Anyone that can help me??? PLEASE!!
I don't understand why I can stop a while into a subVI with a button (and references) and not with a variable!
I wait for an expert Smiley Sad


I think you will find the tutorials on state machines fascinating reading.  😉

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 9 of 41
(4,842 Views)

You may want to look at Ben's post here too.

Message 10 of 41
(4,826 Views)