Something wrong with the keypad?


+ Reply to Thread
Results 1 to 10 of 10

Thread: Something wrong with the keypad?5531 days old

  1. #1
    Pairair
    Guest Pairair's Avatar

    0 Not allowed!

    Unhappy Something wrong with the keypad?

    I can't get the keypad to work properly on my Proton board. I'm sure it's worked before. I read about some problems others had at 20mHz, so I switched back to 4mHz, but no success. Here's what happens with the Button command:
    Code:
    Include "proton_4.inc"
    
    Dim btnvar As Byte
    btnvar = 0
    
    Cls
    DelayMS 20
    
    loop:
        Button PORTB.0, 0, 255, 250, btnvar, 0, nopress
        Print "* "
    nopress:
    GoTo loop
    On reset, it usually sits still. But if my fingers even get close to the keypad (or the board itself!) it will start printing stars like mad.???

    OK, so I tried the Inkey command:
    Code:
    Include "proton_4.inc"
    Cls
    Loop:
    Print At 1, 1, Dec InKey, " "
    GoTo Loop
    Now, it prints 16! As long as I press and hold switches 1 - 12, the LCD will print 1 - 12. But as soon as I release the button it's back to 16. And switches 13 through 16 just cause a little "blink" in the row of LEDs and no change on the display.

    Messy post, but please help!!

    Regards,
    Pär

Attention
×

This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

The advertisements we display are relevant to this web site and your browsing history

Please consider supporting us by disabling your ad blocker.


Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

If you can, please report issues in the forum area WebSite / Forum Issues


Thank you for your attention.

  • #2
    Fanatical Contributor Tim's Avatar
    Join Date
    Jan 2003
    Posts
    7,682
    Thumbs Up
    Received: 47
    Given: 95
    Total Downloaded
    1.32 GB

    0 Not allowed!

    Default

    Pär

    I can't comment on the Button command as I have never used it, but I use the inkey command all the time.

    If you read the manual it says

    "INKEY will return a value between 0 and 16. If no key is pressed, the value returned is 16. Using a LOOKUP command, the returned values can be re-arranged to correspond with the legends printed on the keypad: -

    VAR1 = INKEY
    KEY = LOOKUP VAR1, [255,1,4,7,"*",2,5,8,0,3,6,9,"#",0,0,0]

    The above example is only a demonstration, the values inside the LOOKUP command will need to be re-arranged for the type of keypad used, and it's connection configuration."

    I have tried your code on the VSM and it works as expected, an thing else I would look at your hardware.
    Tim

  • Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #3
    Pairair
    Guest Pairair's Avatar

    0 Not allowed!

    Default

    Thanks Tim!
    There's got to be a hardware problem, but I don't know where to look. I've stripped the board from any peripherals, and replaced the pic and xtal. What can possibly cause the switches to act like "touch-controls"?

    Pär

  • Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #4
    Mark Rodgers
    Guest Mark Rodgers's Avatar

    0 Not allowed!

    Default

    It sounds like you have not got the pullups switched on and the pic inputs are floating in thin air!!

  • Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #5
    AlanR
    Guest AlanR's Avatar

    0 Not allowed!

    Default

    Hi Pär

    Try entering.

    Keypad problems

    In the search tab at the top of the screen.
    This type of problem is very common.
    Lots of info there.

    Regards
    Alan

  • Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #6
    Pairair
    Guest Pairair's Avatar

    0 Not allowed!

    Default

    Yes, thanks Alan.

    I think I've been through them all. I've just reprogrammed the bootloader .hex file, and suddenly the Inkey routine works as expected. I'm still not sure what the "PORTB_PULLUPS = On" does, have to look into that. But before i loaded the new bootloader .hex, if I declared the pullups on, the bootloader wouldn't wait for me to reset, just loaded it. That behaviour is gone as well....

    aaaahhhhh....... just babbleing, I know. I've been away from all this for a while, and still very "amateurish".

    Pär

  • Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #7
    Prolific Poster See_Mos's Avatar
    Join Date
    Feb 2004
    Posts
    1,297
    Thumbs Up
    Received: 17
    Given: 0
    Total Downloaded
    872.27 MB

    0 Not allowed!

    Default

    Hi Par,

    to use the button command with the keypad first you have to decide which row or column of buttons you want to use, find the common line to the PIC and make that high output. You can then use that row of the keypad as four separate buttons.

    No idea why you get 16 with no button pressed, it is a while since I used INKEY, I thought it returned 255 if no buttons are pressed ? You might have a short on two of the connections to the keypad, or more likely a faulty button

    regards T.

  • Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #8
    Fanatical Contributor Tim's Avatar
    Join Date
    Jan 2003
    Posts
    7,682
    Thumbs Up
    Received: 47
    Given: 95
    Total Downloaded
    1.32 GB

    0 Not allowed!

    Default

    The reason Inkey produces 16 when no key is pressed is that it is counting up as it works it's way through the keypad, when it finds a key set it will exit the count indicates the key found made. 16 is no 17 on it's count list i.e. no key

    Here is a section of code that shows how the inkey routine works...

    Code:
    DEVICE 16F628A
    
    DIM KBRD_PORT AS PORTB
    DIM KBRD_PORT_TRIS AS TRISB
    DIM KBRD_PORT_COLUMNS AS %11110000 ' DEFINE THE COLUMN INPUTS
    DIM KBRD_PORT_ROWS AS %00001111 ' DEFINE THE ROW INPUTS
    DIM KBRD_ROWS AS 4 ' NUMBER OF ROWS IN PORT 
    DIM DEBOUNCE_CNT_VAL AS 4
    
    DIM KBRD_TEMP AS BYTE ' TEMP VARS
    DIM KBRD_TEMP2 AS BYTE ' /
    DIM KEY AS BYTE ' KEY RESULT
    DIM LAST_KEY ' KEY READ IN LAST SCAN 
    DIM KEY_FLAGS AS BYTE ' KEY SCAN GEN CONTROL FALGS
    DIM DEBOUNCE_CNTR AS BYTE ' 
    
    DIM KEY_PRESSED AS KEY_FLAGS.0 ' GENERAL CONTROL FLAGS 
    DIM NEW_KEY AS KEY_FLAGS.1
    
    PORTB_PULLUPS = 1 
    KBRD_PORT_TRIS = KBRD_PORT_COLUMNS ' MAKE THE COLUMNS BITS INPUTS
    
    GOTO START
    
    KEYSCAN:
    KBRD_PORT = KBRD_PORT_ROWS ^ KBRD_PORT_ROWS ' SEND ROW LINES LOW
    KBRD_TEMP = KBRD_PORT & %11110000 ' READ ALL THE COLUMNS INPUTS
    IF KBRD_TEMP <> $F0 THEN ' ONLY DO THE REST IF A KEY WAS PRESSED
    KBRD_TEMP = KBRD_ROWS ' NO OF ROWS TO SCAN
    KBRD_TEMP2 = %11111110 ' SET UP MASK
    KEY_PRESSED = 0 ' CLEAR THE FLAG TO START WITH
    CLEAR KEY 
    REPEAT
    KBRD_PORT = KBRD_TEMP2 ' WRITE TO THE PORT TO SET THE ROW LOW
    INC KEY
    IF KBRD_PORT.4 = 0 THEN KEY_PRESSED = 1: BREAK ' CHECK COLUMN 1
    INC KEY
    IF KBRD_PORT.5 = 0 THEN KEY_PRESSED = 1: BREAK ' CHECK COLUMN 2
    INC KEY
    IF KBRD_PORT.6 = 0 THEN KEY_PRESSED = 1: BREAK ' CHECK COLUMN 3
    INC KEY
    IF KBRD_PORT.7 = 0 THEN KEY_PRESSED = 1: BREAK ' CHECK COLUMN 4
    DEC KBRD_TEMP 
    KBRD_TEMP2 = KBRD_TEMP2 << 1 ' ROTATE THE MASK
    SET KBRD_TEMP2.0 ' SET THE BOTTOM BIT
    UNTIL KBRD_TEMP = 0 ' SCAN ALL THE ROWS
    IF KEY_PRESSED = 1 THEN KEY_SCAN_DONE ' HAS A KEY BEEN PRESSED
    ENDIF
    Tim

  • Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #9
    Prolific Poster See_Mos's Avatar
    Join Date
    Feb 2004
    Posts
    1,297
    Thumbs Up
    Received: 17
    Given: 0
    Total Downloaded
    872.27 MB

    0 Not allowed!

    Default

    Of course it is, silly me, it is the LOOKUP command that returns the 255. There is no fault, Par just needs to add the LOOKUP to convert the keycodes to sensible values.

    T.

  • Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #10
    Pairair
    Guest Pairair's Avatar

    0 Not allowed!

    Default

    Got it working now! Thanks everyone for your input.
    Now, I'm off to play with my new Proton IR that I just picked up at the post office!

    Thanks again!

  • Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

    Thread Information

    Users Browsing this Thread

    There are currently 1 users browsing this thread. (0 members and 1 guests)

       

    Similar Threads

    1. dropdownlists wrong?
      By Puffeltje in forum Fuse Configurator
      Replies: 2
      Last Post: 7th April 2019, 20:32
    2. Replies: 5
      Last Post: 4th April 2014, 12:26
    3. What is wrong?
      By laserline in forum Proton Plus Compiler v3
      Replies: 11
      Last Post: 14th December 2008, 14:31
    4. What's wrong with my for next loop???
      By SimonJA in forum Proton Plus Compiler v3
      Replies: 7
      Last Post: 19th December 2006, 19:37
    5. Wrong value return...
      By fanie in forum Proton Plus Compiler v3
      Replies: 6
      Last Post: 22nd July 2006, 01:29

    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