LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

launch vi from vi

I have been looking through the forum but havent found an answer to my question.  I have a main VI that collects input from the user and reads an angle off of an encoder and logs data.  I have a second vi for controlling the motor that the encoder is connected to.  The encoder logging program opens first and there is a bit of user interface.  After the user interface the program starts logging the encoder values.  Once the program gets this far I want it to launch the motor control vi and have the motor control vi run in parallel.  I am not sure how to accomplish this as placing the motor control as a subVI inside the main VI causes the main VI to hault and wait for a return from the motor control.  Is there a way to launch a vi using a vi reference and have it run in parallel?  Any thoughts will be appreciated.

Cheers!
0 Kudos
Message 1 of 12
(3,691 Views)
Of course. Here is a simple example:





Message Edited by smercurio_fc on 02-08-2008 12:22 PM
Message 2 of 12
(3,685 Views)
Thank you very much!  I dont recognize the first three nodes, could you please tell me where I can find them or what their names are?

Cheers!
0 Kudos
Message 3 of 12
(3,681 Views)
Left-to-right:
  • Current VI's Path (File I/O -> File Constants)
  • Strip Path (File I/O)
  • Build Path (File I/O)
These are just to create the path to the VI to launch.

Message 4 of 12
(3,676 Views)
I see.  This is assuming that the vi I am launching and the vi that will be doing the launching reside in the same directory at the same level?  Just want to make sure I follow correctly.

Cheers!
0 Kudos
Message 5 of 12
(3,671 Views)
Also, Will placing this in a executable cause any issues?  I appreciate all of your help!

Cheers


Message Edited by jmcbee on 02-08-2008 11:45 AM
0 Kudos
Message 6 of 12
(3,667 Views)
In my case it was, which is why it's coded that way. Fundamentally, you need to provide a path to the Open VI Reference function. How you specify the path to the VI that you need to launch is up to you.

Just be aware that if you build your code into an executable, you will need to include the dynaminally launched VI in the list of dynamic VIs, otherwise it will not be included in the executable.
Message 7 of 12
(3,665 Views)
Thank you very much for the help!  Its another tool in the toolbox.

Cheers!
0 Kudos
Message 8 of 12
(3,662 Views)
I suppose I should also ask about programmatically closing this vi, as I need to have control over that as well.  I am assuing that obtaining the reference stays the same, can I use the FP.Close method to close the VI cleanly and then close the reference after that?

Cheers!
0 Kudos
Message 9 of 12
(3,650 Views)
The answer really depends on how you're coding this dynamic VI. Setting the FP.Close property to False is essentially the same as clicking the red X close button in the window's title bar. This may not "cleanly" close your VI, especially if you're opening references and the VI doesn't have the chance to close them. Chances are they would be closed automatically, but if, in the more general case, you're doing file I/O, you certainly don't want the VI to abort in the middle of a file write, as that might corrupt the file.

There's a variety of mechanisms that you can use to basically instruct the VI to close. Some possibilities:
  • Global variable flag
  • Queues
  • Setting the value of a front panel control (e.g., programmatically clicking a "Close" button)
 An alternative is to not do any of this, and simply have a "close" button on this VI that the user can press to close out the VI.
0 Kudos
Message 10 of 12
(3,634 Views)