LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

run two VI-s simultaneously

Hi,

I want to run two VI-s simultaneously. I have a VI (Lets say VI-1) that has 4 different parts (look at the image.). What I want is the following:

 

1. Run VI-1 (Has parts :A1,A2,B1,B2 and all parts will be active.)

2. While VI-1 is running, Run a different VI (VI-2) that needs to access the DAQ card and stage controls.

3. While VI-2 is running, VI-1 also keep on running but the DAQ and Stage parts are deactivated (Part A1 and A2 stays active but B1 and B2 deactivated).

4. VI-2 stops after it finishes its job (in ~1 min).

5. VI-1 keep on running and now as VI-2 stops, the DAQ and Stage parts are active again ( All A1,A2,B1,B2 active).

I was using a global variable to set the DAQ and stage part unavailable while the other program is running and then set the DAQ available again.

But that does not seem to be a good idea. It crashes frequently. Can anyone suggest a nice way to do this?
I did not attach my actual VI-s because it is big and it will require lot of other drivers.

Download All
0 Kudos
Message 1 of 6
(3,082 Views)

Hi babu726

 

Why does it have to run in two different VIs?

 

I think that you could use a state machine for the main VI or application that could run as the control for all the parts and if you need to control and synchronize with some other VIs I could recommend you to use notifiers instead of global variables.

 

Regards

Esteban R.

0 Kudos
Message 2 of 6
(3,008 Views)

Hi Esteban,

 

 Thanks for your reply. Following your suggestion, I was trying to make a state machine with 2 DAQ assistants. It does not seem to work. The state machine works fine but the second DAQ assistant does not. I am a little lost. Can you have a look at it.

 

Thanks.

0 Kudos
Message 3 of 6
(2,978 Views)

In general, you shouldn't have two seperate VIs try and use the same hardware.  There arrises alot of issues with determining whether or not the other VI is active, assigning priority, and ORDERING the lower VI to cease communication for a time.

 

I'd use a single VI and use a case structure to determine whether to run the VI-1 Daq/STAGE controls or the VI-2 Daq/Stage controls.  Essentially, when the user presses a button, it sets a boolean control to "TRUE".  Then the true case contains the VI-2 code.  

 

The VI-1 code can be made to keep track of it's own values so that once the VI-2 code is finished, set the boolean control to false and let the VI-1 code resume where it left off.

 

 

0 Kudos
Message 4 of 6
(2,944 Views)

Hi Babu726

 

I modify your example, but keep in mind that it might behave like some sort of state machine but that is not the best way in which you can program a state machine on LabVIEW have a look to this link here they explain how to implement a state machine.

 

In this example I have modify the code in order to help you with the notifyiers and show you how could you do run to different application and communicate two while loop. Also I have implemented a way to stop both while loops when you press the stop button or there is any error on any of the while loop.

 

Is not the best or efficient way or program but it might help to get on track.

 

Regards

Esteban R.

Download All
0 Kudos
Message 5 of 6
(2,920 Views)

I have Labview 2010. Can you please post a version of the vi that is compatible with 2010 or earlier.

Thanks.

0 Kudos
Message 6 of 6
(2,918 Views)