LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to return out of a subVI into a calling VI and not stop the calling function

Solved!
Go to solution

I am writing a program that consists of a calling VI and a sub VI. I want the calling function to be running continuously and be able to trigger the sub VI (via voice activation). I want the sub VI to time out automatically after 10 seconds and return to the calling (master) VI, which will continue running until the sub VI is called again.

 

I found a way to time out the sub VI using the "stop" command, but this quits the calling VI too, which cannot happen. I know there is no "return" or "soft stop" in LabVIEW, but does anyone know a way to do this?

0 Kudos
Message 1 of 8
(3,687 Views)
Since you want the subVI to stop after a certain time, you should be looking at the Timing functions. There are several functions (Tick Count, Get Date/Time in Seconds, Time Delay) there that can be used. For the first two, all you need is a subtract and greater than function. For the Time Delay, you just have wire up the Boolean output. Try to write something and if you get stuck, post your code.
0 Kudos
Message 2 of 8
(3,686 Views)

Hi! I have tried various timing functions, both in the calling VI and the sub VI. right now, I am working with a timing function in a flat sequence structure where the sub VI is positive for 10 seconds, then should be false. this works to some extent; the sub VI triggers on properly, and sometimes goes away, but it keeps coming back and it won't time out without input.

 

do you reccamend using the timers in the sub VI or the calling VI? when I used them in the sub VI, the subVI didn't reliably time out.

 

thanks for your help.

0 Kudos
Message 3 of 8
(3,675 Views)
From your description, the timer should be in the subVI. However, your description of what you want the overall application to do is not clear to me and the fact that you are using a flat sequence structure is a clue to a somewhat less than optimum architecture.
0 Kudos
Message 4 of 8
(3,669 Views)

I am a student working on a project involving voice activation. the overall idea is to have a person say a command (like go or something) that then gives them a 10 second window to say other commands and have them recognized by the program. The idea is to eliminate false positives by nesissitating a calling command that is not spoken very often, and then having 10 seconds to activate what we are trying to vocally control. I hope that helps clarify the intent of the program.

 

I was using a flat structure just because I sucessfully got the sub VI to time out using a flat structure with a boolean false on one side with a wait of 10 seconds, then a boolean true on the other that triggered a stop. this successfully ran the sub VI for 10 seconds and then stopped it; however, it also stopped the calling VI which is my problem. right now, I have a while loop in the calling VI that contains an elapsed time timer and the sub VI and it works (kind of). it sucessfullly calls the sub VI, but not for any given amount of time. it changes each time it runs; sometimes it stays running for 10 seconds before returning to the calling VI, sometimes it just flashes, and sometimes it just doesn't return. I am also experimenting with mathscript code.

 

My partners and I are all new to labVIEW, so if something seems less than optimal, it is because of our inexperience.

 

Thanks again for your help.

0 Kudos
Message 5 of 8
(3,664 Views)
Solution
Accepted by topic author sci

All that you really need in your subVI is something like what is shown below. You specify the delay time in msec. Using the Delay Function or the Get Date/Time In Seconds would work in a similar manner.

 

 

Message Edited by Dennis Knutson on 03-22-2009 07:07 PM
0 Kudos
Message 6 of 8
(3,656 Views)

I put my sub VI in a while loop and put this in the while loop. It runs ok, but it isn't stopping. I think I have the wrong thing where you have the duration. is that just an indicator, or is that a node? because right now, it is always returning zero, and the loop just keeps running. I will experiment with the location of the while loop.

 

Thanks again for your help.

0 Kudos
Message 7 of 8
(3,637 Views)

Never mind it totally worked! thanks so much for your help, you just made my life way easier.

 

 

0 Kudos
Message 8 of 8
(3,635 Views)