LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

What is the best way to run two process in one VI

Hi all...

I'm trying to run two process in the same VI at the same time, which do different operations.

One loop collect data from COM port, the other loop collect data from sound card. And two process should work independently.

So can I simply put two while loops in the VI?

The attachments are my VIs. 

Thank you!!

Download All
0 Kudos
Message 1 of 5
(3,185 Views)

@yatang wrote:

So can I simply put two while loops in the VI?


Yes (although I haven't looked specifically at your VIs). Did you try it?

Normally you'll want to use a queue, notifier, or other synchronization method to communicate between the two loops, or at least to make sure that they both stop together when you stop the code,

0 Kudos
Message 2 of 5
(3,172 Views)

Hi nathand, I will try it later.  So I should use something like queue or notifier to make them start and stop together?

 

Actually I don't care about if two loops start or stop at the same time, I will use "Get Data/Time in Second" function to set a time trigger for data saving. So I just want to guarantee two loops work independently, which means one loop will not be stopped while the other one is operating.Smiley Very Happy

 

 

0 Kudos
Message 3 of 5
(3,164 Views)

As long as neither loop depends on the other (that is, you don't have any wires that carry data from one loop to the other), then yes, two separate loops will run independently.

 

You probably still want some way to stop both loops from clicking a single button. For two loops on the same block diagram, you could use a simple local variable. For any more complicated data exchange, or if the loops are running in subVIs, you'll want a more sophisticated approach to stopping all of them.

0 Kudos
Message 4 of 5
(3,150 Views)

You haven't said what your long term goal is, but putting two loops in the same VI that are doing different things is a poor design choice. The problem is that it limits your options for reusing or expanding your code. Queues, events and notifiers all work equally well whether the processes are in a single VI or spread across a dozen VIs.

 

Mike.. 


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 5 of 5
(3,126 Views)