LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Running multiple VIs?

Hi all!

 

I am still quite new to LabVIEW and I want to achieve listed below.

 

I have 3 different VIs:

1) VI 1 and 2 need starts simultaneously

2) Both VI 2 and 2 each contains a while loop internally

3) VI 3 is required to start after a time delay after starting of VI 1 and 2

4) All 3 VIs are stop after VI 3 complete its execution

 

Is it correct if I just simply put VI and VI 2 on the main VI for them to start together?

What can I do for 3) and 4)?

 

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

3) How precise does the 1s timing have to be?

 

Assuming that timing can be a bit relaxed, here's one possibility, using Flat Sequence Structures and a Global Variable:

sequence.png

 

After the top-left frame completes, VI1, VI2 and the timer should start at almost the same time (this cannot be guaranteed, however). The timer then waits for 1.5s (a bit more than required, just in case), then VI3 starts running too. When VI 3 finishes, the global "Quit" variable will be set to TRUE. The loops inside VI 1 and VI 2 should monitor this "Quit" variable, and exit their loops accordingly. The "Quit" variable is initialized to FALSE in the beginning, to guarantee that it's not TRUE when VI 1 and VI 2 start.

 

Note: Be careful with global variables; don't rely on them too much (some people even argue that we should never use global variables at all)

Certified LabVIEW Developer
0 Kudos
Message 2 of 14
(3,449 Views)

I would consider starting all three subVIs at the same time with the modification to VI3 that it has the Wait internally.  If you bring the wait time out on the connector pane, you could easily change the wait time.

 

If you put Wait on Notification into each of the VIs then you could start all of them as nearly simultaneously as the system will allow by sending a "Start" notification.  You could use a notifier also to send the Stop command to all the VIs.  With the notifiers it does not matter so much when the VIs actually start provided they are all running before the Start notification is sent.

 

Lynn

0 Kudos
Message 3 of 14
(3,444 Views)

note:  please ignore my previous post, moderator notified...due to wrong execution of the VI. corrected VI as shown....

 

Since you are new to LV, this can be intimidating....namely using notifiers,parallel loops and dynamic events. pressing the start button starts vi1,vi2 and delay starts vi3 by 1sec through the notifier. all 3 loops will start accordingly, once vi3 delayed for 5sec, then it generates a dynamic event to the stop structure of the top user interface loop, which ends the main vi. hope you enjoyed the presentation....

 

Spoiler
mod.png
0 Kudos
Message 4 of 14
(3,394 Views)

@apok wrote:

 

Since you are new to LV, this can be intimidating....namely using notifiers,parallel loops and dynamic events.


Hi apok,

 

  1. Why did you use user events instead of native events?
  2. The OP has blocking subVIs that contain long-running loops; how does that intergrate with your architecture?

BTW, you can extend the Merge Errors VI to take 4 inputs (drag the bottom edge) -- no need to create an array first 🙂

Certified LabVIEW Developer
0 Kudos
Message 5 of 14
(3,384 Views)

@JKSH wrote:

@apok wrote:

 

Since you are new to LV, this can be intimidating....namely using notifiers,parallel loops and dynamic events.


Hi apok,

 

  1. Why did you use user events instead of native events?
  2. The OP has blocking subVIs that contain long-running loops; how does that intergrate with your architecture?

BTW, you can extend the Merge Errors VI to take 4 inputs (drag the bottom edge) -- no need to create an array first 🙂


answers:

  1. producer/consumer architecture is highly effective in running multiple parellel loops or sub vi's with communications in between.
  2. doesnt matter how long the sub.vi is running(that is still controlled by the producer loop), again producer/consumer architechture can communicate back whether with dynamic events(noticing that my example shows how vi3 can control the main vi by dynamic communication) or forth with data or UI control of the sub vi's by the producer loop through equeues or notifiers.

BTW, what you are probably seeing with merge error is an anomoly from translating between versions of LV, try it and see what i mean....believe me that i am not creating an array, its a bug. also, your use of flat sequences makes me question.... Smiley Indifferent

 

When Should I Use a Flat Sequence Structure?

Forcing execution with a flat sequence structure is useful for benchmarking code performance

0 Kudos
Message 6 of 14
(3,368 Views)

JKSH wrote:

 

  1. Why did you use user events instead of native events?

Events are great ways to get information back up to the main loop, especially when it is GUI driven.

 

 

Honestly though, I would use a different notifier for each loop.  This way you can send specific commands to specific functions.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 14
(3,313 Views)

Hi all!

 

Thanks for all the methods that you all have suggested!

I tried method suggested by JKSH and it work fine. Smiley Happy

 

 

 

 

0 Kudos
Message 8 of 14
(3,271 Views)

JKSH wrote:

 

  1. Why did you use user events instead of native events?


apok wrote:

 

  1. producer/consumer architecture is highly effective in running multiple parellel loops or sub vi's with communications in between.


crossrulz wrote:

 

Events are great ways to get information back up to the main loop, especially when it is GUI driven.


Understood. My original question was, is there a benefit of signalling using User Events in this case (which adds a lot of clutter to the code), as opposed to Native Events, e.g. by writing to the Value (Signalling) property node of a boolean control?

 

 


apok wrote:

 

2. doesnt matter how long the sub.vi is running(that is still controlled by the producer loop), again producer/consumer architechture can communicate back whether with dynamic events(noticing that my example shows how vi3 can control the main vi by dynamic communication) or forth with data or UI control of the sub vi's by the producer loop through equeues or notifiers.


Ok, I see now; your parallel while loops were meant to represent subVIs. I thought you intended to put the subVIs inside the parallel loops, which would've blocked them. Smiley Embarassed

Certified LabVIEW Developer
0 Kudos
Message 9 of 14
(3,252 Views)

apok wrote:


BTW, what you are probably seeing with merge error is an anomoly from translating between versions of LV, try it and see what i mean....believe me that i am not creating an array, its a bug. also, your use of
flat sequences makes me question.... Smiley Indifferent

 

When Should I Use a Flat Sequence Structure?

Forcing execution with a flat sequence structure is useful for benchmarking code performance


Huh, how odd. Is it because older versions didn't have multi-input Merge Error nodes? If not, this should be reported to NI.

 

LabVIEW is mainly dataflow, but sequence structures are still necessary for times when LabVIEW doesn't provide a way to draw wires between nodes, e.g.

FPGA_sequence.png

Certified LabVIEW Developer
0 Kudos
Message 10 of 14
(3,248 Views)