LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

state machine

Solved!
Go to solution

Can anyone explain to me on which criterion one would choose an event structure over a case structure in a state machine design?

 

Thank you,

Christian

0 Kudos
Message 1 of 27
(4,728 Views)

Personally, I would say that putting an event structure within of a standard state machine would be the best plan if you were to go though that sort of route. I would usually use this as a UI case in my state machine that would do certain things when I did something on the front panel. Having an event structure instead of a case structure doesn't entirely make sense either since it gets away from the whole state machine design scheme.

Message 2 of 27
(4,709 Views)

Do you mean to say that an event structure is useful only if you control a lot of inputs from the front panel? And if otherwise, I should opt for a case structure?  Thanks.

0 Kudos
Message 3 of 27
(4,701 Views)

Do you have an example of what you are looking for?  Are you talking about polling instead of using an event structure?

 

Assuming I am understanding the problem correctly, I tend to have an "Idle" state.  In this state, I put an Event Structure.  If I am just waiting for a user input, then the timeout is -1 (wait forever).  If I am just checking something while I go through a sequence, then I set the timeout to something else that will limit the rate of my sequence.


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 27
(4,693 Views)

I basically have a program with ten different states, but all the inputs are set before I start running the program. Once the program is running, none of the set up needs to be changed. Here is a first (incomplete) attempt at the program.

 

 

0 Kudos
Message 5 of 27
(4,680 Views)

So if you are not doing any user inputs, why would you use an event structure?  I think I might be seeing where your original question is going.

 

Each state of your state machine should be a different case of a Case Structure.  If you are looking for user inputs, use an Event Structure.


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 6 of 27
(4,626 Views)

Thank you.

 

Another question. I am using subvi's in my state machine that display data in graphs and charts. The program runs okay, but the graphs and charts remain empty. What could the reason be?

0 Kudos
Message 7 of 27
(4,536 Views)

@christianwos wrote:

Another question. I am using subvi's in my state machine that display data in graphs and charts. The program runs okay, but the graphs and charts remain empty. What could the reason be?


You probably need to attach your code.

0 Kudos
Message 8 of 27
(4,524 Views)

Looking at what you've said, it doesn't sound like you would need an event structure.  An event structure is meant to act on user events.  If there aren't any user events, why would you want to act on them?

 

In terms of how it impacts the defintion of a state machine, it doesn't hurt the architecture in any way.  State machines involve a finite number of states that interact with each other based on inputs.  One of the most common examples is the traffic light.  A car pulling up to the red light, an event, triggers a change in states that leads to the car's light turning green.  When the car leaves, an event, the light returns to red.  It's VERY common for a state machine to accept user input.  In fact, the device you're using to post to these forums is a state machine.  It acts almost entirely based on user input.

 

 

 

As far as your question, it's pretty difficult to say without seeing your code.  If I had to guess, you're not sending data from the subVI to the main UI.  As a result, the graphs on the subVIs are being updated but nothing passes that on to the UI.  As a result, it looks like nothing is being updated.  If you want more meaningful help, you probably want to attach your code.

Message 9 of 27
(4,504 Views)

Thank you so much for your thorough explanation. I will post the code as soon as I get to work tomorrow morning.

0 Kudos
Message 10 of 27
(4,496 Views)