07-14-2021 12:13 AM
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:
Solved! Go to Solution.
07-14-2021 11:45 AM
@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:
I'm not really clear on what you want. Do you want the "outside" button control the "inside" one? Vice-versa?
07-14-2021 11:51 AM
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
07-14-2021 01:51 PM
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).
07-14-2021 02:56 PM
@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. 🙂
07-14-2021 06:37 PM
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!
07-15-2021 03:02 AM
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