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: 

Can't get sub vi to process button pushed in main vi.

I'm trying to control whether or not data will be written to a spreadsheet through the use of buttons on my main panel. I have 5 sets of data and want to be able to tell the program when to save them by pressing a button. To do this, I created 5 sub vi's with the data as the inputs and a boolean control input representing the button. I then created a case structure inside a while loop, displaying nothing when the boolean is true (so the while loop just loops over and over again doing nothing when true) and saving it to a file when it is false, i.e. when button is released. for some reason, even though i wired the button to the appropriate terminal on the sub vi, when i release the button in the main vi, nothing
happens. the loop in the sub vi seems to always read the boolean as true, not comprehending my action in the main vi. However, if I release the button directly on the panel of the sub vi, it comprehends immediately and displays a dialog box for saving. any suggestions?

thanks a ton:)
yusif
0 Kudos
Message 1 of 5
(2,541 Views)
If you have statically linkded the subVIs to the main, then I think you're missing a basic concept of LabVIEW and dataflow programming. When your subVI is called, you pass it the current value of the Boolean on the front panel of the Main VI. While the subVI is executing, the status of the Boolean does not get communicated to the subVI because the execution of the main VI is essentially paused untill the subVI finishes. If you want to start subVIs and have the Main VI continue exection and be able to pass data to the subVI, you need to use the VI Server functions and start the subVIs that way. There's shipping examples of dynamically calling VIs and additional ones at the NI Developer Zone.
Message 2 of 5
(2,541 Views)
Eventhough your description is quite detailed, i think if you posted an example (in LV 6.0) i'm sure i'd be able to solve your problem directly.

But from what i've read it seems your subVI needs to read the boolean value constantly, and not just the value when the subVI first executes. To do this you could pass the boolean value to a global variable, and use this global in the subVI, or expand the subVI into the main diagram and use a local variable.

If this doesn't help, i look forward to seeing your example.

Kim
Message 3 of 5
(2,541 Views)
Hello Kim,

I'm attaching my main vi along with 2 of the sub vi's i want to use within it. As you can see in the main diagram, there are 5 while loops that I want to place in sub vi's, but can't because of the problem I described earlier. I tried the global variable approach with no luck, perhaps I'm not implementing it properly though.

i look forward to your response:)
thanks again...

-yusif
0 Kudos
Message 4 of 5
(2,541 Views)
There's no reason at all to have a while loop with a case statement inside of the subVI. Make the subVI just the For loop. On your main VI, leave the five separate while loops with the case statements and put the subVI inside the case statement. Better yet would a single while loop that monitors the state of all of the "Save" buttons. The diagram doesn't need any more complications like global variables.
0 Kudos
Message 5 of 5
(2,541 Views)