Shop OBEX P1 Docs P2 Docs Learn Events
A Passive Keypad Decoder? — Parallax Forums

A Passive Keypad Decoder?

DroneDrone Posts: 433
edited 2007-07-26 21:31 in Propeller 1
Hello All,

In a magazine I saw the attached schematic for decoding a 4X4 keypad using only 6 resistors and one pin. Does anyone have the theory behind this technique, such as how to choose the optimum valued resistors to so that there is a unique Vout regardless of how many keys are pressed?

I need to design a decoder like this for a 4X3 keypad, not 4X4. The schematic looks simple but I'm having trouble getting my rum-soaked brain around it. Building it and testing it would mean doing 4096 combinations of key presses - yuk.

Thanks...

David
355 x 480 - 29K

Comments

  • SkogsgurraSkogsgurra Posts: 231
    edited 2007-07-25 14:51
    This design could work. But do not use conductive rubber keys. Their resistance will make your signals very fuzzy. With no keys closed, you get Vcc out. With any key closed, you get anything from 0 % of Vcc (key "1") to around 55 % (key "D"). Key "C" produces around 54 %.

    So, an A/D that uses Vcc as a reference and that resolves better than half a percent (an eightbitter) could work. But a twelvebitter is better - or ten. You need good resistors and good switches. Any serious contamination will make your processor read wrong number.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • SkogsgurraSkogsgurra Posts: 231
    edited 2007-07-25 14:51
    This design could work. But do not use conductive rubber keys. Their resistance will make your signals very fuzzy. With no keys closed, you get Vcc out. With any key closed, you get anything from 0 % of Vcc (key "1") to around 55 % (key "D"). Key "C" produces around 54 %.

    So, an A/D that uses Vcc as a reference and that resolves better than half a percent (an eightbitter) could work. But a twelvebitter is better - or ten. You need good resistors and good switches. Any serious contamination will make your processor read wrong number.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • Mike GreenMike Green Posts: 23,101
    edited 2007-07-25 15:29
    Drone,
    The design you posted is not intended to uniquely detect multiple keypresses. If you work out the resistance values for all the combinations of keypresses (well ... maybe spot check the combinations), you'll see that multiple keypresses generally don't work. Don't forget that it's not just about 6 resistors and the keypad ... you need the ADC too ... plus you have a scheme that's sensitive to noise, etc.

    There's a nice, cheap keyboard encoder chip (MM74C922) that'll do all the work for you for a 4x4 keypad. For a 4x3 keypad, just leave one row or column disconnected.
  • Franz AchatzFranz Achatz Posts: 140
    edited 2007-07-25 15:48
    Hello Drone,

    or you could take an ATTINY2313 (Parallax, sorry about that) + download the BASCOM AVR Compiler
    and using the ps2_kbdemul.bas sample-program as your starting-point. Then you could use your nice keyboard directly
    at the Propeller PS2 Interface.

    best regards
    Franz
  • DroneDrone Posts: 433
    edited 2007-07-25 18:17
    Thanks for the feedback,

    I've done a bit of analysis of this keypad decoder scheme, one-key at a time...

    From my schematic, let's call R2-R4, Rc for the "column" resistor value, & call R5-R7 the "row" resistor value; in each case all individual column and row resistors have equal value. Then:

    Vout = Vcc*[noparse][[/noparse]R1/(R1+cRc+rRr)]

    Where:

    c = the column number, 0-3

    and;

    r = the row number, 0-3

    The forum doesn't allow MIME attachments (Excel spreadsheet), but I attach a .jpd screenshot of the Excel spreadsheet showing Vout for the individual keys, assuming Vcc = 1V.

    But my spreadsheet only deals with individual key presses. I need to analyze further whether multiple key presses will result in same (not good) or similar (depending on analog to digital resolution) results.

    This keypad technique intrigues me from a mathematical stand-point. All Vout values for all key press combinations can be modeled in a 3D matrix-space; but is it clear that individual key presses will always differ from mashing more than one key? Also, what A/D resolution is required to eliminate ambiguity with mashed keys, or even with individual keys?

    This decoding technique has been around for decades, but I've never really delved into it until now. It is a very interesting topic mathematically - Linear Algebra (ugh).

    The ultimate treatment of this decoder topic would result in a complete solution given:

    1. Vcc

    2. Number of rows

    3. Number of columns

    4. A/D resolution in bits

    Resulting in:

    5. Optimum values for all resistors or error if it can't be done.

    A tough nut to crack mathematically IMHO.

    Best Regards, David
    212 x 412 - 39K
  • deSilvadeSilva Posts: 2,967
    edited 2007-07-25 18:53
    Well this is common sense rather than mathematics, though being a mathematician myself it is sometimes tricky to draw the border, and I have colleagues saying mathematics is nothing else but common sense smile.gif

    You imediately see that - considering one column - a key in a lower row shortcuts all keys in the same column in higher position. Likewise the leftmost key in a given row wins!

    So how many keys you will press, just select
    (a) the leftmost of all rows
    (b) the lowest of each columns

    The resistance of the circuit will be exactly the parallel value of those two keys.

    So there is not a real chance to identify more than one key press.

    The values of the resistors are straightforward determined, as you just have to add the horizontal (0, 2, 4, 6 k) and the vertical values 0, .5, 1 1.5

    You can scale them as you like, but there relative values are the only ones for equidistant results.

    Post Edited (deSilva) : 7/25/2007 6:58:00 PM GMT
  • SkogsgurraSkogsgurra Posts: 231
    edited 2007-07-25 19:30
    Drone,

    If you adjust your values by substituting them for 1 minus value, you will get the correct result.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • Franz AchatzFranz Achatz Posts: 140
    edited 2007-07-26 10:06
    Just "killed" a old microsoft keyboard :-)

    Here is my PS2 Keyboard Hack.

    br

    Franz

    keyhack.jpg
  • OzStampOzStamp Posts: 377
    edited 2007-07-26 11:36
    Hi

    An SX28 would be my choice for a keypad controller
    Low cost ... working examples here on the forum.
    JonMac has a couple of them ... the SX B compiler has a schematic and help code embedded in the editor..

    RN
  • DroneDrone Posts: 433
    edited 2007-07-26 13:25
    Thanks for all the suggestions. I want to do this keypad interface with a few parts as possible. I'll have to use a pin and read the voltage across a cap or something. I think there are lots of examples of A/D with Propeller in the Labs. First I've got to find a keypad - not a simple prospect in Jakarta.

    Thanks again... David
  • ForrestForrest Posts: 1,341
    edited 2007-07-26 16:25
    This subject has been discussed before http://forums.parallax.com/showthread.php?p=570329
  • DroneDrone Posts: 433
    edited 2007-07-26 21:31
    Thanks Forrest; links to previous treatment of this topic are most welcome. I did diligence with both the native forum search and Google search, and came up with little... Not to say there isn't more out there. It's all about how you phrase the search.

    David
Sign In or Register to comment.