LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parallel Sub VI Execution

Problem: I have two vi's. One sends a waveform out to my DAQ. The
other scans a serial port inside a loop while the waveform is being
outputed. Right now I manually start the loop vi, then start the
waveform vi, then I manually stop the loop vi after the waveform vi
has completed it's output. I'd like to make it so that I can initiate
and terminate both processes programatically. Somehow I need to find a
way for the called vi's to operate in parallel. Or is there a better
way to do this?
0 Kudos
Message 1 of 4
(3,063 Views)
Bill,

Parallel operation of subVIs is straightforward. Put each in a separate loop (you already have one loop for the serial port VI). Make sure each loop has a wait function and that the loops do not have any data dependency. In the main VI which calls both subVIs, use the event structure to respond to the start and stop commands from the user. If the independent loops need to exchange data, use queues or fuctional globals.

Also look into the state machine structure (a while loop containing a case statement). This is a powerful technique often used for situations like yours.

Lynn
0 Kudos
Message 2 of 4
(3,063 Views)
Hi,
You could try using a simple event (value change) for one of your tasks (serial port scan or waveform generation), triggering by a "value signaling property node", for example. This would be joining both VI's in one VI. Another solutions could be thru dynamic events, making sub-vi's, etc. But i think the first option is better and more quick. Hope this help,

JFT
0 Kudos
Message 3 of 4
(3,063 Views)
If you independently put each of these subVIs in a main vi then they will operate in parallel. You may use occurrences or notifiers from the loop vi to tell the waveform vi when to start and stop. As long as you don't wire these two vis together (creating a data dependency in the main vi) your program should operate as it does now. I have attached a vi library with a main vi and two subvis which show how you can use occurences. The second subvi also includes a notifier, which is more versatile since you can actually pass data.

I hope this is helpful.
0 Kudos
Message 4 of 4
(3,063 Views)