From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SubVI Issues

Solved!
Go to solution

I'm extremely new to LabView, and I'm trying to string together several VI's that better programmers than me have written. I'm having trouble however getting some of them to work as SubVI's in my program, so I feel like I'm missing something. 

 

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.

 

Obvioulsy, I need to translate the cryostat several times later in my program, but even this initial translation isn't working. Where am I going wrong?

Download All
0 Kudos
Message 1 of 10
(3,140 Views)

I would recommend making the code in each of the event cases a subVI.  You can then directly call those VIs and sequence however you need.

 

It is generally not a good idea to have event structures in subVIs unless you are showing the front panel.  Otherwise you have no control and the VI will just freeze waiting for an event that will never happen.

 

Also, do not put outputs on the left side of the connector pane.  Inputs should be on the left, outputs on the right.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 10
(3,117 Views)

Thanks for the quick reply crossrulz. I understand what you're recommending I do, but I'm curious as to why the VI freezes if it has event structures? If I'm wiring a boolean constant to a button, is it not the same as if the front panel pops up and I hit the button? Concretely, what is going wrong in the VI that I uploaded? I ask because most of the VI's I'm attempting to make use of as SubVI's are built similarly. Thanks!

0 Kudos
Message 3 of 10
(3,113 Views)
Solution
Accepted by topic author vivianbritto

@vivianbritto wrote:

Thanks for the quick reply crossrulz. I understand what you're recommending I do, but I'm curious as to why the VI freezes if it has event structures? If I'm wiring a boolean constant to a button, is it not the same as if the front panel pops up and I hit the button? Concretely, what is going wrong in the VI that I uploaded? I ask because most of the VI's I'm attempting to make use of as SubVI's are built similarly. Thanks!


Writing to a control will NOT cause an event.  Writing to a local variable will NOT cause an event.  Writing to a property node value will NOT cause an event.  Writing to a property node Value(signaling) will cause an event.  But I seriously doubt you want to do that here.

 

As I said, your VI starts and sits there waiting for an event.  But since the front panel is not being opened, an event will never be fired.  Result is a VI frozen.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 10
(3,110 Views)

I see! This makes a ton of sense now.

0 Kudos
Message 5 of 10
(3,106 Views)

So I've been reading about the value (signalling) property node for the last little bit, but I can't seem to figure out exactly what it does. You said that I could use it to trigger an event: how exactly? And why would I not want to do that? Thanks.

0 Kudos
Message 6 of 10
(3,082 Views)

It triggers the Value Change event:

Example_VI.png

0 Kudos
Message 7 of 10
(3,069 Views)

Sorry Todd, could you please explain in a little more detail? Given a user control in a SubVI, how can I use the value (signalling) property node to make it as though the user flipped the switch in the front panel?

0 Kudos
Message 8 of 10
(3,066 Views)

Decouple the property node and pass the control's reference to the sub VI. Here is a VI snippet in LV2012:

Example_VI.png

0 Kudos
Message 9 of 10
(3,061 Views)

@vivianbritto wrote:

Given a user control in a SubVI, how can I use the value (signalling) property node to make it as though the user flipped the switch in the front panel?


You don't want to.  That is just a bad architecture.  Separate the code in your Main VI into new VIs and call those.  Working around the event structure is just going to make things way too complicated.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 10 of 10
(3,046 Views)