12-16-2017 03:25 PM
@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.
12-16-2017 04:15 PM
@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. 😄
12-17-2017 09:56 PM - edited 12-17-2017 09:56 PM
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
12-19-2017 10:51 AM
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?
12-19-2017 02:54 PM - edited 12-19-2017 02:56 PM
This is how I do a "wait state" in a state machine that can be aborted at anytime.
Then my Error State closes the VISA sessions and exits (it only displays the error message IF there was an actual error).
12-19-2017 03:02 PM
@RTSLVU
Why not use something like this?
mcduff
12-19-2017 03:15 PM - edited 12-19-2017 03:20 PM
For reasons I don't want to rehash here and divert this thread, I don't use Event Structures in any of my programs.
12-19-2017 03:59 PM
@RTSLVU
Well, the suggestion is there if you are ever feeling naughty.
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
12-19-2017 04:33 PM
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.
12-19-2017 11:09 PM
Is there a way to do positive edge triggers on a push button?