LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

program using two simultaneous VIs

Hello

 

What is the best way to have a program that uses two vi's at the same time?

 

My situation is that I need to create a program that uses two different monitors off of one computer.  So I'd like some plots displayed on one monitor and some controls on the other.... I'm trying to figure out the best approach for this... the monitors are different sizes and making a huge VI that just overlaps the two I don't think is going to work.  I'm picturing that I will have to have two vi's running at the same time and that one would pass data to the other.... so I have two questions?  Could someone tell me what th ebest approach for doing this is?  I'm use to programming all my VIs in state machines.... maybe I would need a consumer/producer architecture here with global variables to pass data?  (it's a simpled data aquistion and plotting program)

 

much thanks!

0 Kudos
Message 1 of 7
(2,853 Views)

Fibo,

 

Producer/Consumer would certainly work here but might be more than you need.

 

I would use queues or an Action Engine to pass data rather than global variables.  These are much less likely to produce race conditions.

 

Even simpler is to use wires.

 

Wires are always better than any of those methods.  If your state machine is producing the data you want plotted on the second monitor, just put the Plot VI in a Display state as a subVI.  Wire the data to Plot VI via a shift register.  Go to the Display state when new data is available for display, certainly no more often than 10-20 times per second because the users cannot perceive changes faster than that.   No globals.  No queues.  No Action Engines. No VIs running in parallel. Works fine.  I have done this for a slide show program I wrote several years ago.

 

Lynn

0 Kudos
Message 2 of 7
(2,848 Views)

Thanks for the resply.... sounds good, although the second VI will probably be doing more than jiust plotting... it'll have some numeric indicators and stuff like that... no controls though, would the wire method still work?  I'm not sure what you meant by puttin the sub VI in a Display state... is display state a setting on VIs?

 

much thanks!

0 Kudos
Message 3 of 7
(2,840 Views)

Fibo,

 

The Display state is a state in your state machine.  After you acquire and process the data, go to the Display state where the Plot VI is called with the new data wired to its inputs.  Then go to the Acquire state again to get more data, ....

 

You can display as much data as you want on the panel of the Plot VI.  If the number of indicators gets large you may want to create a cluster so that you can stay with a standard connector pane such as 4-2-2-4.

 

Lynn

0 Kudos
Message 4 of 7
(2,835 Views)

Thanks, this seems like a good solution, I'm doing it right now, and I had to remove the while loop out of my plot vi so that my main program wouldn't get stuck... this causes the front panel on the plot vi to run and stop running everytime it's called... is this fine?  I tried removing the run arrow (cause it keeps blinking) by viewing it as a top level application but then it got stuck... am I pretty much on the right track as far as following what you are suggesting? thanks.

0 Kudos
Message 5 of 7
(2,823 Views)

I added a chart and now it's blinking real bad I guess cause it keeps running/not running when it's called/not called.  I've attached both VIs I'm using to do this here, I'm running LV2009.  thanks.

Download All
0 Kudos
Message 6 of 7
(2,817 Views)

Rather than using the invoke node, try changing the VI properties: Window Appearance: Customize: Check Show Front Panel when called and Default behavior.  Uncheck the show Run arrow and Abort buttons.  Try various options.  This reduced the flickering considerably for me.  There is still something going on that I do not have time to track down.

 

Lynn

0 Kudos
Message 7 of 7
(2,807 Views)