LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I change values in a running loop from a calling vi

Hi, I have a LabVIEW problem that I have been stuck on for a long time now. I have a large LabVIEW program that conducts automated scan routines, to do this, a sub VI is called from the main vi and a loop is entered in the sub vi in order to conduct the scan routine. I need to be able to pause or abort the scan routine (pause/exit the loop) while it is running. My difficulty comes in changing the value of the boolean switch within the loop which is used to stop or pause the sub vi. Stopping or pausing the loop from the sub vi is not a problem as the stop/pause button can be put inside the loop. I have tried using local and global variables, reading from the button on the main vi and writing to the button in the loop of the sub vi but this doesn't work. Is there anything else I can try? I'm sure there must be an easy way to do this but I'm stuck for ideas and my knowledge of  LabVIEW is quite limited. If anyone could help I would be very grateful. Thanks
0 Kudos
Message 1 of 3
(2,453 Views)
you may try these:
 
1. Add one more logic (define as boolean variable), then OR this variable with the original Boolean switch you used in subvi, then main vi can change the new added variable which is defined as local or global variable.
 
2. Change the subvi while loop as state machine, or use other Synchronization techniques like notifier
 
 
0 Kudos
Message 2 of 3
(2,448 Views)
I think you want to run your loop as a parallel, independent loop rather than as a subVI. Then both the scan loop and the main loop can execute simultaneously. Look at the Producer/Consumer design pattern examples. Each loop must have a wait function to allow effective processor sharing. Queues or notifiers are the usual ways of exchanging commands and data between the loops.

Lynn
0 Kudos
Message 3 of 3
(2,443 Views)