03-22-2017 02:10 PM
Hello everyone,
I am trying to acquire data from my subVI and use it in my mainVI. In subVI (Whenever i run the mainVI, subVI is running and showing the data, but nothing comes to my mainVI) , its running perfectly and giving the data (true or false). But, nothing is transferred to my mainVI. I am attaching the image file of my subVI and main VI. It will be great if someone can give me some outline about solving this problem.
Thanks.
03-22-2017 02:17 PM
Hello everyone,
I am trying to acquire data from my subVI and use it in my mainVI. In subVI (Whenever i run the mainVI, subVI is running and showing the data, but nothing comes to my mainVI) , its running perfectly and giving the data (true or false). But, nothing is transferred to my mainVI. I am attaching the image file of my subVI and main VI. It will be great if someone can give me some outline about solving this problem.
Thanks.
Arnab
03-22-2017 02:23 PM
Where is your code for the subVI? Does it have a loop itself?
03-22-2017 02:27 PM
Ok, now that I think I have the duplicate threads merged and all of the information seems to be here...
Your subVI has a loop in it. Does that loop stop? If not, then your main VI cannot execute due to waiting for that subVI to stop.
03-22-2017 02:50 PM
03-23-2017 03:13 PM
Can I control my subVI from my main VI. The attached file "Nw2" runs perfectly. Based on my condition, it runs my piezostage and whenever my stage makes a contact it comes back. I am trying to execute the same thing dividing the job into two VIs. My attached subVI named "Nw2-Copy" and I am trying to control this VI from my main VI named '1'. But my command is not passed from my mainVI to subVI. Can anyone please help me(LV beginner) know my misunderstandings here or better process to resolve this issue.
Note: I have while loop running in my subVI.
03-23-2017 08:14 PM
There are so many ways to do this in Labview it boggles the mind but leads to a lot of poor designs. I think the forum approved way of doing this is with something called a Notifier.
So what you would do is in your top level VI, you have the second section of your sequence. This second part needs to do two things. One thing is just run the SubVi. The other is a while loop that busy waits on the button. When the button is pressed, you send a notification. The SubVI now needs to accept a notifier as an input. You can then in the SubVI ask if the notifier has a new notification. If it does, do the thing. Since you're just looking for a binary event, simply the presence of a notification is enough (i.e. the wait on notification vi doesn't time out). So the notifier can be literally any data type. However, you can also use the notifier to pass information with the notification.
There are many other ways to do this, including using a reference to button and reading the value of the reference. You can also send a user event which you can catch with an event structure in the subvi. You can also use global variable. You can blah blah blah there are so many ways but the notifier is probably the best (though user events aren't bad either).
Here is some stuff on Notifiers:
http://digital.ni.com/public.nsf/allkb/B9398355D9550EAF862566F20009DE19
http://zone.ni.com/reference/en-XX/help/371361H-01/lvhowto/hndl_notifiers_loop/
Hope that helps.
03-24-2017 03:48 AM
I too think a notifier is the thing you want to go for. I used Occurrences in cases like these, mainly because i'm lazy and Occurences require less wiring 🙂 I recall having read that Occurrences can give you problems though.
Another thing that i want to comment on is the layout of your SubVI terminals. The convention is that Outputs should connect to the right side of the SubVI. In your first picture of Main.vi i got confused because of this and thought that there was no boolean value to collect.
Sq