LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating 2 separate Main programs, passing values

Hello,

 

I am in the process of a creating two sepearte main VI programs. Program (1) will be the program the user interfaces with and updates dynamically (using the front panel to change values, addresses, and states of power supplies, DMM channels, analog I/O, digital I/O, etc). Program(2) will be a separate program running through automated tests (current/voltage sweeps, data acquisition, etc). Normally I would like to incorporate both programs into a single VI, but the shear number of front panel controls and indicators makes it more practical to run separate programs on separate monitors (dual-screen setup). My question is, how do I go about passing the dynamic updates of program (1) into program (2)? For example, if I use event structures for both programs, and change the power supply voltage in program (1), how do I go about updating program (2) with this new value? From what I remember it isn't possible to have a program running and being used as a subVI as well. Any thoughts or recommendations? It would help tremendously to get this type of setup working.

0 Kudos
Message 1 of 14
(3,396 Views)

If I understand correctly...

You can run one exe, one application, with two vis with their front panel open simultaneously.

You can pass the data through them with, functional globals.

 

Is this what you need ?

Message 2 of 14
(3,392 Views)
I suppose functionnal variables, global variables or shared variables should do the trick. A search on the forums will return hundreds of references on the subject !
Chilly Charly    (aka CC)
Message 3 of 14
(3,390 Views)

from what I understand, take a look at shared variables,  and on the main vi 1  put a while loop aside from the event structure with the update of 

your indicators from the shared variables 

0 Kudos
Message 4 of 14
(3,389 Views)
Thanks guys! I will go with the shared variable approach. Everything seems to be working right so far... Now, is there a way to lock the front panel of program (1) while program (2) is executing its specified event? Usually with event structures, there is a check box to "lock front panel VI until event case finishes". Is there a way to do this between different programs?
0 Kudos
Message 5 of 14
(3,360 Views)

You can use a simple boolean variable.

When it is set to true you will ignore every front panel activity

Message 6 of 14
(3,337 Views)

I would strongly recommend you avoid shared variables and globals for this sort of application.  Neither are thread-safe and both will cause many problems due to race conditions.  You can avoid such problems by using a thread-safe storage mechanism.  The most commonly used is the functional global (aka LabVIEW 2 global, shift register global, or action engine).  I prefer to use single-element queues, since they are more scalable and work better with object-oriented design techniques.  You can find examples and information about both of these techniques on this forum, and both work well.

 

Let us know if you need more information.

Message 7 of 14
(3,313 Views)
I appreciate the heads up. I'm not exactly sure how to code the functional global as I have never used it before. To better clairfy the type of program I am trying to run, included are the (2) Main VI's I am trying to setup. The files were written with LabVIEW 8.5 and are currently setup using shared variables. How difficult would it be to switch over to functional globals from the code I already have written? Thanks.
0 Kudos
Message 8 of 14
(3,288 Views)
Here are the project and shared variable library as well.
Download All
0 Kudos
Message 9 of 14
(3,287 Views)

Several things you can do to improve:

  1. You are currently using a simple event structure for program execution flow.  You would probably be better off with an event driven, queue based task handler.  You can find a paper and example code here.  This code also gives an old example of using semaphore locked functional globals.  While useful, the semaphores slow them down quite a bit.
  2. Use VI Server to launch one of your main VIs from the other.  This should take place in your initialization code.  When you launch the second VI, you can pass it references ( e.g. a queue reference to a single-element queue "global" ).  This also ensures that your hardware is fully ready by the time the GUI which uses it is launched.
  3. You can find examples of several types of reference objects here.  The attached paper will also explain why you want to use single-element queues or action engines instead of globals or shared variables.  Use either the single-element queue or action engine approach to store your "global" data.
If you need more information, let us know.
Message Edited by DFGray on 09-03-2008 08:05 AM
Message 10 of 14
(3,271 Views)