LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timing engine with State Machine

Highlighted

Hi,

 

I am looking for some guidance on a VI that uses a timer which will advance a state machine through set stages when it reaches it target time. I've found this timing engine on the a blog post here and this looks exactly what i need but i cant figure out how to get this timer to restart again within a larger VI when it meets its target. I've tried putting in a case structure with Boolean control but because the while loops stops itself i cant get it to restart.

 

I would also advice on how the timer elapsed boolean could be used to advance a state machine to the next state? Or if there is a better way to do it?

 

 

 

 

 

0 Kudos
Message 1 of 5
(183 Views)

Why not just have a "Timer" state in your state machine that handles the timing between states? 

 

statemachineTimerCapture.PNG

-------------------------------------------------------------------
Unfortunately, most readers of this Forum, including some real Experts, have not mastered the skill of being able to read the code that Posters fail to post. If we cannot see "what you did wrong", we are unable to tell you how to fix it. (Bob Schor 28 August 2018)
0 Kudos
Message 2 of 5
(151 Views)

Well, you didn't show your State Machine, but if it's the usual "Case Statement inside a While Loop", where each Case is a State and you wire the Next State to a Shift Register when the Case exits, if you want State N to last for, say, 100 msec, simply put a 100 msec Wait in the loop.  The Principle of Data Flow will guarantee the Case element won't finish until everything in it, including the 100 msec Wait, is done.  Of course, if you want an immediate "Next State when Done", don't put in a Wait.

 

Bob Schor

0 Kudos
Message 3 of 5
(144 Views)

Hi Bob,

 

I wanted to avoid putting a wait in the stages as what I am aiming for is a experimental timer at the top of my main VI that shows the current stage (state) remaining time along with the  full experiment time and the ability to pause the timer which will halt the transition to the next state.

0 Kudos
Message 4 of 5
(119 Views)

@xander054 wrote:

Hi Bob,

 

I wanted to avoid putting a wait in the stages as what I am aiming for is a experimental timer at the top of my main VI that shows the current stage (state) remaining time along with the  full experiment time and the ability to pause the timer which will halt the transition to the next state.


That is going to require the timer to be a part of each state itself.

-------------------------------------------------------------------
Unfortunately, most readers of this Forum, including some real Experts, have not mastered the skill of being able to read the code that Posters fail to post. If we cannot see "what you did wrong", we are unable to tell you how to fix it. (Bob Schor 28 August 2018)
0 Kudos
Message 5 of 5
(113 Views)