Matrix keyboard and sleep


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807

    Default Matrix keyboard and sleep

    I am trying to get rid of double keypress of the same key in the matrix keyboard that is scanned by the PIC 16F886 after it wakes up from sleep.

    Not always but random times some of the key presses are detected two times. I think either a debounce or waiting for key release could help but cannot find a way to make it work.

    After any key press a beep is generated to give feedback.

    The 886 is in sleep and IOC is enabled to detect keypress of the matrix.

    Then flag pressed is set and main routine takes over.

    Attached is the program. Just delete the .txt extension.

    Ioannis

    RCT-100.pbp.txt
    Last edited by Ioannis; - 11th December 2022 at 14:17.

  2. #2
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: Matrix keyboard and sleep

    I didn't download your program, as I surf with my Mac and PBP on my PC. I would have to thumb-drive it over to look. However, the debounce procedure that works well for me it to detect a button press, then pause about 50 ms to see if it's still pressed. Then wait until it is no longer pressed, and wait another 50 ms. Something like this:
    Code:
    IOC_ISR:
    IF PORTB.4 = 1 THEN  'Button is pressed
      PAUSE 50  'Give it a chance to stabilize
      IF PORTB.4 = 1 THEN  'Recheck to verify button press
        WHILE PORTB.4 = 1  'Wait until button is released
        END WHILE
        PAUSE 50  'To give any rogue static bounces a chance to fizzle
        'Take Action Based on Button Press
      ENDIF
    ENDIF
    I've been coding in XC8 for the past couple years. My PBP is getting a bit rusty. Forgive me if my syntax isn't correct, but hopefully you get the gist of what I'm trying to accomplish.

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: Matrix keyboard and sleep

    Thanks Mike.

    The problem is that the keyboard is a matrix one that is scanned to see which key was pressed. This complicates the case...

    Ioannis

  4. #4
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: Matrix keyboard and sleep

    Maybe you could use a Timer to mask recently pressed buttons. When PORTB.4 IOC triggers, disable the IOC Interrupt for that pin, start your 50 ms Timer, then in the Timer ISR restore all IOC Interrupts, regardless of which one you disabled for the mask.

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: Matrix keyboard and sleep

    I am not sure why you mention the portb.4 bit but regardless, the idea to use timer is good. Thanks.

    Matrix keyboard is more complicated in that aspect, also if sleep is also involved.

    Ioannis

Similar Threads

  1. 10x4 matrix keyboard using only portB
    By aratti in forum Code Examples
    Replies: 19
    Last Post: - 16th November 2011, 09:39
  2. Matrix keyboard for up to 32 keys
    By Pedro Pinto in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 21st June 2009, 01:43
  3. Keyboard Matrix with a Twist
    By k3v1nP in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 29th October 2008, 10:51
  4. LCD + keyboard matrix minimal I/O
    By RFsolution in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 21st June 2006, 19:49
  5. Matrix keyboard problem
    By MegaADY in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 9th May 2005, 18:50

Members who have read this thread : 1

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