LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I get a subvi to run continuously when it is called by the main program?

I know that you can set up the subvi to run when called, but I want it to keep running until the main program tells it to stop? I have tried to do this indirectly with a while loop, but I can't get that to work either. I want either the loop or the subvi to execute for a prespecified time interval. Any help would be greatly appreciated!
0 Kudos
Message 1 of 4
(3,984 Views)
Look at the Plug In Example. It shows you how to launch a vi remotely.
0 Kudos
Message 2 of 4
(3,984 Views)
One way to accomplish this is to code your main routine with two, parallel loop structures. Your routine that is to run continuously would be enclosed inside of one loop (a while loop). The remainder of your code would be enclosed in a second loop. With this architecture, you can set timing, duration, and halt criteria independant of the other loop. You can assign the subVI to operate on a different thread than the main routine. You can also synchronize the multiple loops with the advanced synchronization functions found in the tools palette. You will want to consider using loop timing (wait functions) if you want to force (control) CPU access. Assignment of different threads will improve CPU sharing; however, you may want better control of sequencing.

I adm
it that this response may refer to many capabilities that you have not used before; however, parallel looping structures (combined with multiple thread access) is one of the few ways to perform simultaneous (or very close) operations in LabVIEW.

PS ... When you use parallel loops, you can not have ANY wires between the two structures as those wire "attachments" would force the traditional "dataflow" characteristic on your VI by forcing one loop input to wait on the output from the other loop. Using local variables (WITH CAUTION) is a non-synchronized method to pass data between the loops. You just need to be sure that you coordinate the read and write sequencing - be sure that you write to the local variable before you read from them.
Message 3 of 4
(3,984 Views)
Hi,
I am attaching 3 vi where Main vi calls the sub vi when Start Sub vi button is pressed. You can also stop your sub vi by pressing Stop Sub Vi button.

I hope this helps. Incase of any problem, pl. get back.

Best Regards,
Nirmal Sharma
India
Download All
0 Kudos
Message 4 of 4
(3,984 Views)