LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Update Indicator from SubVi in Main Vi

Hi, I am new to labview and have recently undertood the concept of Control Refnum. Because all the examples online are related to passing controls to the subvi and triggerign an event there, I am able to do it and it works. I am here because I could not find any example where indicator values are passed back to the Main Vi. I have attached my two Vis and will appreciate if someone could help me understand and apply this concept.

 

I am just pressing a button in Main Vi and want the LED and number indicator in my main vi to update from the sub Vi. Currently it only updates in Sub Vi.

Thanks

Download All
0 Kudos
Message 1 of 24
(6,498 Views)

Why isn't your event structure in your top level VI?  That is where GUI events should be.

 

Your indicator on the main VI isn't updating because your subVI is still running.  The values in the indicators are not passed out until the subVI is done running.  Dataflow 101.


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 24
(6,487 Views)

Thanks. This is because my main vi will become very cluttered if I do everything there. I will have nearly 8-10 events in my final program and I find it easier to shift them to sub vi. I can see what you mean now, as my number gets updated if I remove the while loop. But I am left with one problem, how do I toggle the led without a while loop and shift registeres? 

0 Kudos
Message 3 of 24
(6,475 Views)

@lsbu wrote:

I will have nearly 8-10 events in my final program and I find it easier to shift them to sub vi.


That's very few events.  Did you not know the event structure can handle many events?  At that point, it is as hard to manage as a single case structure (which is dirt easy).  Trust me.  It will be a lot easier to manage a single event structure than trying to follow your references everywhere just to try to figure out who is handling what event.


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 24
(6,460 Views)

@lsbu wrote:

Thanks. This is because my main vi will become very cluttered if I do everything there. I will have nearly 8-10 events in my final program and I find it easier to shift them to sub vi. I can see what you mean now, as my number gets updated if I remove the while loop. But I am left with one problem, how do I toggle the led without a while loop and shift registeres? 


 

How to toggle the LED without a while loop/shift registers:

 

 

toggle.png

 

Every time you call above code, output will be toggled.

 

-BTC

--------------------------------------------------------

New Controls & Indicators made using vector graphics & animations? Click below for Pebbles UI


0 Kudos
Message 5 of 24
(6,439 Views)

Thanks, but what is that green function with a right arrow and false connected to it?

0 Kudos
Message 6 of 24
(6,425 Views)

It's a Feedback Node, you can find it under block-diagram functions palette->structures.

 

-BTC

 

--------------------------------------------------------

New Controls & Indicators made using vector graphics & animations? Click below for Pebbles UI


0 Kudos
Message 7 of 24
(6,417 Views)

I tried the above code and placed it in my SUB Vi (It is without the while loop now). The state remains the same i.e. led doesn't not toggle. 

0 Kudos
Message 8 of 24
(6,415 Views)

Calling that code just once won't get you toggling output, you have to call it again each time you want the output toggled. Please refer to help pages on how to use these basic functions.

 

-BTC

--------------------------------------------------------

New Controls & Indicators made using vector graphics & animations? Click below for Pebbles UI


0 Kudos
Message 9 of 24
(6,410 Views)

As it's shown above, the feedback node gets reinitialized every time you click the white run arrow. Try deleting the constant false and it should change to be globally initialized.

0 Kudos
Message 10 of 24
(6,396 Views)