LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Call SubVi in 2 ways

Hello

I have following question:
I have main VI in this VI I need to call a VI named "Sub_Settings.vi" to load the settings and write them to my global variables in the VI "Sub_Global_Variables.gbl.vi". When I start the main VI, the settings VI should be started and closed in the next cycle. But then I want to open the settings VI also with a button to do some changes in the settings. I've tried it with a loop construction, but the settings VI couldn't be closed. After the first call in the main programm. How can I realize that? Thanks for tipps and solutions 😉

Sebastian
0 Kudos
Message 1 of 11
(3,583 Views)
I've attached one way. The subVI has a while loop with a stop button. The stop button is wired to the connector pane. When a true is wired to the subVI, it will execute once. If a false is wired (or no constant connected), the subVI will run until the user clicks the stop button. In the main VI, I set the subVI Node Setup (right click on subVI) to Show Front Panel When Called and Close afterwards ir originally closed so that the subVI's front panel will show only when the user clicks on the Open subVI button.
Download All
Message 2 of 11
(3,583 Views)
Thank you Dennis

Your example helped me in that way, to open the subVI by using a button. But how can I load the subVI and run it once at the first time the MAIN progamm is opened? Or isn't it possible??
Thanks a lot!
0 Kudos
Message 3 of 11
(3,583 Views)
Open subVI that dennis give you,
Then go to VI properties,
then
>> Window apperence
>>> CUstomize
>>>>>enable show front panel when called
>>>>>enable close afterwards.....
then change your main vi.
remove bollean constant that connect to subVI.
Regards,
Saw
0 Kudos
Message 4 of 11
(3,583 Views)
In the example I sent, the subVI does run once the first time the main program is started. It just doesn't show the front panel. If you want the front panel to show every time the VI is run, then you can change the VI properties to do that. There's lots of ways to do what you want. I just shoed one. another powerful way to do things is with a state machine architecture. There would be an intialize state where the VI would run once and and state where the VI would run when a button is clicked. There's lot of examples on NI Zone of state machines. Do a search if you're interested in more information.
0 Kudos
Message 5 of 11
(3,583 Views)
Ok sorry, Dennis, then I haven't got that right! I think your way is the easiest. In my opinion it would take too much time at the moment to change all my VIs for the use of a state machine.
Thanks a lot!!!!
0 Kudos
Message 6 of 11
(3,583 Views)
Hello again Dennis

I've tried what you've mentioned. First it looks very fine. But as I tested it today it doesn't work. I will send you a picture of the calling WHILE loop in my main programm and my subVI that should be called! Maybe you can help may anyway. Thanks!!!
Download All
0 Kudos
Message 7 of 11
(3,583 Views)
Your main VI terminates after immediately because if the front panel Boolean is false to start with, you invert it and have the loop set to stop if true. You never get a chance to change to front panel Boolean to true to run the subVI. If you remove the Not function between the Boolean and the loop terminator, then you'll be able to start the subVI and then after it's closed, the while loop will terminate.
0 Kudos
Message 8 of 11
(3,583 Views)
Ok I've deleted the NOT at the WHILE lopp in mainVI. but the frontpanel of subVI isn't opened. What is always wrong?
0 Kudos
Message 9 of 11
(3,583 Views)
Do you do as I mentioned earlier - "In the main VI, I set the subVI Node Setup (right click on subVI) to Show Front Panel When Called and Close afterwards if originally closed"?
0 Kudos
Message 10 of 11
(3,583 Views)