LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview SubVI

Hi Folks,

I need a help from you regarding SubVi.

I have a subvi in which two boolen inputs , two ouputs(one boolean and one string value)


Now i wanna start using one of the inputs and it goes in to a  while  loop infinitly. I have to stop the loop and exit from the subvi by using the other input .

Displayin the two outputs ....Bool and string

 

Can someone help me?

Boldness has genius, power and magic in it!'
0 Kudos
Message 1 of 10
(2,712 Views)

Care to share you VI?  How do you plan on stopping the loop?


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 2 of 10
(2,703 Views)

this is my subVI . I wanna use it  in my  final VI .

 

Boldness has genius, power and magic in it!'
0 Kudos
Message 3 of 10
(2,695 Views)

None of this code makes sense to me.  What are you trying to do with this subVI?


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 4 of 10
(2,682 Views)

You can only provide the inputs to the subVI at the time you call it, therefore if you call your subVI and it enters an infinitely running while loop then you cannot stop it from the calling VI. If this subVI needs to be stopped at some stage then make the condition for stopping the while loop settable from within the subVI itself.

 

If your while loop is meant to repeat a task until a particular output is achieved, ensure a pass state causes the while loop to exit. Do not wire one of the subVI inputs to the while loop conditional terminal because once set by the calling VI this input cannot be changed (sensibly).

Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 5 of 10
(2,679 Views)

Hi Guys thanks a lot.

My Aim is to give the user to deicide whether the photodiode works fine .

There will be a block in front of it and so till that time the program is running continously.

Later it is stopped when he decides it ok or not .

 

I think i am clear in my explaination,.

Boldness has genius, power and magic in it!'
0 Kudos
Message 6 of 10
(2,634 Views)

Hi MaveenD,

 

I think it would be easy for people to help you if you post your main vi and sub vi. Looking into it, the experts in the forum will definetly able to suggest some approach(if any) that can help you to meet your requirement.

______________________________________________
Kudos are welcome
0 Kudos
Message 7 of 10
(2,626 Views)

Hi MaveenD,

do you know to use Variables? That could help you with stopping a While Loop from outside or from another VI.

 

More information about Variables:

 

Tutorial: Local Variable, Global Variable, and Race Conditions

http://www.ni.com/white-paper/7585/en

 

Best Regards,

 

Martin

 

0 Kudos
Message 8 of 10
(2,586 Views)

This design doesn't require a sub-vi, just a while loop in your main vi inside a case structure.  Pressing a start button enters the while loop, the stop condition is wired to a Stop button on the front panel for the user.

 

As others have stated, the problem with trying to do this in a subvi is that the inputs are only evaluated at the time the subvi is called (your main code will not do anything until the subvi has finished running so a stop button on the main vi will do nothing and you subvi will NEVER stop).

 

To truly achieve this, you would have to run the two vi in parallel, opening the second one using VI reference and invoke node to run.  The data would be passed between the two using either a global variable or a functional global variable.  The problem with this, is that the user could still tell the main VI to run code which could interfere with the second vi, unless you programatically disable certain controls in this situation.

 

All in all, your desired function for this code sounds simple enough that it should just be inside your main vi.  

0 Kudos
Message 9 of 10
(2,581 Views)

Why is everyone suggesting using global variables. There are much better and preferred methods for passing data. I would recommend using queues, notifiers or user events to pass data between VIs.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 10 of 10
(2,559 Views)