03-28-2013 06:18 PM
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.
03-29-2013
06:44 PM
- last edited on
08-15-2024
03:04 PM
by
Content Cleaner
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.
03-30-2013 07:52 PM
04-01-2013 12:12 PM
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.
04-01-2013
03:34 PM
- last edited on
08-15-2024
03:04 PM
by
Content Cleaner
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.
04-01-2013 03:53 PM
I have Labview 2010. Can you please post a version of the vi that is compatible with 2010 or earlier.
Thanks.