12-29-2014 08:11 AM
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
12-29-2014 08:29 AM
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.
12-29-2014 09:01 AM
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?
12-29-2014 09:54 AM
@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.
12-29-2014 12:55 PM - edited 12-29-2014 12:56 PM
@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:
Every time you call above code, output will be toggled.
-BTC
12-29-2014 02:07 PM
Thanks, but what is that green function with a right arrow and false connected to it?
12-29-2014 02:17 PM
12-29-2014 02:23 PM
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.
12-29-2014 02:36 PM - edited 12-29-2014 02:36 PM
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
12-29-2014 03:07 PM
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.