LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling a SubVI with while loop from another VI

Dear All,

this might be an easy Question but i couldn't catch an answer for it.

first of all i have a VI which i will use as a subVI , this VI  is simply as shown in the "test_out of scope.vi" attached file

 

now i will use it inside another VI called "Main VI" as shown in the file "Main_VI.vi"

i'm just wondering , why couldn't i control the "Frequency" and "Stop" as i can do so while running the SubVI only without accessing it from another VI ?

isn't it possible to access objects inside a while loop from another VI if i just connected them in the connection Pane terminals ??

 

Thanks in advance to everybody

Message Edited by Mohammed.Ashraf on 06-09-2009 10:27 AM
Eng. Mohammed Ashraf
Certified LabVIEW Associated Developer
InnoVision Systems Founder, RF Test Development Engineer
www.ivsystems-eg.com
Download All
0 Kudos
Message 1 of 18
(3,937 Views)

Being a CLAD, you should realize why that cannot be.

 

If you are using a While Loop and within the While Loop you call a VI, then the VI has to complete execution and exit befor the While Loop completes it's iteration.

 

What you want to do is call the sub-vi externally to that loop.  You may use a variety of approaches to changes values within the sub-vi, such as using references or queues.  

 

R

0 Kudos
Message 2 of 18
(3,929 Views)

i totally understand this

the point is that i was preventing using Global variables , maybe a more efficient way or something

also i thought of using a Control reference to modify the controls instances inside the While loop

 

posting here really teaches me alot , even if i was knowing an answer , i may expect a better one

there are 2 kinds who never learn , the ignorant and the shy

 

Regards...

 

 

Eng. Mohammed Ashraf
Certified LabVIEW Associated Developer
InnoVision Systems Founder, RF Test Development Engineer
www.ivsystems-eg.com
0 Kudos
Message 3 of 18
(3,923 Views)
You can just get rid of the loop in the subVI. That is the cleanest thing to do. The loop is senseless.
Message 4 of 18
(3,917 Views)

yeah , but i just posted an example illustrating the problem , in this case no need for the while loop but in other cases it is the main part of the code 

Eng. Mohammed Ashraf
Certified LabVIEW Associated Developer
InnoVision Systems Founder, RF Test Development Engineer
www.ivsystems-eg.com
0 Kudos
Message 5 of 18
(3,913 Views)

Why would it be the main part of the code? The top level has a while loop so why do you want to repeat that?

 

Message 6 of 18
(3,910 Views)
Totally agree with Dennis.
0 Kudos
Message 7 of 18
(3,902 Views)

Dennis , you are talking general ? or still stuck to this piece of code i've uploaded ?

if you are talking general , then u mean i can replace any while loop inside the subVI with a while loop in the main VI instead ?

Regards

Eng. Mohammed Ashraf
Certified LabVIEW Associated Developer
InnoVision Systems Founder, RF Test Development Engineer
www.ivsystems-eg.com
0 Kudos
Message 8 of 18
(3,897 Views)

Do you need the sub-vi to run iterations for an undertermined period of time? 

 

If so, then why not implement it as a parallel loop to the main one.  Maybe part of a consumer loop.

 

If not.  Where the main loop would take care of each iteration and call the sub-vi in one shot. Then no need for a loop in the sub-vi.  

 

It's all a matter of how you want the software to behave.  Have you looked at Event Structures?

 

R

0 Kudos
Message 9 of 18
(3,889 Views)
Yes, I am talking in general. A while loop with a front panel stop Boolean cannot be controlled (well, it can with some hacks) so why have it? Your example will run forever unless you use the abort button and that is true of all subVIs like that. There are legitimate uses for a subVI to have a while loop and a stop button. The only time I use this type of subVI is when I want a popup for the user.
Message 10 of 18
(3,888 Views)