04-06-2013 02:35 AM - edited 04-06-2013 02:45 AM
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)?
04-06-2013 10:24 AM
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:
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)
04-06-2013 10:33 AM
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
04-07-2013 08:29 AM - edited 04-07-2013 08:41 AM
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....
04-07-2013 10:05 AM
@apok wrote:
Since you are new to LV, this can be intimidating....namely using notifiers,parallel loops and dynamic events.
Hi apok,
BTW, you can extend the Merge Errors VI to take 4 inputs (drag the bottom edge) -- no need to create an array first 🙂
04-07-2013 03:32 PM - edited 04-07-2013 04:01 PM
@JKSH wrote:
@apok wrote:
Since you are new to LV, this can be intimidating....namely using notifiers,parallel loops and dynamic events.
Hi apok,
- Why did you use user events instead of native events?
- 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:
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....
When Should I Use a Flat Sequence Structure?
Forcing execution with a flat sequence structure is useful for benchmarking code performance
04-08-2013 08:12 AM
JKSH wrote:
- 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.
04-09-2013 08:08 AM
Hi all!
Thanks for all the methods that you all have suggested!
I tried method suggested by JKSH and it work fine.
04-10-2013 01:20 AM
JKSH wrote:
- Why did you use user events instead of native events?
apok wrote:
- 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.
04-10-2013 01:27 AM
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....
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.