LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SubVI works individually but not when call from main VI

Solved!
Go to solution

Hi guys,

 

I have a problem with my subVIs, in the "% calculator", while the subVIs work individually, the "% calculator" VI doesn't seem to be able to call in the value and calculations requested, giving "0" to whatever value is inputted even when there should be an error.

 

I have looked around the forum to look for similar problems but doesn't seem to be able to find a solution, hope someone can take a look and let me know what's wrong.

 

best

0 Kudos
Message 1 of 4
(3,078 Views)

Your subvi includes an event structure, which only fires off events (activity), and in your case you're asking for events such as Stop button value change and Current Value value change. When executed on it's own, you have the front panel open and you can change the Current Value value, which fires the event structure, and you can press the Stop button, which also fires your event structure. But when called as a subVI, the front panel is not shown, and therefore you cannot press any buttons or change any values. Therefore the subVI is running and waiting, waiting forever for some event to fire, but none ever will as the front panel is not visible and you cannot interact with it. The fact that you set the value for Stop and Current Value as inputs is irrelevant, these do not fire "value change" events in the event structure.

You need to modify your subVI to not use event structures here, it's totally unnecessary. Just call the core content of the subVI (the bit inside the while loop), such that it executes and exits immediately, returning your calculated result in the output terminals.

Message 2 of 4
(3,065 Views)

Thanks for the quick response RTD!

 

I'm assuming what you meat is the "% distributor" SubVI, and I've gone ahead and done that, but I can't figure out a way to make "val change detect" work without the event structure as it requires data recall and from my knowledge that's the only way this would work? Or is there another option to do the same function as the "val change detect" subVI?

0 Kudos
Message 3 of 4
(3,003 Views)
Solution
Accepted by topic author Caleb963

You seem to be confused about what an event structure is and what a value changed event is.  Please read the help files on them.

 

An event structure is used to react to events, mainly things like user interaction with a front panel.  (There are other things like user events and some other events you can register for, but we won't go into that here.)

 

A value change event occurs whenever the user changes the value in a control, even if technically they just reentered the same value.  You can programmatically fire a value change event if you use the Value(signalling) property node.  But that event will be triggered whenever that node is executed, whether or not the value has changed.

 

If you want to detect whether a value has changed on a wire from the last time a subVI was called, then you need a shift register or feedback node to store the old value, and do a comparison with the new value.

 

I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours

Message 4 of 4
(2,978 Views)