Showing results for 
Search instead for 
Did you mean: 

Running two programs simultaneously

I’m trying to run two programs simultaneously in the same Labview window. One of the program is measuring the airflow through a USB device connected to the computer. The other program is acquiring sound through audio jack. I have inserted the sound acquisition program into the original or main program which measures the airflow. After insertion, only the sound acquisition program runs and displays sound signals. But the airflow program is not working and even not displaying in the graph. Here also I have attached the screen shot of the front panel and block diagram. 


Could anyone help me to fix this problem?





0 Kudos
Message 1 of 6

You've put one loop that runs forever in another loop. The outer loop won't loop, it will execute one iteration (i=0) and then wait for the inner loop to finish. That won't happen until you press stop.


Use execution highlighting to see this happening...


You need two parallel loop, not two nested loops.


Then you need some data communication mechanism. Queues, or the like.


You might invest in doing some courses first.

Message 2 of 6

Why did you send a Microsoft Word Document to a LabVIEW Forum?  Why didn't you attach the LabVIEW VIs that are giving you trouble, so we could (a) see them clearly, (b) edit them, (c) try to execute them, and (d) be able to better help you?  We all have LabVIEW -- not all of us have Word (and we couldn't execute your code from Word even if we did have Word ...).


Bob Schor

Message 3 of 6

LabVIEW code in a Word document. That is a new one. LOL

Certified LabVIEW Developer (CLD)
There are two ways to tell somebody thanks: Kudos and Marked Solutions
0 Kudos
Message 4 of 6

Thank you for your suggestions and willingness to assist me. I really appreciate it.


Here I have attached the LabVIEW VI's of the two programs. The flow_VI is for airflow measurement through a USB device connected to the computer. The sound_VI is for the sound acquisition through audio jack. So I have to combine these two programs under one VI's for it to work simultaneously at the same time. 


Hope you could help me on this issue. 


Thank you very much.

Download All
0 Kudos
Message 5 of 6

You have two VIs, each of which has a Front Panel with elements you want to use.  What you really want is One VI to Rule Them Both, One VI to Find Them, One VI to Show Them All, and with LabVIEW Bind Them.  From Austin, where NI Dwells.


This can be done (believe it or not!).  Here's the Idea:

  • Configure Flow and Sound so they both run pretty well by themselves.
  • What you are going to do is to run both of them from a Third VI (which I will call "Sauron") that will both Start and Stop them.  Here's the idea of Sauron:
    • Sauron consists of a single Control, called "Stop", and two sub-Panels (called "Flow" and "Sound") designed to show you the Front Panel of Flow and Sound and letting you interact with them.
    • Find Sub-Panels on the Front Panel Palette under Containers.  Put Two of them, side-by-side, on Sauron's Front Panel.  They need to be large enough to hold both Flow and Sound's Front Panels (minus the Error Lines and any other Controls or Indicators you don't need to see).  Sauron will "call on" Flow and Sound to run in such a way that their Front Panels appear in Sauron's two sub-Panels, letting you interact with them independently.  We'll come back to Sauron in a minute.
  • Modify the Front Panel of Flow and Sound to be as small as practical and still fit all the Controls and Indicators you need to see and use.  Note this does not usually include Error In or Error Out.  Drag them "on top of" Sauron's Front Panel and make sure the sub-Panels are large enough to hold the (now smaller) Front Panels.
  • When you dropped down the two sub-Panels in Sauron, you got two Invoke Nodes labeled Flow and Sound, asking you to enter a VI Ref (for Flow and Sound, respectively).  Here's the Easy Way to do this:
    • Be sure Flow and Sound have been saved.
    • On the Applications Palette, drop a Static VI Reference.  Right-click it, choose "Browse for Path" and (for Sound) find  Note if you had made an Icon for Sound, its Icon would appear here.  Wire this to the VI Ref for the Sound sub-Palette.
    • Do the same for Flow.
    • To start both of these running at the same time, branch the Error Wire and put Flow on one branch, Sound on the other.
    • This starts Flow and Sound.
  • Now we have an interesting problem -- Sauron is "controlling" Flow and Sound, so it has to be running in order to interact with Flow and Sound's Front Panel (including their Stop buttons).  One way to do this is to wire the Error Out from Flow and Sound into a While Loop in Sauron, and let Sauron's Stop Button stop the Loop.  That works, but you don't want a loop running full speed checking the Stop button.  [Do you know two ways to "not waste all the CPU time check for Sauron's Stop Button to be pressed?]
  • If you stop both Flow and Sound first, you can then stop Sauron.
  • Ah!  There's a catch.  If you are still with me (and doing this Experiment), you'll find some interesting things possibly happening when you start Sauron.  Flow and/or Stop will probably show Error 1144.  Do you know how to look up Error Messages?  Go to Help, choose Explain Error, and put in 1144.  Read and understand (and fix) the Error.
  • So now you have three Stop Buttons to push (what a pain!).  How do you push them in the correct order?  What is the correct order?
  • This is turning out to be an "Advanced lesson".  The answer is -- you get rid of the Stop Buttons on Flow and Sound, and let Sauron be the Boss, "notifying" Flow and Sound (using something called, appropriately, a Notifier) to tell them to stop.  Or you can safely use a Global Variable called Stop that Sauron sets and Flow and Sound Read.  [That's definitely simpler, and may be better ...].

And I'm going to stop here.  If you've been following this so far, you are in a position to create a Sauron for yourself, get Flow and Sound running "within" it, and leaving (for now) the three Stop buttons.  [Suggestion -- make "Dummy Flow" and "Dummy Sound" that do some very simple things, like counting once/second for one, twice/second for the other, and try this out.  LabVIEW is great for creating simple Test routines to test out complex code -- once you get the idea, you can substitute your real Flow and Sound].  Once you have the Demo working, you can substitute your real Flow and Sound and be off and running ...


Bob Schor

Message 6 of 6