T4887 HOW TO: Write a simple software input debounce routine

Article ID: T4887
Date: 2/14/12
Product: EPSON RC+ All Versions

For certain applications, you may want an input to be maintained for a specific length of time in order for the signal to be considered stable. All of our controllers use an RC filter to debounce each input line. 

That being said, simple SPEL+ code can be used to ensure that an input is maintained for a specific amount of time.

Here is an example of how the code can be written  ->

Function main
    ‘Ensure that Input 0 remains on for 0.25 seconds
    If debounce(0, 0.25) = True Then
        Print "Input 0 remained on for 0.25 seconds"

Function debounce(inputNum As Integer, debounceTime As Real) As Boolean
    Wait Sw(inputNum) = On
    Wait Sw(inputNum) = Off, debounceTime
    If TW Then
        debounce = True
        debounce = False

 Author of the Article: John Yett

Related Articles

No related articles were found.


No attachments were found.

Visitor Comments

Article Details

Last Updated
21st of February, 2012

Would you like to...

Print this page  Print this page

Email this page  Email this page

Post a comment  Post a comment

 Subscribe me

Subscribe me  Add to favorites

Remove Highlighting Remove Highlighting

Edit this Article

Quick Edit

Export to PDF

User Opinions

80% thumbs up 20% thumbs down (5 votes)

How would you rate this answer?

Thank you for rating this answer.