LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timed state machine


@Blokk wrote:

An important feature of a state machine is that you can Abort it any time.


That's not entirely true.  There are many state machines that operate in an "infinite" embedded environment.

 

But, the rest of this post I entirely agree with.  It seems like the OP is taking this under consideration by using the Elapsed Timer Express VI rather than a convoluted mixture of delays and waits.  They're just getting stuck with how they'd want to use that input.

 

Given their desire to read the value of a button for N seconds prior to making an action, I can see why they went with the Switch Until Released mechanical action as well.

0 Kudos
Message 11 of 23
(2,395 Views)

@natasftw wrote:

Given their desire to read the value of a button for N seconds prior to making an action, I can see why they went with the Switch Until Released mechanical action as well.


The code posted by the OP only has switch action booleans, making the problem description even more confusing. 😄

0 Kudos
Message 12 of 23
(2,390 Views)

Thanks @Kannan. This is very close to what I need.

I have re-worked your VI and attached it here.

The issue I am having is that for example PB pressed for 1.5s causes it to go to state 1 but PB also can be pressed to go back to default state so it tends to toggle between default and state 1. Similar kind of thing with OEP input and state 2. How can I work around this?

 

Default state-
if NOT horn low and (PB has been held for 1.5s or 10s has elapsed) go to state 1
else (if OEP ack has been held for 3s go to state 2 else stay in default state)

state 1-
OEP ack of PB has been pressed go to default state
else (if 10s has elapsed go to state 2 else stay in state 1)

state 2-
OEP ack of PB has been pressed go to default state
else (if 5s has elapsed go to state 3 else stay in state 2)

state 3-
input 3 has been pressed go to state 1 else state 3

0 Kudos
Message 13 of 23
(2,373 Views)

You'll have to give me a bit more clarification CFarrelly. Based on the code you have, you would see the activity that you were describing. 

 

Were you hoping to not have PB tied in to force it back into the default state?

Casey G.
0 Kudos
Message 14 of 23
(2,339 Views)

This is how I do a "wait state" in a state machine that can be aborted at anytime.

 

timee.PNG

Then my Error State closes the VISA sessions and exits (it only displays the error message IF there was an actual error).

 

erxte.PNG

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 15 of 23
(2,332 Views)

@RTSLVU

 

Why not use something like this?

Snap10.png

 

Snap11.png

 

mcduff

 

 

Message 16 of 23
(2,325 Views)

For reasons I don't want to rehash here and divert this thread, I don't use Event Structures in any of my programs.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 17 of 23
(2,321 Views)

@RTSLVU

Well, the suggestion is there if you are ever feeling naughty. Smiley Very Happy

 

Another suggestion that probably does not matter much, is to protect your current while loop against an edge case, that is, the system time has been changed. My suggestion is to use the difference with the Tick Count VI. Since the output is U32 you do not need to worry about overflow, it just works.

 

Cheers,

mcduff

0 Kudos
Message 18 of 23
(2,307 Views)

Hi @CaseyGJ,

 

I want the PB when held for 1.5s to go to state 1 and then once the PB is pressed again I want it to revert back to the default state and stay in default state unless the PB is pressed again for 1.5s or the other conditions are met that cause it to change state.

0 Kudos
Message 19 of 23
(2,304 Views)

Is there a way to do positive edge triggers on a push button?

0 Kudos
Message 20 of 23
(2,291 Views)