Keypads HELP! hehe, Need advice and possible code.


Closed Thread
Results 1 to 14 of 14
  1. #1
    Join Date
    Dec 2012
    Location
    Tennessee
    Posts
    262

    Default Keypads HELP! hehe, Need advice and possible code.

    I have 5 4x4 matrix Keypads (Grayhills), and I have 5 74C922N IC's (Keypad Interfaces)

    Now I am trying to use them but they want to use a few capacitors and other IC's in conjuction with the 922 Chip, What I would like is to only have the 922 chip, keypad, and PIC. If this is possible. I have not found good schematics for this, and am unsure what schematic would be best. I was hoping to use the Data Available pin to the INT (RB0) and tie the 4bit to (? PortC 0-3) I could use any pin as the data received. I can use the keypad.bas and tie the keypad strait to the PIC, but I would rather use these chips.

    So what should I use a direct Keypad-PIC connection and software code keystrokes? or Use the 922 Chips with Supporting Chip & Capactors? or Other options someone here may provide.

    My layout of code in my head right now appears like this.
    on INT(RB0) set Variable X = PortC
    send data received to 922 chip
    continute program, program now uses variable X


    PS, im only trying to use 1 keypad, I just noted that I have 5
    Chris


    Any man who has accomplished anything in electronics at one time or another has said... " STOP! WAIT! NOOO! Dangit.... Oh Well, Time to start over..."

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: Keypads HELP! hehe, Need advice and possible code.

    hey Wd, What are you talking about having to use more ic's than the 74C922? All you have to do is put a capacitor with the part to operate the oscillator and wala.... you have a keyboard decoder.... I used these IC's about 30 years ago and acording to the data sheet thay haven't changed. Just tie the tristate output control line low and connect the data available linr to the interrupt line.
    Dave Purola,
    N8NTA
    EN82fn

  3. #3
    Join Date
    Dec 2012
    Location
    Tennessee
    Posts
    262


    Did you find this post helpful? Yes | No

    Default Re: Keypads HELP! hehe, Need advice and possible code.

    all the schematics in the data sheet use other chips to help the 922, depending on the configuration you want it uses a 7474, or 7404, or a nand gate. none of the schematics show only the chip. if youve got one please post it to me, I havent found one on the web yet.
    Chris


    Any man who has accomplished anything in electronics at one time or another has said... " STOP! WAIT! NOOO! Dangit.... Oh Well, Time to start over..."

  4. #4
    Join Date
    Dec 2012
    Location
    Tennessee
    Posts
    262


    Did you find this post helpful? Yes | No

    Default Re: Keypads HELP! hehe, Need advice and possible code.

    Dave I tried that, it gave me really erratic results, numbers were all over the place even above 16. , so i disconnected the 4 data lines to the pic, and tested the lines output

    on the 922 Chip output, with 4 LEDS, pressing any key on pad repeatedly should output the same leds every time, however they blink like christmas lights.
    on the PIC (when INT fired) it outputs 0, 16, 06 randomly each time INT fires.
    tied the datalines back and now PIC does nothing till they are removed???

    Here is the code I am using, although this doesnt solve the issue with the 922 chip outputting random bits

    Code:
    include "LCD_D.bas"
    INCLUDE "DT_INTS-18.bas"     ; Base Interrupt System
    INCLUDE "ReEnterPBP-18.bas"     ; Include if using PBP interrupts
    TRISD = 0                               ' PORTD is Display
    TRISB = 1                               ' PORTB is Input
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler   INT0_INT,  _KEYPRESS,   PBP,  yes
    	endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    @   INT_ENABLE   INT0_INT     ; enable external (INT) interrupts
    
    X VAR BYTE : X = 0
    
    LCDOUT $FE, 2
    Pause 1000
    
    Main:
    LCDOUT $FE, 2
    LCDOUT $FE, $80
    LCDOUT DEC X
    PAUSE 500
    GOTO Main
    
    '---[INT - interrupt handler]---------------------------------------------------
    KEYPRESS:
    X = PORTB <<4  '922 Data lines 0,1,2,3 hooked to 4,5,6,7 of PORTB
    @ INT_RETURN
    Chris


    Any man who has accomplished anything in electronics at one time or another has said... " STOP! WAIT! NOOO! Dangit.... Oh Well, Time to start over..."

  5. #5
    Join Date
    Dec 2012
    Location
    Tennessee
    Posts
    262


    Did you find this post helpful? Yes | No

    Default Re: Keypads HELP! hehe, Need advice and possible code.

    OK the Data Bits from the 922 Chip are working ok now, wrong capacitor was in circuit, i thought it was a .1 and it was a 10. so the 922 chip sends a data available while any key pressed and the 4 data lines go high in binary.

    however the pic is not displaying anything but 0 on the LCD? ive even tried removing the <<4 just to get something out. nothing works. anyone see a problem?
    Chris


    Any man who has accomplished anything in electronics at one time or another has said... " STOP! WAIT! NOOO! Dangit.... Oh Well, Time to start over..."

  6. #6
    Join Date
    Apr 2013
    Posts
    32


    Did you find this post helpful? Yes | No

    Default Re: Keypads HELP! hehe, Need advice and possible code.

    I think you have a mistake here

    Code:
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler   INT0_INT,  _KEYPRESS,   PBP,  yes
    	endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    @   INT_ENABLE   INT0_INT     ; enable external (INT) interrupts
    I belive it has to be like this ;

    Code:
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler   INT_INT,  _KEYPRESS,   PBP,  yes
    	endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    @   INT_ENABLE   INT_INT     ; enable external (INT) interrupts
    actually both are same but you may wanna try

    PS: also "X = PORTB <<4" statement is wrong, change it to "X = PORTB >> 4"
    Last edited by elcrcp; - 23rd April 2013 at 00:20.

  7. #7
    Join Date
    Dec 2012
    Location
    Tennessee
    Posts
    262


    Did you find this post helpful? Yes | No

    Default Re: Keypads HELP! hehe, Need advice and possible code.

    I tried both , it still only displays a 0
    Chris


    Any man who has accomplished anything in electronics at one time or another has said... " STOP! WAIT! NOOO! Dangit.... Oh Well, Time to start over..."

  8. #8
    Join Date
    Dec 2012
    Location
    Tennessee
    Posts
    262


    Did you find this post helpful? Yes | No

    Default Re: Keypads HELP! hehe, Need advice and possible code.

    EDIT: I got it working, it was the TRISB line, I didnt update it for the inputs past 0. So I added TRISB = %11111111 and now its reading the data, its funny though i must have some wires in wrong place because only one row reads corrects numbers all the others are way off, will have to check pinouts of keypad. but its working now

    BEFORE EDIT:
    Ok it was a bit confusing to make sure the INT was firing so I moved the code down to the INT, it places a 0 on LCD when a key is pressed so the interupt is working, but its not reading data on portB

    heres a code update

    Code:
    include "LCD_D.bas"
    INCLUDE "DT_INTS-18.bas"     ; Base Interrupt System
    INCLUDE "ReEnterPBP-18.bas"     ; Include if using PBP interrupts
    TRISD = 0                               ' PORTD is Display
    TRISB = 1                               ' PORTB is Input
    asm
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler   INT0_INT,  _KEYPRESS,   PBP,  yes
    	endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    
    @   INT_ENABLE   INT0_INT     ; enable external (INT) interrupts
    
    X VAR BYTE : X = 0
    
    LCDOUT $FE, 2
    Pause 1000
    Main:
    PAUSE 500
    GOTO Main
    End
    '---[INT - interrupt handler]---------------------------------------------------
    KEYPRESS:
    X = PORTB 
    X = X >> 4
    LCDOUT $FE, 2
    LCDOUT $FE, $80
    LCDOUT DEC X
    @ INT_RETURN
    Last edited by wdmagic; - 23rd April 2013 at 23:17.
    Chris


    Any man who has accomplished anything in electronics at one time or another has said... " STOP! WAIT! NOOO! Dangit.... Oh Well, Time to start over..."

  9. #9
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: Keypads HELP! hehe, Need advice and possible code.

    Well Chris, I'm glad you got it going. Did you learn anything? Do you still need those other support IC's? Thats all it takes is a little persiverance.
    Dave Purola,
    N8NTA
    EN82fn

  10. #10
    Join Date
    Dec 2012
    Location
    Tennessee
    Posts
    262


    Did you find this post helpful? Yes | No

    Default Re: Keypads HELP! hehe, Need advice and possible code.

    nope you dont these those other IC's, I notice when you start adding outside chips wether it be a temp sensor or a 40 pin digital IC, it has a adverse affect on the project if you have an error, because you cant always test the externals as well as the PIC, and settings can be crucial. a missing CAP, a wrong value CAP, and a TRIS statement was the major problems here. I couldnt find the problem because there was internal and external problems at the same time.

    NOTE: I did have to add a capacitor to the KeyBounce pin on the 922.

    Thanks
    Chris


    Any man who has accomplished anything in electronics at one time or another has said... " STOP! WAIT! NOOO! Dangit.... Oh Well, Time to start over..."

  11. #11
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,597


    Did you find this post helpful? Yes | No

    Default Re: Keypads HELP! hehe, Need advice and possible code.

    Just a little note:

    This code fiirst moves cursor to top of screen, then moves cursors to beginning of line 1. That's the same thing.

    Code:
    LCDOUT $FE, 2
    LCDOUT $FE, $80
    LCDOUT DEC X
    You can simplify that with:
    Code:
    LCDOUT $FE, 1, DEC X
    It will clear the screen, move cursor to first line and display value.

    Robert
    Last edited by Demon; - 25th April 2013 at 18:21. Reason: typo

  12. #12
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,597


    Did you find this post helpful? Yes | No

    Default Re: Keypads HELP! hehe, Need advice and possible code.

    Also, what happens if you try this?

    Code:
    X = PortB >> 4
    Robert

    .
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  13. #13
    Join Date
    Dec 2012
    Location
    Tennessee
    Posts
    262


    Did you find this post helpful? Yes | No

    Default Re: Keypads HELP! hehe, Need advice and possible code.

    yes thats how i had X set up at first, I just had the>> going the wrong way, I can now put it back like that .

    on the screen clearing, ive got to stop using clear except when initializing because of LCD flicker, but i should be able to do

    LCDOUT $FE, $80, DEC X , " " 'add spaces to cover excess leftover characters

    That way all the other data on screen stays wile updateing line 1
    Chris


    Any man who has accomplished anything in electronics at one time or another has said... " STOP! WAIT! NOOO! Dangit.... Oh Well, Time to start over..."

  14. #14
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,597


    Did you find this post helpful? Yes | No

    Default Re: Keypads HELP! hehe, Need advice and possible code.

    That makes sense.

Similar Threads

  1. Membrane Keypads
    By jonathan in forum Adverts
    Replies: 0
    Last Post: - 15th April 2009, 21:18
  2. Low key count membrane keypads
    By AndrewC in forum General
    Replies: 6
    Last Post: - 7th April 2009, 20:12
  3. Need advice on A/D
    By james in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 24th August 2007, 19:30
  4. Custom membrane keypads UK
    By Calco in forum Off Topic
    Replies: 2
    Last Post: - 14th May 2004, 09:02

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