10-06-2022 05:27 AM
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.
Solved! Go to Solution.
10-06-2022 09:21 AM
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?
10-06-2022 09:37 AM
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
10-06-2022 09:42 AM - edited 10-06-2022 10:31 AM
@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...
10-06-2022 09:57 AM
10-06-2022 10:33 AM
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...
10-06-2022 10:46 AM - edited 10-06-2022 10:47 AM
@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.
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!!!!
10-07-2022 02:51 AM
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
10-07-2022 02:56 AM
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.