10-11-2010 01:05 PM - edited 10-11-2010 01:07 PM
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
10-11-2010 01:18 PM
You need to call the subvi dynamically and set Wait Until Done to false.
10-11-2010
01:21 PM
- last edited on
09-14-2025
04:00 PM
by
Content Cleaner
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.
10-12-2010 08:46 AM
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.
10-12-2010 09:36 AM
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.
10-12-2010 11:17 AM - edited 10-12-2010 11:18 AM
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.
10-12-2010 11:25 AM
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.
10-12-2010 11:39 AM
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.
10-12-2010 11:51 AM
@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.
10-12-2010 12:38 PM
Thank you Bob, really a good example, saved a lot of time. I will implement this logic in my main vi.