a little help with keypad on 18f4520 please


Closed Thread
Results 1 to 18 of 18

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    Tray to use LCDout Dec Key_Press and see if you get the correct ascii value.

    Al.
    Last edited by aratti; - 20th November 2009 at 15:30.
    All progress began with an idea

  2. #2


    Did you find this post helpful? Yes | No

    Default

    Thanks Al

    I now see numbers and not ||

    OK so this is how I am now setup ...
    http://www.rentron.com/serkey16.htm
    notice there are no pull-ups on the rows.

    I have series resistors on for the columns (100 OHM)
    In other words KEYPAD >> RESISTOR >> PIC (PortB4-7)
    Aah at least I am now seeing characters
    When Idle the LCD just displays 4 8 12 and the 16 and then it repeats :-(
    What's wrong :-(

    My wishlist
    A schematic( where to wire the pull-ups and where to wire the pull downs.
    I would prefer not to use Port.B since I have the pickit 2 setup for ICSP on PortB.6 and B.7.
    So which ports are advisable to use ? How should I TRIS each ?

    Some code shows keypad ports as input tohers as output ... some show pull-ups others show no pull-ups ?

    This is getting mega confusing

    Should I just stick with dipswitches and give up on the dream of using a keypad for input ?

    Any more help or comments would be seriously appreciated

  3. #3
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    OK so this is how I am now setup ...
    http://www.rentron.com/serkey16.htm
    notice there are no pull-ups on the rows.
    You don't see any pullup because they are using internal pullup on portB

    See the instruction that activate the weak pullup in the code.

    OPTION_REG.7 = 0 ' Enable PORTB pull-ups

    If you use different port then you have to use external resistors.

    Al.
    All progress began with an idea

  4. #4


    Did you find this post helpful? Yes | No

    Default

    Hi again Al

    Thank you again for the reply :-)

    Adding OPTION_REG.7 = 0 ' Enable PORTB pull-ups
    Shows a compile error in Microstudio
    Does not compile
    I am using an 18F4520

    So I am back to square one

    Any suggestions

  5. #5
    Join Date
    Dec 2007
    Location
    Finland
    Posts
    191


    Did you find this post helpful? Yes | No

    Post

    Code:
    INTCON2.7 = 0     'switch pull-ups ON
    "Each of the PORTB pins has a weak internal pull-up. A single control bit can turn on all the pull-ups. This is performed by clearing bit, RBPU (INTCON2<7>). The weak pull-up is automatically turned off when the port pin is configured as an output. The pull-ups are disabled on a Power-on Reset."
    (Page 96 on PIC18F4520 manual)

    BR,
    -Gusse-
    Last edited by Gusse; - 20th November 2009 at 19:08.

  6. #6
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Adding OPTION_REG.7 = 0 ' Enable PORTB pull-ups
    Shows a compile error in Microstudio
    Does not compile
    I am using an 18F4520
    Dennis not all pic has the internal pullup, could be that your mcu has not pullup.
    (Check the datasheet).



    Since you will need the pullups (otherwise the keypad will not work), so add four external 10K resistors.

    Al.

    Edit:

    Gusse has read the datasheet for you: Replace OPTION_REG.7 = 0 with INTCON2.7 = 0
    Last edited by aratti; - 20th November 2009 at 19:16.
    All progress began with an idea

  7. #7


    Did you find this post helpful? Yes | No

    Post Thank you

    Al, Gusse
    Thank you both I implemented mister e's keypad using the whole of port B as an input had to perform some pin swaps on row and column order and it's working .
    I have two more questions :

    1.How do I set the keys to display the correct characters as per the keypad
    my matrix key's are labeled is as follows:

    1 2 3 A
    4 5 6 B
    7 8 9 C
    * 0 # D

    but when I press the keys for example 1,2,3,A
    My readout is 1,2,3,4

    Would I have to do a lookup or re-assignment ?

    2. How do i capture a number ending with a hash for example

    The reason I am asking is because I would like to type in a number for example 135 end it with a # to signify an enter and then store and send the number (TX).

    Any further help would be appreciated

  8. #8
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    1 2 3 A
    4 5 6 B
    7 8 9 C
    * 0 # D

    but when I press the keys for example 1,2,3,A
    My readout is 1,2,3,4

    Would I have to do a lookup or re-assignment ?
    I am not familiar with mister e's keypad program, but if you get the sequence from 1 to 16, then use an array to code out what you need.

    Code:
    Kp_Array    var byte [17]
    
    
    Kp_Array[1] = "1"
    Kp_Array[1] = "2"
    .
    .
    .
    Kp_Array[15] = "#"
    Kp_Array[16] = "D"
    2. How do i capture a number ending with a hash for example
    If Kp_Array[keypress] = "#" then ........


    Al.
    All progress began with an idea

Similar Threads

  1. 4x4 keypad Help
    By aaliyah1 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 5th October 2010, 16:34
  2. Universal Keypad System
    By aratti in forum Code Examples
    Replies: 3
    Last Post: - 18th January 2009, 13:06
  3. Keypad input test
    By Kalind in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 8th October 2008, 04:00
  4. Need help in matrix keypad coding
    By rano_zen06 in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 24th May 2008, 13:16
  5. Inconsistent output on a 4x4 matrix keypad
    By markcadcam in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 24th November 2006, 03:54

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