LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Running 2 or more sub vi's at a time

Iam trying to develope a vi, where it has 3- sub vi's in it. Main vi has 3- push buttons, each one of them is responsible to call a sub vi.

 

Iam able to operate the 3- subvi's from my Main vi. But Iam stuck at 2- things

 

1) Iam unable to run 2 or more sub-vi's at the same time. Its allowing me to run only one sub-vi for one instance. In order to run my second sub-vi, i have to stop the first one executing and then make run the second sub-vi, by pushing its button.

 

2) When I call the sub-vi(either Graph-1 or Graph-2 or Graph-3) form my Main vi, this vi by defaultly is running. How to modify the sub vi, so that when it is called it should not execute by itself by deafault, should wait till the user hit the run button.

 

Can any one please say how to do this.

 

Thank you

0 Kudos
Message 1 of 12
(4,195 Views)

You need to call the subvi dynamically and set Wait Until Done to false.

 

DynamicOpenVI_BD.png

- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 12
(4,184 Views)

 


pks wrote: 

1) Iam unable to run 2 or more sub-vi's at the same time. Its allowing me to run only one sub-vi for one instance. In order to run my second sub-vi, i have to stop the first one executing and then make run the second sub-vi, by pushing its button.


 

You have to launch the subVIs dynamically using the VI Server functions. Search the Examples (Help -> Find Examples) as you will find examples on how to do this. Be careful about the path you create to pass to the Open VI Reference VI. See also http://digital.ni.com/public.nsf/allkb/CB109EC8325252A18625735B0049830B, which could have been found using a search.

 

 


2) When I call the sub-vi(either Graph-1 or Graph-2 or Graph-3) form my Main vi, this vi by defaultly is running. How to modify the sub vi, so that when it is called it should not execute by itself by deafault, should wait till the user hit the run button.

The simplest way is to put the code that should be executed inside a case structure which is driven by a front panel button.

 

0 Kudos
Message 3 of 12
(4,179 Views)

Thank's for your reply smercurio and bob. I launched the sub vi dynamically (as shown in the attachment), now iam able to run one or more sub vi's at a time. But I have one more problem, I  also want to create a control where user can have the flexibility to stop the execution of sub vi from the sub vi front panel as well as from Main vi front panel.

 

With the attached logic I can stop the execution's in the sub vi's at any time  with a stop button created on the sub vi front panel. But how to stop all the execution of the sub vi's from a stop button created in Main vi front panel.

 

Thank you.

0 Kudos
Message 4 of 12
(4,147 Views)

There's a variety of ways to do this. You can use user events. You can use queues. You can set control values using the VI Server. You can use global variables (Oh, no, here come the global variable nay-sayers... Oh my god, look at them all! They're everywhere!!!! RUN FOR YOUR LIVES!!!!). Examples for each of these have been posted on this forum, so please do a search.

 

Also: You should put the Boolean control inside the event case so that the event case can read the control and reset it. This is especially important for latch-style buttons.

0 Kudos
Message 5 of 12
(4,135 Views)

Here is an example of how to stop a subvi from main or from the subvi itself.  Also, an indicator in the subvi is updated and displayed in the main by using references.  Study it.

 

Edit:  Ooops, I put an example where the vi is called staticly.  You want to call it dynamically.  OK that is another story.  I'll come up with an example shortly.

 

- tbob

Inventor of the WORM Global
Download All
0 Kudos
Message 6 of 12
(4,119 Views)

 


tbob wrote: 

  I'll come up with an example shortly.


You don't need to - examples have been posted before. Let the user learn to search and then come back for more questions.

 

0 Kudos
Message 7 of 12
(4,113 Views)

Calling a subvi dynamically and passing references to it is a tall order for a rookie.  Examples may be around but they are scattered.  I already had an example written, I just had to find it. 

 

I learn best by example so I teach by example.  I can't see making the OP spend hours searching for something I have immediately.  His time is better spent studying my code than searching for pieces and then trying to put them together, and having to come here to ask more questions.

 

 

- tbob

Inventor of the WORM Global
Download All
0 Kudos
Message 8 of 12
(4,105 Views)

 


@tbob wrote:

His time is better spent studying my code than searching for pieces and then trying to put them together, and having to come here to ask more questions.


I disagree, but you are free to do what you wish. Smiley Wink

 

0 Kudos
Message 9 of 12
(4,101 Views)

Thank you Bob, really a good example, saved a lot of time.  I will implement this logic in my main vi.

0 Kudos
Message 10 of 12
(4,087 Views)