LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Access while loop in subvi pls help

Solved!
Go to solution

[Beginner] In my calling vi there is a sub vi which is basically a while loop with many loops and structures inside it.

 

I want to start and stop the sub vi from the calling VI only. But the while loop in the sub vi only takes the first value from the control on main vi.

 

essentially the first pic is a dummy of the sub vi ( with all the structures inside it removed) and of the calling vi.

 

the sub vi should only start if the initial value of boolean is true.

 

please help

 

Download All
0 Kudos
Message 1 of 21
(3,816 Views)

You can control subVI by passing reference.Refer to this document.
Also find the attached VI

Aarthi
Download All
Message 2 of 21
(3,807 Views)
Solution
Accepted by topic author su_a

Either pass the reference as mentioned, or transfer data through Events (in which case you pass the event register thread instead) or my favorite, an Action Engine (AE). In the last case your main vi writes data to an AE and the sub-vi reads from it.

 

I think Ben has an excellent nugget on AEs.

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 3 of 21
(3,788 Views)

Ben's nugget:

 

http://forums.ni.com/t5/LabVIEW/Community-Nugget-4-08-2007-Action-Engines/td-p/503801

>

"There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal
Message 4 of 21
(3,772 Views)

Aarthi : yes it works.. thank you...

 

Yamada : I am not sure how to implement it through a thread but I'll surely explore...

 

Vt92 : thank you for the link..

 

Can you please tell which is the best way>> ? My main VI is to be the central control for all sub vi s i.e all sub vi s will start and stop accoding to the

 

control from main vi. Also some of the vi maybe in loops so that it continuously checks for value from main vi and can be started or stooped more than

 

 once while the execution of the main vi..

0 Kudos
Message 5 of 21
(3,751 Views)

The best thing would be to use the LV2G (Functional global).You can follow the link given by vt92. Action engine is the advanced version of LV2G and Ben has given an Awesome explanation on both. So better follow that and use LV2G.

-----

The best solution is the one you find it by yourself
Message 6 of 21
(3,747 Views)

does using a functional global use a lot of cpu usage? because it is making my computer really slow, and values from one control is not being written into the functional global, do i hvae to put that control in a loop ? or should it update automatically despite where it lies??

0 Kudos
Message 7 of 21
(3,732 Views)

Hi

 

Could you show your functional global and the control which is not being read? 

Regards
Freelance_LV
TestAutomation Consultant
0 Kudos
Message 8 of 21
(3,726 Views)

I guess You have done one mistake. You have not given the stop condition true that will only cause two things.

 

Full CPU usage (Since no time delay)

 

Since stop condition is false it will not come out of it.

 

try this

 

LV2G1.png

 

LV2G2.png

-----

The best solution is the one you find it by yourself
0 Kudos
Message 9 of 21
(3,716 Views)

here are the images. I can attach the VI as well. The main vi has the boolean control start. However this value is not read the second time I change the control. Please tell what am I doing wrong?

Download All
0 Kudos
Message 10 of 21
(3,687 Views)