LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

State Machine Simultaneous States

Solved!
Go to solution

Hi Guys

 

I've developed a standard state machine VI based on a motor and vision project for college. Its working fine transitioning between states but there are a couple instances when i want 2 states to run simultaneously. One for the motor running and one to constantly monitor temperature for example.

Is there a way to have 2 states run simultaneously using the standard state machine structure in labview?. I really hope so as this is the final hurdle in my project!.

 

Any help would be much appreciated. Thanks in advance guys.

0 Kudos
Message 1 of 8
(4,011 Views)

Is your state switching condition is same for those two sates what you would like to run simultaneously? If so, put them to gether in one state to run simultaneously.

0 Kudos
Message 2 of 8
(4,007 Views)
Solution
Accepted by topic author Banjo_B

No, you can't have two simultaneous states.  That just blows apart any state machine logic.

 

You could either have the two states switching back and forth between each other.  Since each state shouldn't take a long time to run, they'll be virtually running at the same time.

 

Or, your monitor temperature shouldn't be considered a state at all since you said you want to constantly monitor it.  It should be its own separate while loop that is not part of the state machine logic.  Then it truly be running simultaneously with the state machine.  There are a number of ways to pass the data from the DAQ loop to the state machine loop so that the state machine can change state as necessary based on the temperature data.

Message 3 of 8
(4,004 Views)

Excellent. I didnt think of having a daq loop independant of the loop itself. That solves my problem.

Thanks very much for your input. I'm guessing I can wire in data from that independant daq loop that can dictate what happens inside the standard state machine if my temp should rise too high for example.

0 Kudos
Message 4 of 8
(4,000 Views)

You can't use a wire to get the data from the DAQ loop to the state machine loop, because the DAQ loop doesn't put any data onto that wire until the loop ends.

 

You can use a notifier to pass data.  You can use a functional global variable to pass the data.  You can also use a local variable as long as you don't do the kinds of things that lead to local variable abuse.

0 Kudos
Message 5 of 8
(3,997 Views)

Forgive my naivety but what is local variable abuse??. I use them quite a bit without any issues albeit in small/simple vi's.

0 Kudos
Message 6 of 8
(3,995 Views)

LabVIEW is a dataflow language.  Local (and global) variables break the dataflow.  Race conditions are a commonly encounterd problem. Search the Forum for local variables and you will find hunderds of posts on the topic.

 

They do have their appropriate uses, but the way they are often used by programmers coming to LV from a text-based language is what is often called abuse.

 

Lynn

0 Kudos
Message 7 of 8
(3,992 Views)

Ah yes, Ive read about race conditions in Labview For Everybody. Thanks for all your input and fast response guys. Its really appreciated. 🙂 

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