Quick 4x4 keypad matrix question


Closed Thread
Results 1 to 16 of 16

Hybrid View

  1. #1
    Join Date
    Jun 2011
    Location
    St. Louis, MO
    Posts
    13


    Did you find this post helpful? Yes | No

    Default Re: Quick 4x4 keypad matrix question

    Thanks for the reply Archangel. In response to your questions...

    1. Why are you putting in LCD defines if you are using the USART, Do you want dual display?
    The LCD is used just for quick on-the-spot feedback. It was part of another program, so I usually just cut-and-paste it into other programs. The USART is just for debugging purposes. Plus it remindes me of the old BBS days .

    2. Since you did not specify which PIC you are using, which port is your PIC equipped to use the USART ? Is it the same as the keypad uses?
    At the beggining I stated I was using an PIC 16F877 @ 20 mhz. The hardware USART TX/RX are ports C6/C7 on the 16F877 which are only being used for serial communication. The keypad is is connected to PORTB.0 to PORTB.7.

    3. Why did you change the value of the resistors ? I suspect Bruce proved out his design before posting it on his website.
    I was under the impression that the value of the resistors were not that important to a certain extent. While researching keypad matrices, a few people stated that any value <= 10k would be sufficient. I had 1k resistors with me at the time so i gave it a shot. I just replaced the 1k resistors with 270-ohm. It seemed to make the problem occur only on one button (row3-col1). While pressing the button repeatedly, the value displayed will sometimes be the value of the button directly below it, but only intermittently.

    By changing the 1k resistors for 270 helped eliminate the problem on all the buttons except the one (row3-col1). I still cant figure what is causing this.

    thanks again for the help.

    Sean

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: Quick 4x4 keypad matrix question

    Quote Originally Posted by triton99 View Post
    Thanks for the reply Archangel. In response to your questions...

    1. Why are you putting in LCD defines if you are using the USART, Do you want dual display?
    The LCD is used just for quick on-the-spot feedback. It was part of another program, so I usually just cut-and-paste it into other programs. The USART is just for debugging purposes. Plus it remindes me of the old BBS days .

    2. Since you did not specify which PIC you are using, which port is your PIC equipped to use the USART ? Is it the same as the keypad uses?
    At the beggining I stated I was using an PIC 16F877 @ 20 mhz. The hardware USART TX/RX are ports C6/C7 on the 16F877 which are only being used for serial communication. The keypad is is connected to PORTB.0 to PORTB.7.

    3. Why did you change the value of the resistors ? I suspect Bruce proved out his design before posting it on his website.
    I was under the impression that the value of the resistors were not that important to a certain extent. While researching keypad matrices, a few people stated that any value <= 10k would be sufficient. I had 1k resistors with me at the time so i gave it a shot. I just replaced the 1k resistors with 270-ohm. It seemed to make the problem occur only on one button (row3-col1). While pressing the button repeatedly, the value displayed will sometimes be the value of the button directly below it, but only intermittently.

    By changing the 1k resistors for 270 helped eliminate the problem on all the buttons except the one (row3-col1). I still cant figure what is causing this.

    thanks again for the help.

    Sean

    Hi Sean, Ok . . .

    1.OK . . . had to ask . .
    2. Sorry old eyes, I missed that. Ok that's good.
    3. Looked at Bruce's page again, his statement proves you right . . . non critical.
    This code is floating around the forum in many threads, with many variations, and the only thing I see is no TRIS settings for your ports B,C, & D. In the 1 Mr._E did he set the portb Tris as follows: TRISB = %11110000 , he also used an interrupt to detect the keypress, it maybe your finger is faster than your loop, especially given you are using 3 different display protocols. I would comment out any code you are not pressed to use and see if it improves, also you might consider debug over serout as it executes faster using less code space ( or so they tell me) I have not yet proven that last statement to myself, but it is a bit faster, in terms of how long a loop takes to execute,
    oh and try these defines (from mister E's famous picmulti calc)
    Code:
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    DEFINE HSER_SPBRG 129 ' 9600 Baud @ 20MHz, 0.16%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    Last edited by Archangel; - 19th June 2011 at 10:39. Reason: I really miss the Old Forum's text format
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Quick 4x4 keypad matrix question

    The program kinda of works....sometimes when a button is pressed, the number sent via HSEROUT is actually the number below it.

    i.e. Say the number "3" is pressed...most of the time the number "3" is displayed...but sometimes the number displayed will be "6", which is the button just below the "3" on the keypad.
    Double check your hardware.
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: Quick 4x4 keypad matrix question

    What's in the INCLUDE "ansi.inc" file ?
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  5. #5
    Join Date
    Jun 2011
    Location
    St. Louis, MO
    Posts
    13


    Did you find this post helpful? Yes | No

    Smile Re: Quick 4x4 keypad matrix question

    I just assembled the same circuit using an 16f88 instead of the 16F877. Using the same circuit and code[plus changes for the 16F88], the program works perfect.

    These are the register setting I use on the 16F88.

    Code:
    CMCON =     7                   '// PortA = digital I/O
    OPTION_REG.7  =  0              '// Enable PORTB pull-ups
    ADCON1  =  7 
    ANSEL=%00000000                 '// set all analog pins to digital
    ANSEL = 0                       '// disable ADC
    With the circuit working on the 16F88, I resumed working on the 16F877.

    I rebuilt and re-checked the wiring on the 16F877. I also got rid of all the extra LCDOUT and HSEROUT commands, while using only the SEROUT command, just like the Bruce's original example. It still has the weird problem. I just cant seem to pinpoint what is causing the error. Its weird too, because I dont have to be pressing the button fast....it does it even if when I press the button slowly. Every once in a while it will display the number below instead of the actual number. Arghhhhhh!!!! I love this stuff .

    *Archangel, the "ANSI.INC" was from Darrel Taylors easy ANSI module for PBP.
    It is the main reason I wanted to use HSEROUT. The ansi.inc only works with the hardware USART, and not with SEROUT(2).

    Thanks for the help, Im not giving up on this.

    Sean
    Last edited by triton99; - 20th June 2011 at 03:03.
    "Reality is merely an illusion, albeit a very persistent one." , Albert Einstein

  6. #6
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: Quick 4x4 keypad matrix question

    Ok, just wanted to know, oh and I do see where you set TrisB in your orig modified code. Maybe as Dave mentioned there is a hardware problem, bad breadboard or the pic it'self. Those breadboards get corrosion inside them and then the fun begins.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: Quick 4x4 keypad matrix question

    Internal pull-up may sucks, check OPTION reg in the datasheet and see what happen when you set a pin to output... probably the internal pull-up get disabled 'till you set them again... use external one and post your results.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Members who have read this thread : 0

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

Tags for this Thread

Posting Permissions

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