LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Aborting execution of Flat Sequence Structure

Solved!
Go to solution

Hello, 

 

With reference to the attached VI, how do I abort the ongoing Flat Sequence Structure execution either by switching of the 'Selection switch' or by 'Stop' button?

 

As I see, when the 'Selection switch' is put to OFF, it will complete the ongoing execution and then go the 'False' case. And, when the 'Stop' button is pressed, apart from the ongoing execution, another execution of the sequence takes place before the VI stops. Reason for this? 

 

Note: Please put a few second delay in between the LEDs. 

 

Off topic: I do save the VI with the timer values. But when I reopen the VI, those values will be reset to zero. How can I retain those values upon next opening?

 

Thanks. 

0 Kudos
Message 1 of 4
(4,392 Views)

Without looking into the VI:

Use (single frame) sequence structures only in very specific situations. Never use them anywhere else!

 

That being said, you are looking for a "state machine".

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 4
(4,388 Views)
Solution
Accepted by topic author Ganny

"Off topic: I do save the VI with the timer values. But when I reopen the VI, those values will be reset to zero. How can I retain those values upon next opening?"

 

Right click on the control --> Data operations --> Make Current Value Default. Then save your VI (Ctrl+ s). Next time you open it, it will show the new values as initial values. Anyway, a proper LabVIEW program should end up in a executable application (.exe) which only requires the LV Runtime engine (and some other stuff depending on hardware interfaces, etc). For an exe(cutable) you cannot use the above "make current value default" trick. The proper way is to use configuration files. You application searches for a config file at launch, if it finds one, loads it and updates the required controls based on the data stored in the config file...

 

And about your main question: yes, you should never use flat sequence structure for such purpose! Learn how to program a proper State Machine, which is expandable, easy to debug, and most importantly, can be aborted/stopped in a sane way in a short time!

Message 3 of 4
(4,373 Views)
Solution
Accepted by topic author Ganny

Ganny wrote:  how do I abort the ongoing Flat Sequence Structure execution either by switching of the 'Selection switch' or by 'Stop' button?

You can't.  The is just the way sequence structures work.  They have to execute to completion, every frame in order.  Look into using a State Machine instead.

 


Ganny wrote:

As I see, when the 'Selection switch' is put to OFF, it will complete the ongoing execution and then go the 'False' case. And, when the 'Stop' button is pressed, apart from the ongoing execution, another execution of the sequence takes place before the VI stops. Reason for this?


Data Flow.  The Selection Switch is read before the case structure.  But everything inside of the case structure must run to completion before the loop can iterate.  On the next iteration, the Select Switch will be read as FALSE and then that case will run.

 

For the Stop button, it is being ran in parallel to the rest of the case in the loop.  So the terminal will likely be read as soon as the loop iterates.  So if you press it while the case structure is running, you have to wait for that to complete so the loop can iteration and then the terminal will be read.  BUT, the rest of the code in the loop must also be ran in order for the loop to complete.  So the case structure code must run again.



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
Message 4 of 4
(4,372 Views)