km4hr Posted October 28, 2008 Report Share Posted October 28, 2008 My first experience creating a subVI is failure . The first use of the subVI works fine. But when I create a second instance they interact with each other. They appear to share data somehow. That is, when I probe a wire inside one of the subVI instances I see values that should only be present in the other instance. I created the subvi in literally "textbook" fashion. Everything falls into place just like an example from the book "LabVIEW 8 Student Edition". My code works fine when not used in a subVI. That is, when I "cut-and-paste" the code multiple times it works correctly. But when I encapsulate the code in a subVI I get interaction between instances. Has anyone else ever had this problem? What did you do about it? Quote Link to comment
Minh Pham Posted October 28, 2008 Report Share Posted October 28, 2008 QUOTE (km4hr @ Oct 27 2008, 10:51 AM) My first experience creating a subVI is failure http://forums.ni.com/t5/util/emoticonspopuppage' target="_blank"> . The first use of the subVI works fine. But when I create a second instance they interact with each other. They appear to share data somehow. That is, when I probe a wire inside one of the subVI instances I see values that should only be present in the other instance. I created the subvi in literally "textbook" fashion. Everything falls into place just like an example from the book "LabVIEW 8 Student Edition". My code works fine when not used in a subVI. That is, when I "cut-and-paste" the code multiple times it works correctly. But when I encapsulate the code in a subVI I get interaction between instances. Has anyone else ever had this problem? What did you do about it? can you post the vi(s) so i can understand your problem better? Quote Link to comment
Karissap Posted October 28, 2008 Report Share Posted October 28, 2008 Try going into VI properties, go into the execution category and tick the box "Reentrant execution", this will mean each instance of the sub VI will run in its own memory space. Quote Link to comment
BobHamburger Posted October 28, 2008 Report Share Posted October 28, 2008 QUOTE (Karissap @ Oct 26 2008, 10:36 PM) Try going into VI properties, go into the execution category and tick the box "Reentrant execution", this will mean each instance of the sub VI will run in its own memory space. This will work if there is something in your subVI that is holding data in between calls. The most likely culprit for what you're observing is that you have one or more uninitialized shift registers. What you need to ask yourself is "do I need the subVI to keep data or state information from one call to the next?" If the answer is no, then initialize your shift registers appropriately, and you won't require reentrant execution. This will save memory use. If the answer is yes, then follow Karrisap's advice and go for reentrant execution. Quote Link to comment
Norm Kirchner Posted October 28, 2008 Report Share Posted October 28, 2008 EVERYONE BACK UP A STEP!! I believe what km4hr is in need of is a better understanding of what a VI is and the concept of it rather than delving into reentrant execution. He just started. Let's see how we can get you back on track. First, if a 'vi' is opened either explicitly by calling it from disk or is loaded as being a SubVI within another VI, by default, there is one copy of it in memory and anyone that uses that SubVI will call the exact same chunk of code (vi, or file if you want to think of it that way) So your first creation was not a failure. In fact it was a roaring success!!! It did exactly what it was programed to do. So please do attach your sub-vi so that we can better understand why one execution would impact the other. But know that if you do anything that causes the same vi to be used, by default, certain techniques in programming will cause one execution of the SubVI from one source to impact the next execution of the SubVI from another source. Making the SubVI reentrant will assist you in your endeavor and possibly solve your problem, but you MUST understand why you are seeing what you're seeing FIRST otherwise you will curse yourself and any other work that you will do w/ LV. ok possibly overreacting, but this is not C++ or VB. It's still programming but the constructs cause different kind of behavior that are easy to grasp and move beyond so you can continue doing your cool project! 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.