1
General Board / Re: How do you model a debounce of a signal?
« 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.
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.