LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems calling SubVI

Solved!
Go to solution

Hi,

I am currently writing a program in which I need a "pop up" SubVI.

The SubVI opens when the user presses a button and closes again when it is finished. I am doing this with an event structure.

Tha main program consists of several while loops.

 

When I start the program for the first time, everything will run fine. If I now stop the main program with the LabView stop button and the restart the program, everything is still running fine.

If I however stop the program by terminating all the while loops in the main program and then restart and Call the SubVI, the main program will behave as if everything works fine, however the SubVI Frontpanel (or the entire SubVI, I don't know) won't open.

 

I really have no Idea what I did wrong there. Apparently the way I close the program does make a difference. As I undestand it, however it shouldn't, should it?

Or does it matter, that the "Pop Up" Sub-VI is called in an extra SubVI that doesn't pop up?

 

I have tried to reproduces this scenario in a simple example that I've attached. However, even though it is in all means similar to the real program, here, the error doesn't occur.

 

Maybe anyone of you had the same problem before or has an idea what happens there?

Thanks for your help!

 

 

In the attachments, "test" is the main Program!

Download All
0 Kudos
Message 1 of 5
(2,529 Views)

The problem you have is that when you use your stop button to exit the main (Test.vi) you don't actually exit. That vi is stuck in the lower loop waiting for an event to occur. First, you should have the event structure monitor the VI's stop button with a value change event. The upper loop should be waiting looking at some other value to determine if it should exit. If it looks at the value of the stop button you may exit before the lower loop exits.

 

A few other comments on the code. Try to get rid of the sequence structures. They should only be used sparingly. You do not need the outer most sequence structure. The one in your event structure is acceptable since you have no direct data flow to depend on. However, there are better ways to accomplish that as well. Try to avoid using local variables all over the place. You can easily find yourself having race conditions if you aren't very careful. Look at the producer/consumer architecture since this is basically what you are doing. Use a queue or notifier to pass messages. These are a much better methods for sending information between parallel tasks.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 2 of 5
(2,509 Views)

Hi,

Thanks for your quick help.

 

Concerning your hints about sequence structures and loical variables:

I have checked my code and of course found lots of places where I can improve my code! Especially the hint with the producer/consumer architecture helps a lot! Thanks a lot!

 

 

Concerning my problem I have tried your hints. However this didn't help.

If I understand your answer correctly it does matter wheter simultanous loops are ended simultanioulsy or not. If this is the case, that would explain why I am having troubles, as my loops most definatly do not stop simultaniously.

However I don't understand why this should matter? If the program stops, shouldn't it be irrelevant how it stopped as long as it does stop? I am defining "stopped" after the arrow in the top left.

Thanks again!

 

0 Kudos
Message 3 of 5
(2,494 Views)
Solution
Accepted by topic author kper

You may have misunderstood my earlier comments. The reason your code does not exit is that you are simply reading the value of the stop button in the loop with the event structure. That loop cannot complete until everything in it has completed. That means it is a MUST to check the stop condition after an event has been processed. Doing it outside of the event structure like your code does will mean that the while loop is sitting there waiting for the event structure to complete. This will never happen once you stop you application using the button as currently written. If you hit the stop button and then follow that with pressing the Call subVI button your application will actually stop. In addition, your event structure will not process the Stop button until the subVI (your pop-up) has actually exited. The event containing that call will not complete until the subVI completes.

 

I have posted a simple modification to your code that includes some of the suggestions I made earlier.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 4 of 5
(2,486 Views)

Hi,

Thanks a lot. Now I undestand.

And thanks again for your other comments. I have modified my code accordingly and found, that it helps a great deal!

 

0 Kudos
Message 5 of 5
(2,466 Views)