Matrix Keypad routine


Closed Thread
Results 1 to 40 of 135

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    i has the advantages to be 'user configurable' and support many matrix Keypad type... up to 8X8.

    Can be used in a Timer interrupt as well, so you can read from it when you want, etc etc.

    Enjoy!
    Steve

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

  2. #2
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Post

    It looks quite comprehensive.

    I tend to base most of my algorithms around direct logic - boolean algebraic structures - rather than continuous mathematics, i.e calculations. PIC's are not as well equipped for calculations.

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


    Did you find this post helpful? Yes | No

    Default

    If that was true... ASM additions, substraction, bit shifting functions and few STATUS register bits wouldn't exist...(carry/Borrow, Z)
    Last edited by mister_e; - 12th May 2007 at 23:35.
    Steve

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

  4. #4
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Post On Par?

    Quote Originally Posted by mister_e View Post
    If that was true... ASM additions, substraction, bit shifting functions and few STATUS register bits wouldn't exist...(carry/Borrow, Z)
    So, you believe that a PIC performs on par with: A = (100 / I) + (J * 2) Vs IF B = 1 THEN A = 120 ?
    Huge amount of work for the PIC to do something like this: A = (100 / I) + (J * 2)
    100 x the num of clock cycles perhaps?
    Last edited by T.Jackson; - 13th May 2007 at 06:47.

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


    Did you find this post helpful? Yes | No

    Default

    Trent, If your example was right i could agree with some part of it... programming method and code optimization is an endless story... i'm not going to argument on which is better, which is worst... it's not what the actual thread is about anyway.

    100X ??? NAH, i don't think so. Depending the Value of I, few times maybe... but not 100 for sure. and * 2, is just a Byte shifting, one position to the left... not much... 1-2 cycle not much.
    -----------------------------

    Charudatt,
    before going in sleep mode, make sure those PINs are set to input (with pull-up) and the others are set LOW and OUTPUT (or input but with pull-down resistor). Once you'll press a key, RB<7:4> should see the LOW signal... which should wake your PIC, then you call the keypad scan.
    Last edited by mister_e; - 13th May 2007 at 09:11.
    Steve

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

  6. #6
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    I tend to base most of my algorithms around direct logic - boolean algebraic structures - rather than continuous mathematics, i.e calculations. PIC's are not as well equipped for calculations.
    Huh? Lookups have their place (and I love them when needed) but to say PICs are not equipped for calculations is just plain silly.

    For all your projects (that you have posted), was time of the issue or code space? (answer = the latter). With your example equation, which one takes less code space? Which one is faster for larger I? (answer = calculation based approach).

    Code:
    ' Calculation based equation A = 100/I +J*2
    If I > 100 then
    A = J<<1
    ELSE
    A = 100
    FOR X = 1 to 100
    A = A – I
    IF A < I then OUT
    NEXT X
    OUT:
    A = X+ J<<1
    ENDIF
    or
    Code:
    ' lookup based equation A = 100/I +J*2
    IF I = 1 then A = 100+J<<1
    If I = 2 then A = 50 +J<<1
    If I = 3 then A = 33+J<<1
    If I = 4 then A = 25+J<<1
    ...
    ' (a bunch more  if-thens)
    ...
    if I =100 then A = 1+J<<1
    If I > 100 then A = J<<1
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  7. #7
    Join Date
    May 2007
    Location
    Harvest, Alabama
    Posts
    10


    Did you find this post helpful? Yes | No

    Default Pull Up Resistors

    I know the Pull up Resistor attaches to Vss but where does it go else wise? Also... What happens to other test programs etc by its presence?

    Paul

  8. #8
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Smile Don't twist my words...

    Quote Originally Posted by paul borgmeier View Post
    Huh? Lookups have their place (and I love them when needed) but to say PICs are not equipped for calculations is just plain silly.
    I didn't say not equipped - I said not as well equipped. And, I'm more so referring to something that's more so "hard coded" over calculations. When I say hard coded I'm talking about something that's direct as in (a = 100) Vs (a = b x 10 / 2) No prizes for guessing which is faster and uses less resource.
    Last edited by T.Jackson; - 23rd May 2007 at 09:28.

Similar Threads

  1. calculator-like code entry with matrix keypad and display
    By Dennis in forum mel PIC BASIC Pro
    Replies: 35
    Last Post: - 16th December 2009, 22:58
  2. Need help in matrix keypad coding
    By rano_zen06 in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 24th May 2008, 13:16
  3. I2C PCF8574 4X4 Keypad routine
    By RFsolution in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th January 2007, 21:25
  4. Inconsistent output on a 4x4 matrix keypad
    By markcadcam in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 24th November 2006, 03:54
  5. very basic matrix keypad question
    By kitcat in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 8th July 2006, 21:33

Members who have read this thread : 2

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