Searching \ for 'Keypad Decoding ][][' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/index.htm?key=
Search entire site for: 'Keypad Decoding ][]['.

Truncated match.
PICList Thread
'Keypad Decoding ][]['
1999\01\04@024004 by Greg Cormier

flavicon
Does anyone have any information on decoding a keypad? I have 2 of em. One
is 4 by 4 (16 keys) and has a 9 pin header, the other is a phone keypad and
has 8 pins. I havn't a clue how they work.

Thanks
greg


-----------------------
Greg Cormier
Kathmandu, Nepal
Local time : GMT + 5h30m
spam_OUTgcormierTakeThisOuTspamwlink.com.np
ICQ # : 565465

1999\01\04@032902 by Eric Borcherding

picon face
Greg,

Been there done that, can help...

These are matrix arrangements.    X1-X4 and Y1-Y4.   In the case of the
Phone unit it is missing Y4, and has 12 keys?...

There is a PIC APP Note for a strobe function to read a keypad.   I have
also seen a crafty design somewhere that allows a hard contact keypad
(low resistance) to switch an R2R ladder of reisitors on the X and Y at
discontinuous Ranges that bias a 555 timer and then read as a
singular frequency by a single PIC pin.

If you want to go the H/W route this is possible too...   Some older but
still on the market devices like a MM74C922 or LM74C923 are keypad
encoders that do all of this work in silicon; but they are quite pricy and
could be replaced cheaper by a 13 I/O PIC if a in mass design.

Have fun

Eric Borcherding

1999\01\04@034557 by Mark Willis

flavicon
face
There are several ways;  2 of the most common I've seen are to short
two grids together (1 X-axis set of wires and 1 y-axis set of wires),
and to short the two grids together but to ground, instead of to just
each other.  Not the only way this is done, of course.

 The easy way to figure it out (if you cannot take these apart) is to
use a volt-meter and measure resistances with various keys pressed. (As
it's not uncommon to put diodes in series with each switch, you'll want
to measure both ways until you know how the keypad's built.)  The diodes
let you distinguish between different simultaneous keys pressed at the
same time (Looking at a telephone, if you hold down 1 and 5, the phone
can tell the difference - it doesn't think that 2 and 4 are pressed,
because a diode is in line with each set of contacts.)

 Usually you have a pin per row of keys, and a pin per column of keys,
then sometimes an extra for ground.  (Sometimes it's some Vcc type
voltage, not Ground, of course.)

 Some keypads output DTMF tones, too, which is even more hard to trace
with a voltmeter <G>

 Mark, .....mwillisKILLspamspam@spam@nwlink.com

Greg Cormier wrote:
{Quote hidden}

1999\01\04@040252 by Greg Cormier

flavicon
Thanks for the input guys. I just ripped the 4x4 and here's the story :


Pins 1 to 4 - Columns 1 to 4 respectively.
Pins 5 to 8 - Rows 1 to 4 repectively.
Pin 9 - Ground, VCC??? Beats me.

Pin 9 does nothing. Runs a trace around the keypad and contacts with a
metal grid near the keys. Maybe for grounding to reduce RF noise? So
pressing 1 (R1, C1) shorts pin 1 and 5 together. Now, I have absolutely no
clue how to read it. At first, if it put it to ground, it would of been
easier. How do I test for a connection between the 2 with a PIC? In the
meantime, I'll try to find that Microchip article...

thanks
greg


-----------------------
Greg Cormier
Kathmandu, Nepal
Local time : GMT + 5h30m
.....gcormierKILLspamspam.....wlink.com.np
ICQ # : 565465

1999\01\04@044512 by Mark Willis

flavicon
face
Sounds like the pin 9 is for noise immunity perhaps, probably ground
it <G>

 The max-pins method is to connect RA.0 through RA.3 (for example) as
outputs on the Columns, and RB.0 through RB.3 as inputs on the Rows.

 Then to read the current state of the switches:  (Put a pulldown
resistor, say 20k, from each Row to Ground, for this example.)

 For each Column i (you need to loop 4 times through these commands:
   Make the RA.i pin for this column high, and the other 3 of RA.0
through RA.3 low.
   Read in RB.0 through RB.3, this tells you the status for this scan
of that column.
   Handle de-bouncing (if you scan at 100-250 Hz or so and get say 3
good key closures in a row, you have a good keypress.  Vertical Counters
are good, use what works for you here.)

 There are LOADS of good shortcuts and other good ways to do this (2
pins to a shift register for driving the columns, some people prefer to
default to all columns high and put a low on the column being checked, &
use pull-UP resistors per row, especially on a PIC with built-in weak
pull-ups;  there are entire IC's out there such as the MC14490 Hex
switch de-bouncer (But at $4.45 or so apiece for those, a PIC is a
cheaper more flexible solution, with pins left over to do other things
<G>)

 Mark, EraseMEmwillisspam_OUTspamTakeThisOuTnwlink.com

Greg Cormier wrote:
{Quote hidden}

1999\01\04@050002 by Quentin

flavicon
face
It is called Matrix scanning, simply put:
You connect the rows and columns to your PIC. Lets say the rows are your
scan lines (PICout) and column are your data lines(PICin). This could be
the other way around, depending on keypad.
Now what you do is to to let the PIC pull Row 1 high. Then the PIC reads
the Data lines. Your program must know that with Row 1 high and with
whichever of the column lines high, that represents the number on
keyboard. Next Row 2 is switched on (and Row 1 off) and data lines are
read again, and so forth.

Quentin

1999\01\04@053947 by paulb

flavicon
face
My "two bits" FWIW (is it?).  It«s rather funny that this toPIC hit
the Motorola HC11 list just yesterday!  I initially assumed in fact that
was what the "][][" meant.

Eric Borcherding wrote:

> Some older but still on the market devices like a MM74C922 or LM74C923
> are keypad encoders that do all of this work in silicon; but they are
> quite pricy and could be replaced cheaper by a 13 I/O PIC if a in mass
> design.

 I can«t understand this.  These chips are expensive as one-offs, but
so are PICs.  Surely in bulk they are dirt cheap?

Mark Willis wrote:

> There are several ways;  2 of the most common I've seen are to short
> two grids together (1 X-axis set of wires and 1 y-axis set of wires),
> and to short the two grids together but to ground, instead of to just
> each other.

 The second method was used in all the early phones as they used two
separate L-C oscillators, and many IC implementations.  Actually, those
early L-C jobs generally had one or two (muting) additional common
contacts.  Obviously, the single-crosspoint keypads are *much* easier to
construct.  The 8-pin 12-key device may also have a shield as the eighth
wire, or a common contact.

> As it's not uncommon to put diodes in series with each switch, you'll
> want to measure both ways until you know how the keypad's built.

 It«s extraordinarily uncommon in a telephone keypad and all others
I«ve seen!

> The diodes let you distinguish between different simultaneous keys
> pressed at the same time (Looking at a telephone, if you hold down 1
> and 5, the phone can tell the difference - it doesn't think that 2 and
> 4 are pressed, because a diode is in line with each set of contacts.)

 Most telephone encoder ICs respond (deliberately) to two keys pressed
in one row by generating no column tone, and vice versa.  This allows
generation of "row only" and "column only" tones for special purposes.
Keys pressed in different rows *and* columns generate *no* tones.

 In fact, even the keyboard on which you«re presently typing is most
unlikely to have "rollover" diodes.  Capacitive and inductive keyboards
don«t need them, but most keyboards either ignore combinations they
can«t distinguish, or simply generate the fourth "phantom" if three keys
with a row and column in common are pressed.

> Make the RA.i pin for this column high, and the other 3 of RA.0
> through RA.3 low.

 No!  If two keys are pressed together you can short the drivers.  For
pull-downs as you happened to specify, you pull the active one up and
TRIS the others.

 You described the slow method.  The fast one is to use the weak pull-
ups on all port B, pull rows low and see which column goes low, then
pull columns low and see which row goes low.  All not low are again,
TRIS.

> Vertical Counters are good, use what works for you here.

 I se no reason for vertical counters if you are only de-bouncing a
single key (i.e., whichever is alone, closed).

>   There are LOADS of good shortcuts and other good ways to do this

 Obviously!

> some people prefer to default to all columns high and put a low on the
> column being checked, & use pull-UP resistors per row, especially on a
> PIC with built-in weak pull-ups;

 A standard relating to TTL logic, and the concern to make it short-
circuit proof, FWIW.
--
 Cheers,
       Paul B.

1999\01\04@054357 by Greg Cormier

flavicon
Hmmmm, seems pretty simple now... :) <foot in my mouth> Now just the
coding. Rather tricky... Although I was trying it using only PORTB, should
be easier now. I found a source example, but it was in C :( Sheesh. Here's
my approach though.

#1 Toggle a column high.
#2 Read in PORTB.
#3 If PORTB == 0  goto #1
Otherwise, we know it's in column X.
... Check each bit of PORTB.

Should be faster, only check the bits once we're sure we've got a match?
But I have a question. Is the only way to check if it's 0 with this method :

movlw           PORTB
movwf           rowstats
incf            rowstats        ; Hassle. yuk.
decfsz  rowstats

??? Sure is a pain. Ungh, assembler, gotta love it....

thanks
greg


-----------------------
Greg Cormier
Kathmandu, Nepal
Local time : GMT + 5h30m
@spam@gcormierKILLspamspamwlink.com.np
ICQ # : 565465

1999\01\04@172021 by Mark Willis

flavicon
face
Paul B. Webster VK2BZC wrote:
> <snipped>
> > Make the RA.i pin for this column high, and the other 3 of RA.0
> > through RA.3 low.
>
>   No!  If two keys are pressed together you can short the drivers.  For
> pull-downs as you happened to specify, you pull the active one up and
> TRIS the others.
>
>   You described the slow method.  The fast one is to use the weak pull-
> ups on all port B, pull rows low and see which column goes low, then
> pull columns low and see which row goes low.  All not low are again,
> TRIS.

 *Knew* there was another good reason to use diodes where I was at <G>
Every time I've done keypads, chording has been absolutely REQUIRED,
with TTL O.C. demultiplexers you need diodes to allow this - last one I
did had that with pull-up resistors on the rows - that was a *LONG* time
ago, in the late 70's? <G>  With OC and pull-ups on the rows, it is
mandatory to use diodes for chording, far as I can figure (Tri-Stating
IS a more elegant way to do this, though, if it'll do the job.)

 Can anyone suggest a way to do chording keyboards without diodes,
though?  I cannot see a way (sans diodes) to distinguish between a X1
and a Y2 chord, and a X2 and Y1 chord.  Unless you don't use a matrix at
all.  4 diodes're cheaper than a shift register <G>

 (My current project has diodes as it's a 6x3 chording keyboard, need
to get going and start coding on that puppy some more, this week.)

 Mark

1999\01\04@195340 by Max Toole

picon face
In a message dated 99-01-04 04:03:19 EST, you write:

<< Pins 1 to 4 - Columns 1 to 4 respectively.
Pins 5 to 8 - Rows 1 to 4 repectively.
Pin 9 - Ground, VCC??? Beats me.

Pin 9 does nothing. Runs a trace around the keypad and contacts with a
metal grid near the keys. M >>

I use the Digitran KL0054 keypad, which is a 12 key pad.  It has 8 pins; 3
columns and 4 rows plus the other is connected to ground.  This interfaces
directly to DTMF generator chips such as the National TP5089N (No longer in
production) and a Harris chip that is pin for pin compatible.

The way it works is that, when you press a key, it connects that row and that
column to the common pin, which, in my case, is ground.

Hope this helps,
Max

1999\01\05@135305 by Peter L. Peres

picon face
On Mon, 4 Jan 1999, Mark Willis wrote:

>   *Knew* there was another good reason to use diodes where I was at <G>
> Every time I've done keypads, chording has been absolutely REQUIRED,
> with TTL O.C. demultiplexers you need diodes to allow this - last one I
> did had that with pull-up resistors on the rows - that was a *LONG* time
> ago, in the late 70's? <G>  With OC and pull-ups on the rows, it is
> mandatory to use diodes for chording, far as I can figure (Tri-Stating
> IS a more elegant way to do this, though, if it'll do the job.)
>
>   Can anyone suggest a way to do chording keyboards without diodes,
> though?  I cannot see a way (sans diodes) to distinguish between a X1
> and a Y2 chord, and a X2 and Y1 chord.  Unless you don't use a matrix at
> all.  4 diodes're cheaper than a shift register <G>

Hello Mark,

 with a PIC or any other device that can go tristate it is easy, because
you can isolate the whole matrix and read each node as seen. There are
some phantom combinations that cannot be detected reliably but this is a
postprocessing problem (more specifically: whether the phantom key(s)
masked by a chord are pressed or not).
 The easiest way to do this is to read the matrix into a ram matrix and
operate on the set bits in the matrix. There are several ways to do this,
depending on what you are after.
 I don't know what you mean by an (X1,Y2) (X2,Y1) chord, but in such a
keyboard, problem chords will be: (X1,Y1)+(X1,Y2)+(X2,Y2) for ex., where
the unknown is (X2,Y1), which can't be determined. There is no two-key
chord that will confuse a 2 by 2 direct matrix, there are four three-key
chords that will, and one four-key chord that is indistinguishable.
 Similarily, on a 3 x 3 keyboard, for each four adjacent keys (as above),
the same problem exists (four 'key-hiding' chords), but there is one more
hidden (undeterminable) key for each key added to the 3-chord in a certain
direction etc. Fortunately, most people have only 10 fingers and 2 palms.
 In practice, using good switches and a fast read-out algorythm (PIC)
called often it is possible to determine even the hidden keys. This relies
on the fact that the code reads the keys faster than any human can move,
and the keys go 'down' individually. After they are down, however, the
user can play tricks with the 'phantom' keys without their being readable.

Peter

More... (looser matching)
- Last day of these posts
- In 1999 , 2000 only
- Today
- New search...