debouncing switches with a timer interrupt?


Results 1 to 28 of 28

Threaded View

  1. #7
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    This would still require some kind of debouncing. The logic state can "bounce" a number of times when pressing a button
    Contact's debouncing should be solved with proper RC filter! If proper filtering is not possible an additional IF/THEN statement should reduce greatly the debouncing effect.

    Code:
    False        CON  0
    True         CON  1
    KEYPRESS  VAR portXx
    KeyFlag      VAR BIT
    Counter      VAR WORD
    
    LOOP:
    
    PAUSE 1
    
    IF KEYPRESS = False then
    
    IF KeyFlag = False Then
    Counter = Counter + 1
    KeyFlag = True
    ENDIF
    
    ELSE
    KeyFlag = False
    IF  KEYPRESS = False THEN  KeyFlag = True    ' re-checks the key logic state
    ENDIF
    .
    .
    .
    .
    .
    GOTO LOOP
    Al.
    Last edited by aratti; - 26th July 2010 at 00:01.
    All progress began with an idea

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts