LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Vi to switch between Programs without restart

Good Morning,

 

I am looking for some help to program a Vi to switch between different "Sub Vi´s".

The objective is to generate a Mask to switch between 3 or more programs. The Programs itself have some parameters the user should be change and i need something like a start button so they dont start after switching the Tab.

At the moment i am using the "Tab Control" but if i change to the other Tab the program starts immediately. But if i insert a "start-button" the program cant change the Tab after the first change or it runs very slowly and i cant change the parameter of the Programs.

 

The two different programs are working.

 

Its very difficult to explain the problem for me. I hope with the Vi in the attachement it is possible to understand.

It is not necessary to switch between the progams as long one of the progams is running (this should be not possible). Only if the program is finished it should possible to change the Program

 

Gruß

Chris

0 Kudos
Message 1 of 8
(2,498 Views)

Do not use the tab.  Turn you "programs" into subVIs.  You top level VI should just be a launcher.  So just have buttons to launch the desired "programs".  Look into the Start Asynchronous Call to launch your VIs.  Those VIs can show their front panels and show whatever necessary settings.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 8
(2,443 Views)

thx for the answer, i combined the Tab´s with a start button and it works. I have only one Problem with one of the three Programs. The first Control (Microcontroller Ansteuerung its the name) is working if i switch to the Tab and press the start button and after this i can use the "Command to send" Box without any Problems. But if i switch to the tab and write something without pressing the start button before the Programs dont react anymore the only way to stop is to click on the "abort execution" item in the menubar.

 

I dont know how to fix it because i get no error messages or crash. I thought its in a Loop but i cant see anything.

0 Kudos
Message 3 of 8
(2,402 Views)

@Chris202002 wrote:

thx for the answer, i combined the Tab´s with a start button and it works. I have only one Problem with one of the three Programs. The first Control (Microcontroller Ansteuerung its the name) is working if i switch to the Tab and press the start button and after this i can use the "Command to send" Box without any Problems. But if i switch to the tab and write something without pressing the start button before the Programs dont react anymore the only way to stop is to click on the "abort execution" item in the menubar.

 

I dont know how to fix it because i get no error messages or crash. I thought its in a Loop but i cant see anything.


If you have a problem then it doesn't work. The program that you posted previously is going to be nothing but a headache, and I expect that the new version that you didn't post is no better.

 

Here are just a few problems with your code that I noticed at first glance:

 

1. You have Event structures inside of Event structures.You should really only have one event structure, and especially not have them nested. Without seeing your code I'm guessing that this is the source of your problem.

 

2. You have and Filtering event for the Panel close? but you do not handle this event.

 

3. You are structured so that you have multiple stop buttons.

 

4. Why are you using bytes at port? Does your data have a termination character? If so just read a large amount of bytes - it will stop at the termination character. 

 

5. Why do you have a FOR loop with 1 wired to the iteration terminal?

 

Please reconsider the advice that crossrulz gave you above. 

 

Edited to add: Your updated program was not showing up when I first wrote this response. It looks like a couple of these things have been fixed (I no longer see the nested Event structures, for instance), but it's hard to tell with such a large footprint. Please try to make your program fit on one screen.

0 Kudos
Message 4 of 8
(2,385 Views)

1. You have Event structures inside of Event structures.You should really only have one event structure, and especially not have them nested. Without seeing your code I'm guessing that this is the source of your problem.

 

In the actual version i have no event structures nested. It changed nothing but its easier for me to handle.

 

2. You have and Filtering event for the Panel close? but you do not handle this event.

 

Yeah I saw this in many Guides and one or two weeks ago i had some questions to the Program and this is one of the not used leftovers.

 

3. You are structured so that you have multiple stop buttons.

 

I have one Stop button for the whole VI and one Button for every Sub VI. The user spot only one for the "Sub VIs" and the one for the whole program to the same time.

 

4. Why are you using bytes at port? Does your data have a termination character? If so just read a large amount of bytes - it will stop at the termination character.

 

The bytes at port only checking if there are any bytes at port because if there are zero bytes and i start to read an error occurs.

 

5. Why do you have a FOR loop with 1 wired to the iteration terminal?

 

It was the easiest way to start only one measurment. Through the Loop the Power generator stops after the measurment another possibility should be to work with the OPC from the Analyzer and an Case Structure before stoping the Power generator

 

Thx for the Interest

 

Hmm the Asynchrounus mode Iam not sure its the way my VI should work. Its not necessary that more then one "program" is running at the same time.

0 Kudos
Message 5 of 8
(2,375 Views)

@Chris202002 wrote:

 

 

3. You are structured so that you have multiple stop buttons.

 

I have one Stop button for the whole VI and one Button for every Sub VI. The user spot only one for the "Sub VIs" and the one for the whole program to the same time.

You do not have this structured with subvis. Your "subvis" are just parts of your main vi. The approach that crossrulz suggested does not necessarily have to be asynchronous (though I like that approach). You can have buttons for each "program" on the main or, perhaps preferably, you can have a menu or a ring. Using a Value Changed Event you can make it hide the main front panel, call the appropriate subvi with settings to open front panel when run and close when done, and then unhide the main front panel when you exit the subvi. This achieves the goal of being able to select a program, run that program, and then return to select another program. 

 


@Chris202002 wrote:

 

4. Why are you using bytes at port? Does your data have a termination character? If so just read a large amount of bytes - it will stop at the termination character.

 

The bytes at port only checking if there are any bytes at port because if there are zero bytes and i start to read an error occurs.

 


What kind of error were you getting? Was it a timeout? Perhaps you need to either increase the timeout or handle the timeout error. If it is some other error then post more information and someone here will likely be able to give you some better guidance on how to better get rid of the error.

 


@Chris202002 wrote:

 

5. Why do you have a FOR loop with 1 wired to the iteration terminal?

 

It was the easiest way to start only one measurment. Through the Loop the Power generator stops after the measurment another possibility should be to work with the OPC from the Analyzer and an Case Structure before stoping the Power generator

 


If you want it to execute the code only one time then you do not need the FOR loop. Are you saying that in the future you might want to change this value?  If so then I understand.

 


@Chris202002 wrote:

 

Hmm the Asynchrounus mode Iam not sure its the way my VI should work. Its not necessary that more then one "program" is running at the same time.


Actually, the way your code is working now (as you describe it, not really how it is working) is asynchronous. You have the main vi calling the functions that you are calling subvis. If those were really subvis (running in a subpanel, for instance) then you would have two vis running at once (even though the top level is sitting idle). As I discussed above, you don't necessarily have to use an asynchronous call, but you might want to at least consider it. For instance, in the future you might have a desire to start some process and monitor it. If you used the asynchronous approach then you could do that without having to change the entire structure of your program. Also, making subvis for your separate programs makes it much more modular - you could easily add to or take away from the program without impacting the remainder of the program.

0 Kudos
Message 6 of 8
(2,362 Views)

ok iam looking for a way to change the Mainmenu. Iam testing the Event structure and shift register at the moment for something linke a state machine. Is this what you mean before?

 

My Problem is without the "Tab Control" i find no way to change the hole display to my Sub VIs and I cant use the "Tab Control" because it is handled like an Indicator in the Block diagrm.

 

My idea was to use some buttons in a Main menu to change the Tabs from the Tab Control and in every Tab one button to get back to the main menu. but its not possible for me to change the Tabs with some buttons. And i found no other way to change the Interface.

 

Gruß Chris

0 Kudos
Message 7 of 8
(2,306 Views)

@Chris202002 wrote:

ok iam looking for a way to change the Mainmenu. Iam testing the Event structure and shift register at the moment for something linke a state machine. Is this what you mean before?

 

My Problem is without the "Tab Control" i find no way to change the hole display to my Sub VIs and I cant use the "Tab Control" because it is handled like an Indicator in the Block diagrm.

 

My idea was to use some buttons in a Main menu to change the Tabs from the Tab Control and in every Tab one button to get back to the main menu. but its not possible for me to change the Tabs with some buttons. And i found no other way to change the Interface.

 

Gruß Chris


Why do you need the Tab? If you put your programs in a subvi then you can make that subvi front panel open - you could even hide the main panel in the background if you want. This gives the ability to have each of your programs with their own front panels and operation. The Main program would then just have buttons, a ring selector, or some other means to select the program to run. I've attached an example (the subvis really don't do anything, but it shows you how they can be launched).

0 Kudos
Message 8 of 8
(2,301 Views)