07-31-2013 08:01 PM
As a newbie to LabView, I'm really confused as to how to trigger user events in SubVI's. For instance, the attached "Main Controller.vi" just translates a cryostat vertically, so I've attached "SubVI.vi" to indicate the kind of things I want to try and do with it:
(1) I feed values into "Absolute Position" and "Relative Position",
(2) Wait for the "Master Ready Indicator" to turn green, and then
(3) Hit the "Home to Bottom Limit Switch" button.
So my problem is two-fold: what's going wrong in "SubVI II.vi"? If I try to wire the output of "Master Ready Indicator" to a simple boolean indicator, why isn't it lighting up when the latter does? And then If simply wiring a boolean constant to the Home Button doesn't trigger the event, how can I make this happen? The VI's probably aren't going to run on your machine, but I'd imagine I'm missing something much simpler.
07-31-2013 08:03 PM - edited 07-31-2013 08:03 PM
You didn't attach a bunch of other files... namely R356 Home To Bottom Limit Switch" etc. Can't run the VIs. Zip the whole project and post that.
07-31-2013 08:05 PM - edited 07-31-2013 08:06 PM
Sorry about that! I've attched the zipped folder; both SubVI and SubVI II are in the main folder.
07-31-2013 08:10 PM - edited 07-31-2013 08:12 PM
OK, even without those VIs, There are some serious issues with your design. Assuming SubVI-2 (why is it called a subvi if it's the main VI?) You put an event struct in a subVI (the subvi here being Main Controller). If you run SubVI2, Main Controller is never going to return and the whole thing is just going to hang. That's because the event structure is waiting on events... but you haven't even opened up its front panel. So ... it will hang.
You shouldn't use event structures unless you're going to pop up a window and wait on user input. Never use them in subvi's which just need to perform a particular function then return.
07-31-2013 08:13 PM
I guess to summarize, think of subvi's like functions. They should perform a particular task, then exit and return their data. They should have nothing in them that requires keyboard/mouse input unless you're opening up a dialog window to acquire said input.
07-31-2013 08:14 PM
Yeah, someone pointed this out to me in an earlier thread. I'm essentially just trying to string together a bunch of VI's that other people have designed, so my question really boils down to this: can I mimic a user pressing a button on front panel?
07-31-2013 08:16 PM - edited 07-31-2013 08:17 PM
Yes. Create a property node of the control, then use Value (signaling). Wiring a value to it will trigger its corresponding event. BUT you should RARELY have to do this and it's a very bad habit to get into.
I think there is probably a better way. Can you explain what your intent is?
07-31-2013 08:28 PM
Sure. Main Controller (MC) is one of many VI's that I'm trying to put into a single framework. MC is a one-stop shop controller for the whole translator (hence the event streucture), and another VI - say BG - is the one I use to take measurements. This is what I want to do
(1) Exexcute the initial steps using MC that I described above,
(2) translate up using MC (absolute position),
(3) take measurement with BG,
(4) translate down using MC (relative position), and
(5) take second measurement with BG.
This simple procedure is very tedious since I have to do it multiple times, switching between VI's; I just want to tell LabView to click the existing front panels instead of me.
07-31-2013 10:16 PM
Also, do you mind describing how to use the property node function that you mentioned?