LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to "access" a control in a SubVI from outside

Solved!
Go to solution

I have the attached SubVI as part of a camera control. It relays on the manufacturer's API.

 

I implemented a small change where by pressing a button a frame is saved as a jpeg file. I wired the button as a pin-out, and in the attached photo I am trying to hook it up to another button from outside. However, the outside button doesn't work.

 

Should I make the inner button a type def? Or maybe the outer one? I was thinking also to try with Global variable.

 

Personally, the type-defs, global vars and the references are a complete mess in my mind.


Thanks in advance for any help!

 

Outer button:

 

grumpy_numpy_0-1626239584826.png

 

0 Kudos
Message 1 of 7
(1,435 Views)

@grumpy_numpy wrote:

I have the attached SubVI as part of a camera control. It relays on the manufacturer's API.

 

I implemented a small change where by pressing a button a frame is saved as a jpeg file. I wired the button as a pin-out, and in the attached photo I am trying to hook it up to another button from outside. However, the outside button doesn't work.

 

Should I make the inner button a type def? Or maybe the outer one? I was thinking also to try with Global variable.

 

Personally, the type-defs, global vars and the references are a complete mess in my mind.


Thanks in advance for any help!

 

Outer button:

 

grumpy_numpy_0-1626239584826.png

 


I'm not really clear on what you want.  Do you want the "outside" button control the "inside" one?  Vice-versa?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 7
(1,377 Views)

Hey Bill,

 

Exactly! I am wandering how to make the outside button affect the inner button.

 

Apologize for the nube question... but that's what I am. 🙂

 

Thanks for the answer!

 

George

0 Kudos
Message 3 of 7
(1,372 Views)
Solution
Accepted by topic author grumpy_numpy

You can't directly make the outside button control the inside button other than the initial value as you have it wired now. You can pass a reference of the outside button to the subvi and use that. You could also use VI Server and get a reference to the inside button. Some other options would be to use, for example, a notifier. 

 

I would personally break up that subvi and move the loop into the outer program. Then you no longer have the problem (you can make multiple subvis in order to make the program look cleaner - it is a mess now).

0 Kudos
Message 4 of 7
(1,360 Views)

@grumpy_numpy wrote:

Hey Bill,

 

Exactly! I am wandering how to make the outside button affect the inner button.

 

Apologize for the nube question... but that's what I am. 🙂

 

Thanks for the answer!

 

George


It's okay that you're a noob.  Sometimes we have to ask questions to help you ask better ones.  🙂

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 5 of 7
(1,345 Views)

The way pins work here is that they supply the value *once*, when the VI is called. Your subVI will get called one time and won't return until it finishes. This is the core principle of dataflow. A given node (subVI, etc) runs if and only if all of its upstream inputs are configured. A wire doesn't connect buttons together, it connects values together.

 

You will need another VI, one which, when it runs, takes a picture and immediately returns. Then you'd want to use an Event structure to monitor the button, then call that VI when the button is clicked. The VI you made that you are inserting runs continually until explicitly told to stop, meaning the caller program won't be able to move on until the subVI itself has stopped.

 

Modify your subVI to take one picture when it's run, then call THAT VI instead of the one you attached.

 

(This has nothing to do with typedefs, global variables, or anything else you mentioned by the way- it's more of a program structure question).

 

Good luck!

0 Kudos
Message 6 of 7
(1,331 Views)

Million thanks John!

 

I used reference to my button from the main VI, and the refnum created by it in the SubVI. Now it works!

 

The only thing is that the latch option does not work, as it removes the Include Data Type option of the refnum. But I can live with this.

 

Thanks!

 

George

0 Kudos
Message 7 of 7
(1,301 Views)