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.
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.
05-11-2015 08:27 AM
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
05-11-2015 08:36 AM
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.
05-11-2015 09:27 AM
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...
05-11-2015 09:39 AM
@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.
05-11-2015 10:47 AM
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?
05-11-2015 12:12 PM
@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.