LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why doesn't my VI operate when inserted into another VI?

Solved!
Go to solution

It is a flat sequence that has individual while loops in each stage. 

Each of the while loops traps execution until an OK button is pressed, and local variables control the loop terminal of each. 

A toggling action allows progress along the flat sequence.

When run by itself I have indicators showing me that the traps control the sequence.

There is no overall While loop.

I saved this first purely as a VI and then in a project.

Inserting this VI into another project lets me begin the sequence but the OK button doesn't operate the stages within the sub VI

Any clues please? I've uploaded a snip of the start of the sequence. Only the Begin button works and the OK button does nothing. Fine in its own project.

0 Kudos
Message 1 of 9
(1,100 Views)

I recommend to start with the learning resources listed at the top of the forum. Pay attention to dataflow.

 

Once you learn about state machines, you no longer need sequence structures, greedy loops and local variables in the wrong representation. All big no-no's!

 

If you have problems after "inserting" into another VI, please attach the entire thing: caller and subVI, so we can give specific advice. You talk about OK buttons. Is that on the caller or on the subVI? Is the subVI configured to show the front panel when called? How are things wired together?

0 Kudos
Message 2 of 9
(1,093 Views)

I've created LabVIEW applications before, I think there is something basic this one is missing. I will attach the VI I'm trying to insert to others as a sub VI. Thank you for your assistance.

 

It runs perfectly by itself. Press Begin, then keep pressing OK until it advances through the stages

0 Kudos
Message 3 of 9
(1,080 Views)

@CG_DTB wrote:

It is a flat sequence that has individual while loops in each stage. 

Each of the while loops traps execution until an OK button is pressed, and local variables control the loop terminal of each. 

A toggling action allows progress along the flat sequence.

When run by itself I have indicators showing me that the traps control the sequence.

There is no overall While loop.

I saved this first purely as a VI and then in a project.

Inserting this VI into another project lets me begin the sequence but the OK button doesn't operate the stages within the sub VI

Any clues please? I've uploaded a snip of the start of the sequence. Only the Begin button works and the OK button does nothing. Fine in its own project.


 

Well in general you are doing it wrong, so, so wrong...

 

But the answer to your question is when a sub-VI can starts it reads all the inputs. Once it is running your controls outside the sub-VI are not functional until that sub-VI completes. (Well there are ways but they are rather advanced and still a kludge. IMHO) 

 

My first advice is to take the free tutorials linked at the top of the forum and learn proper program architecture.

 

Second when you find yourself thinking a Sequence Structure (Flat or Stacked) is the right thing to use, THINK AGAIN!

 

The Sequence Structures should not be used at all except for a few limited cases.

 

A simple State Machine can probably handle this. Imagine each of your sequence frames as a "state" in the machine. Using a State Machine will have the benefit if being able to abort or change the order of the sequence based on conditions, user input, errors, etc...

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 9
(1,073 Views)
  • Never ever attach a VI that is set to run when opened. That's very rude!!!!
  • Stacked sequences should never be used. (Flat sequences sparingly).
  • Why are most of your terminals disconnected?
  • Greedy loops are bad.
  • "Switch until released" is almost never a reasonable mechanical action unless it controls a car horn.
  • All you need is one toplevel loop and a state machine architecture.

 

0 Kudos
Message 5 of 9
(1,063 Views)

I could make a case for "sequence structures are NEVER" needed.  If you need to force dataflow that badly, you could always make the stuff you would put in a sequence structure into a subVI instead.  Of course this is overkill for most instances of this usage, but still, for the purists...

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 9
(1,028 Views)
Solution
Accepted by topic author CG_DTB

@CG_DTB wrote:

I've created LabVIEW applications before, I think there is something basic this one is missing. I will attach the VI I'm trying to insert to others as a sub VI. Thank you for your assistance.

 

It runs perfectly by itself. Press Begin, then keep pressing OK until it advances through the stages


Instead of a 10-frame stacked sequence, 20+ local variables and numerous greedy loops, here's a quick draft to get you started (no local variables, no sequences, One while loop with a reasonable wait, correct mechanical actions, etc.).

It is probably not exactly correct in all details, but should give you some ideas.

 

altenbach_0-1665070957213.png

 

And yes, once it is called from another VI, you need to ensure that the front panel is shown and you operate it on the panel of the subVI. Alternatively, you could just keep the state in a feedback node, instantly end the while loop, and call it repeatedly with controls on the main panel (not shown here). Dataflow!!!!

 

0 Kudos
Message 7 of 9
(1,019 Views)

Wow that's excellent work, thank you. I'm good at building bridges with Meccano so to speak, not the best method to get there. 

I don't know why my previous VIs have worked fine when used as sub VIs.

 

I'll study your example and learn with that

0 Kudos
Message 8 of 9
(970 Views)

Yes I think I'm trying to go about it in what I see as the simplest way, and will need to look further. Thank you. 

I can now see that this as a sub VI cannot work also.

0 Kudos
Message 9 of 9
(967 Views)