LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I run two sub-VIs in parallel and have the faster VI continue to execute while the slower one completes?

I have two sub-VI's - one that makes a laser distance measuring device turn on and return a distance, and another that moves a platform upon which a target is mounted that the laser reflects against. The laser VI takes well under 5 seconds to complet. The platform-moving VI, on the other hand, requires about 30 second. I would like to be able to have the laser on AS the platform moves. Of course, I can accomplish this by running the VIs seperately. However, I would like to control them from a master VI. Currently, the laser turns on as the platform begins to move but then turns off, since the master VI waits on the platform-moving VI to
complete. Any help with this seemingly simple dilemma would be greatly appreciated.
0 Kudos
Message 1 of 3
(2,854 Views)
Simply make a master vi with two while loops, place fast subVI in a loop and slow vi in the other. Place a case inside each loop(subVIs in true case) and wire a boolean control to each case selector. Put another control to stop both while loops. Everytime you hit one of the buttons, one loop or another will be executed without waiting to the other.
Hope this helps
0 Kudos
Message 2 of 3
(2,854 Views)
In order to synchronize the two VI's I would recommend using a global variable. By creating a global boolean, you can make reference to it in both programs, and control when your "laser" subVI terminates.

Basically, have your "laser" subVI wait until the global boolean goes true to stop execution. Have the boolean initialized false, and then have your "platform" subVI write a true to the global boolean when it has finished running. This will keep you laser running until the platform has completed its move. Good luck!
0 Kudos
Message 3 of 3
(2,854 Views)