LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

A sequence controlled by an input button

Solved!
Go to solution

Hi guys.

I want to create a sequence that is controlled by an input button for example a "NEXT" button that will commence a set of instructions assigned in step 2 of a sequential structure. Something like we see in an installation of a software.

Can somebody direct me in the right direction?

0 Kudos
Message 1 of 8
(3,489 Views)
Solution
Accepted by topic author therealjohndoe77

Google for "state machine LabVIEW" and also search here the forum. If you meant you want to use the "Flat sequence structure" or the "stacked sequence structure", you do it wrong. Use a proper state machine.

 

What you describe is easily managable using a State Machine, and you can do much more with it. For example you can have a "Next" and a "Cancel" button, and depending on the user's choice, the state machine will go into a different state. In case of the Next button, it will start to do some operations for example (which operation should be anytime abortable ("Abort" button), in a short time, this is also a benefit of a good state machine), and for the Cancel button the State Machine will go into an "Idle" state, waiting for new user commands, and so on...

 

 

 

0 Kudos
Message 2 of 8
(3,471 Views)

This is an easy way to make a sequence.  The first case will wait until the Next boolean changes, you put whatever you need in subsequent cases and a True constant to stop the While loop.

 

snip.png

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 3 of 8
(3,461 Views)

What's the purpose of this?

 

If you want to use a sequence, the sequence structure already exists.  Re-creating it with a while loop and case structure doesn't really provide added benefit.  If you want flexibility, you should be developing a state machine.  In neither case would it make sense to create this structure.

0 Kudos
Message 4 of 8
(3,449 Views)

A Sequence structure can't exit early; mine can. 

You can add a shift register and pass data between states, an ugly idea with a Sequence structure.

My suggestion is a mini-State Machine, yours uses the oft-vilified Sequence structure.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 5 of 8
(3,419 Views)
Solution
Accepted by topic author therealjohndoe77
You definitely want a state machine, but one built inside an event structure like jcarmody showed. The idea it to have a timeout event that contains the logic for the state machine. To provide interaction with the user, have the timeout value for the event carried in a shift register so you can in essence pause the state machine.

The loop surrounding the event structure should also have a shift register carrying the state variable (a typedef enumeration).

When the state machine gets to a point where user interaction is required, it write a -1 to the timeout shift register, thus turning the timeout off. The Next Burton event handler sets the timeout to 0 to restart the state machine and writes the appropriate next state to shift register carrying the state variable.

http://www.notatamelion.com/2015/02/23/building-a-proper-labview-state-machine-design-pattern-pt-1/

http://www.notatamelion.com/2015/03/02/building-a-proper-labview-state-machine-design-pattern-pt-2/

Mike....

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 6 of 8
(3,405 Views)
Thanks guys I'm ready all of your suggestions. Will make sure to post a reply if the state machine idea works real soon!
0 Kudos
Message 7 of 8
(3,382 Views)

It worked! Thanks guys for the pointers!

0 Kudos
Message 8 of 8
(3,305 Views)