Brian B Posted July 25, 2008 Report Share Posted July 25, 2008 I'm looking for some help with some code that I am trying to write. The problem is that the top level program is the only vi that the user has access to and I have many subvi's running for an extended amount of time. My question is, how do I get a subvi that may be running for an hour or so to exit from commands from the main vi? I have tried using a global variable to pass the stop command with, but the main vi is totally ignored during execution of any sub vi's. An example of what I am trying to do is attached. Quote Link to comment
LAVA 1.0 Content Posted July 25, 2008 Report Share Posted July 25, 2008 QUOTE (Brian B @ Jul 24 2008, 09:18 AM) ...I have tried using a global variable to pass to the stop command with, but the main vi is totally ignored during execution of the sub vi. ... No time to down load and diagnose but... I suspect the global is not being written or not being read in the active code. Watch both the main and a sub-VI in execution highlighting and observe when the gloabl is being read and when it is being written. The light-bulb reveals all. Ben Quote Link to comment
pallen Posted July 25, 2008 Report Share Posted July 25, 2008 Hi Brian, Not sure exactly why you've set things up this way. But it looks like the quick "fix" is to pull your subVI out of the While Loop in your top VI. The way you had it inside the While Loop, it was constantly be re-started every iteration of the loop. Quote Link to comment
Brian B Posted July 25, 2008 Author Report Share Posted July 25, 2008 pallen, I am running a nested loop architecture becuase my program is running several pieces of equipment that need to be changed programatically during certain stages of the test. The reason that I am trying to exit the subvi indirectly is in cases where some device in the test was set wrong or the device under test just blew up. I am trying to avoid displaying the subvi for many reason but mostly because I have up to four loops nested and it would get to be an excess of windows displayed. This would end up covering up the data that the user does need to see in order to know if the test needs to be aborted for some reason, and also causes a lot of windows "blinking" open and close. Using the abort button is also not an option as I need to exit gracefully in order to shut down test equipment to avoid further damage and save data to see why a problem was generated. Brian Quote Link to comment
crossrulz Posted July 25, 2008 Report Share Posted July 25, 2008 Your problem (at least in this example) is that the global variable is only being written to immediately coming into the loop. The loop is then dominated by the subVI. Therefore the global to exit the subVI will never be written to again. The following recommendation is only for GUI stop commands, but it might lead to other ideas for your specific situation. Use another loop with an Event Structure in it. Set an event to "Stop" value changing and then write the new value to the global variable. This will then end the subVI. As long as you don't have a Timeout event case, the event structure uses no cpu cycles until a registered event happens, so performance issues are nonexistant. My edited code for the top level VI is attached. Quote Link to comment
Brian B Posted July 25, 2008 Author Report Share Posted July 25, 2008 crossrulz, I can't look at your example because I don't have version 8.5 installed. I have found something that works that seems a little simpler than what you describe but along the same lines. Thanks for your response. Quote Link to comment
crossrulz Posted July 25, 2008 Report Share Posted July 25, 2008 QUOTE (Brian B @ Jul 24 2008, 01:02 PM) crossrulz,I can't look at your example because I don't have version 8.5 installed. I have found something that works that seems a little simpler than what you describe but along the same lines. Thanks for your response. Sorry. I should have looked at what versions you had. I just did a save for version 8.0. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.