State Transition with a time delay

21 次查看(过去 30 天)
I have a state transition which needs to be triggered when a condition is met for a fixed period of time.
In the example below, the response I would like is for the transition from the on to the off state to occur when the input is > 0 continuously for 5 seconds. If, during the 5 seconds input becomes <= 0 the state should remain on and the timer should reset. i.e. if input is > 0 again, it will wait for 5 seconds before transitioning to off.
The state machine below will transition to off instantly if input becomes > 0 after it has been in the on state for > 5 seconds.
Any help with resolving this problem is appreciated

回答(1 个)

Julia
Julia 2015-6-8
Hi,
you have to combine your two conditions with '&&'. That should solve your problem.
  2 个评论
Frazer Watson
Frazer Watson 2015-6-8
Thanks Julia.
I've tried the following for the on to off transition:
[after(5,sec)&& input>0]
although I'm still seeing the same problem. I believe that the 'after' timer is only reset on the transition into the state. this means that the 5 seconds begins as soon as the on state is entered rather starting when input is > 0.
I can fix my problem by adding the 'StartTimer' state as shown below which resets the timer when input is <=0. Doing this on my actual system would create other problems as I execute logic using the 'during:' command whilst in the on state and these would be distributed by as the state switches to StartTimer and back.
Julia
Julia 2015-6-9
Here is another solution. However, I did not use the after() command.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Complex Logic 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by