A Passive Keypad Decoder?
Drone
Posts: 433
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
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
Comments
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.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
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.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
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.
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
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
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
If you adjust your values by substituting them for 1 minus value, you will get the correct result.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Here is my PS2 Keyboard Hack.
br
Franz
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
Thanks again... David
David