From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

state machine

Hello,

I am relatively new to Labview and have a problem with state machine.

I have a state machine which executes a vi when one button is pressed and executes another vi when a second other button is pressed. Both vi contain motions sequence for stepper motors.

The problem I have is that when I press the second button after having pressed the first one, the vi corresponding to the second button won't execute until the first vi ends. I need to be able to switch from one motion sequence to the other even if their execution is not complete. How do I do that and can you please provide an example?

Thanks a lot

 

0 Kudos
Message 1 of 6
(3,049 Views)

Sounds like you need to modularize your code a little better.  Instead of calling other VIs, you should be calling states in your state machine.  This way, you can easily stop a sequence and run a different one.


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 6
(3,045 Views)

Thank you for your answer, but I'm not sure I understand what you mean by calling a state instead of a vi. Here is an example, with a VI that switch LED on instead of my motion sequence...

 

0 Kudos
Message 3 of 6
(3,025 Views)

@jmbelzince68 wrote:

Thank you for your answer, but I'm not sure I understand what you mean by calling a state instead of a vi. Here is an example, with a VI that switch LED on instead of my motion sequence...


You call the different states in your state machine.  With your example, I would add a few states to your state machine: Set LED and Clear LED.  So when somebody presses 1LED, you call the Set LED state, followed by Wait For Event with a timeout of 3 seconds.  Then you go to the Clear LED state followed by the Wait For Event state.  You can set parameters (like which LED to change, how long for your event timeout, etc) in shift registers.


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
Message 4 of 6
(3,004 Views)

Thank you, but I still don't get how I can implement that with my motion vi's. I have two distint motion sequences in two separates vi, and I need to cancel one when I press a button. Can you provide a simple example with a state machine of how I can do that?

 

0 Kudos
Message 5 of 6
(2,976 Views)

@jmbelzince68 wrote:

Thank you, but I still don't get how I can implement that with my motion vi's.


You don't.  You need to break up that code and put each part into their own states.


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 6 of 6
(2,939 Views)