Book a Demo

Author Topic: How do you model a debounce of a signal?  (Read 2269 times)

mse

  • EA User
  • **
  • Posts: 308
  • Karma: +1/-0
    • View Profile
How do you model a debounce of a signal?
« on: May 29, 2024, 12:13:02 am »
I have a scenario where I would like to model a signal having a certain value for 500ms. It is part of an operation I am modeling called reset_system(). I wanted to do this in an activity with an AcceptTimerEvent but I'm not sure how it would be done.

I suppose it would be an AcceptTimerEvent action with a value of 500 ms, and an object flow representing the signal with a value of "ON", both leading to a join operator. When both are present, the control continues to the reset logic.

Is there some other way?

jfranflorez

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: How do you model a debounce of a signal?
« Reply #1 on: June 01, 2024, 02:18:09 am »
Do you want to A) keep a signal to a ceratin value for 500ms or B) you want to check if for 500ms a signal kept all the time a certain value?


If A)
Then you simple set the value and then use a timer event to delay furher execution

if B)

Your described approach would not be correct, because it would simply check that after 500ms have passed and the signal value is ON. So if from ms 2 to ms 499 the value of the signal was OFF, and at ms 500 the signal became ON, then you would still continue with the next steps.

Debouncing is usually a state based behavior so, a state machine would be better. But if you want to model with an Activity Diagram, then you need variables to represent the expiration of the timer.  The timer tracking variable is se to true if the timer expires and you have a decision loop which continously checks if Signal is ON and the timer has expired.