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 terminals in loops

I'm trying to create a subVI from a VI in which most of the controls and indicators (that will become the terminals of the subVI) reside in loops. I then connect the resulting subVI into a wrapper VI.

 

One boolean control within a while loop in the subVI is assigned to a terminal. If I connect a button in the wrapper VI to this terminal, the subVI doesn't seem to notice the input from the button at all. If I push the button on the subVI front panel, however, this works fine.

 

For indicators that reside in loops, the corresponding output terminals do not seem to reflect the subVI outputs either.

 

What am I doing wrong?

 

0 Kudos
Message 1 of 4
(2,627 Views)

Dataflow.  You need to take some tutorials as this is basic LabVIEW knowledge.

 

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

 

When a subVI starts, it is going to use whatever value is passed into its terminals at the time it started.  It isn't going to magically know that you pressed a button.  It won't know that until the subVI stops, and that part of the code runs again so that the new value of that button gets passed into the terminal of the subVI.

0 Kudos
Message 2 of 4
(2,608 Views)

@Barry_Wealand wrote:

What am I doing wrong? 


You don't understand dataflow yet. 😉

 

A subVI receives values on all inputs when called and returns values on all outputs after it completes. The callling VI cannot continue with anything depending on the subVI output and thus it will also not read the control you are changing until the next iteration. Once called, all operations are local to the subVI. You can do what you are trying to do by wiring control references into the suVI and read values via value propety nodes wired to the references, for example. There are many other ways, though. Some better than others.

 

It would probably help i you could describe what you are trying to achieve with all this. Most likley there are much better solutions. Why is there a loop in the subVI?

Can you attach a simplified version of your architecture (i.e. toplevel VI and subVI)?

0 Kudos
Message 3 of 4
(2,598 Views)

Thanks for the tips - I now have a better understanding of how LabView treats subVIs, and it makes good sense.

 

The core of the intended application is a state machine based on a message queue. The implementation uses several concurrent while loops. The deployed instances of this core functionality will differ mostly in the number of inputs and the processing thereof, so I had thought to turn the core into a subVI, and handle the different input sets with different wrappers using the same core. I obviously have some rethinking to do...

 

Thanks again!

 

0 Kudos
Message 4 of 4
(2,582 Views)