From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple VI on a Single Program

Solved!
Go to solution

hello,

i am using LabVIEW 2010 , i wants to call different subVIs in same program ,example 3 subVIs are there if i select subVI1 then it should run then if i stop that subVI1 only stop next if i select subVI 2 that has to run . In this concept i am facing small problem when i used to stop subVI 1  main program gets stoped . so how to use different subVI program in same main vi.

0 Kudos
Message 1 of 7
(4,091 Views)

Obviously you are not programming it right, but we need to see some code to tell what's wrong. How are you calling the subVIs? How are you stopping the various things?

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

This depends on how you are terminating your SubVis. See the example for how I think you want to make sure you terminate your subvis. When you call SubVis from a main vi, you don't want to abort or exit out of the SubVis. Instead, you want them to simply run out of stuff to do. This means, for instance, exiting all for and while loops. See the example I have attached and just open and run the main vi. Then look at the simple code for the two sub vis. Click the buttons to stop them, don't abort or exit.

0 Kudos
Message 3 of 7
(4,071 Views)

@altenbach wrote:

Obviously you are not programming it right, but we need to see some code to tell what's wrong. How are you calling the subVIs? How are you stopping the various things?



in this program i wants to run main program then if i stop1 vi1 only should stop, after that i wants to perform vi2 but stop is not working. 


@altenbach
0 Kudos
Message 4 of 7
(4,015 Views)

@majoris wrote:

This depends on how you are terminating your SubVis. See the example for how I think you want to make sure you terminate your subvis. When you call SubVis from a main vi, you don't want to abort or exit out of the SubVis. Instead, you want them to simply run out of stuff to do. This means, for instance, exiting all for and while loops. See the example I have attached and just open and run the main vi. Then look at the simple code for the two sub vis. Click the buttons to stop them, don't abort or exit.


in this program i wants to run main program then if i stop1 vi1 only should stop, after that i wants to perform vi2 but stop is not working. 

0 Kudos
Message 5 of 7
(4,008 Views)
in this program i wants to run main program then if i stop1 vi1 only should stop, after that i wants to perform vi2 but stop is not working. 

@altenbach

 

0 Kudos
Message 6 of 7
(4,005 Views)
Solution
Accepted by topic author manoj07

Hi manoj,

 

your VIs work exactly as YOU have programmed them!

All of the behaviour is dictated by THINK DATAFLOW!

 

1. You call a subVI. The subVI opens its frontpanel and runs until you stop it.

2. Then the DATALFLOW goes back to your mainVI, the next iteration of the while loop starts and your subVI is started again (within microseconds): back to point 1.

 

Simple solution: change the "vi selection" in the mainVI BEFORE you stop the subVI.

 

Better solution: only start the subVI after the user switches a dedicated START button.

General hint: Implement a better UI handling…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 7 of 7
(3,999 Views)