LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

killing loop in subvi from main vi

I have a subvi that runs a loop taking a series of images from a camera, but if I want to end the loop my main vi is running in, I have to wait till the subvi loop ends therefore moving back into my main vi. Any suggestions?

0 Kudos
Message 1 of 7
(2,862 Views)
0 Kudos
Message 2 of 7
(2,846 Views)

Well you probably shouldn't have a long loop inside a subVI.  Perhaps you should redesign your approach. 

 

However if you insist on having the loop within the subVI, I would recommend using either a functional global, a shared variable, or a notifier.  All of these should allow you to flag the subVI to stop the loop whenever the Main VI wishes.

 

Could you explain more precisely when you want to stop? I.E. Only for emergency exit, take pictures until you tell it to stop then resume Main VI, etc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If someone helped you out, please select their post as the solution and/or give them Kudos!
Message 3 of 7
(2,824 Views)

use an'eventstructure' to respond instanly to the user interface and a notifier with "0" wait connected to the stop control of that sub.vi loop

 

0 Kudos
Message 4 of 7
(2,806 Views)

Are you sending any data to this subVI already?  Almost always when I have a long subVI, it is actually running off on its own in parallel with my main VI's loop.  I then use a queue to send commands to it.  Commands may include Start, Stop, Log File, etc.  So the Stop command coming from the queue will stop the subVI.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 7
(2,788 Views)

@crossrulz wrote:

Are you sending any data to this subVI already?  Almost always when I have a long subVI, it is actually running off on its own in parallel with my main VI's loop.  I then use a queue to send commands to it.  Commands may include Start, Stop, Log File, etc.  So the Stop command coming from the queue will stop the subVI.


I guess this is really just a variation of a QSM except that the state machine loop is just made into a subVI?  (This is just for my personal understanding.)

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 6 of 7
(2,775 Views)

@billko wrote:

@crossrulz wrote:

Are you sending any data to this subVI already?  Almost always when I have a long subVI, it is actually running off on its own in parallel with my main VI's loop.  I then use a queue to send commands to it.  Commands may include Start, Stop, Log File, etc.  So the Stop command coming from the queue will stop the subVI.


I guess this is really just a variation of a QSM except that the state machine loop is just made into a subVI?  (This is just for my personal understanding.)


Not reallly.  More of a QMH (Queued Message Handler).  I like to have loops that do one specific thing (like reading from a DAQ, writing to a file, etc).  So some (like the file writer) will only react to commands.  Others (like the reading from a DAQ) will have a 0ms timeout while commanded to be active, basically looking for the stop command.  So in this way, I can control any of my parallel processes just by sending a message down their queue.

 

Though, now that I'm thinking of it, this is sounding a lot like the Actor Framework.  I really need to start studying up on that.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 7 of 7
(2,761 Views)