What I would like to do is decode a Grayhill keypad so I select
different sub programs. This will allow me to control how lights are
turned on and off. What is the best way to go about decoding the
matrix. The digikey part # is DH5003-nd.

Thanks for the help.

Patrick

Reply by arhodes19044●April 25, 20052005-04-25

I just did this for the "matrix" type. Mine was 12 pins. I did it is
C, but the effect is the same.

You have 4 rows and 4 columns. When a button is pressed, it connects
a certain column and row. You can not simply apply voltage to all
columns simultaneously to get a full reading. You would only know
what row the button was in.

You have to raise the voltage on one pin which is connected to one row
(or column, since your size is symmetrical). Then read all 4 column
pins, shift the bits left 4 places and strobe the next row, and read 4
columns, add that to the 4 bits you already have then left shift 4
more bits. Do this 2 more times and you have a 16 bit number that
corresponds to ALL the buttons that were active. You can read
multiple simultaneous presses this way.

The possible combinations of 16 buttons taken even just a few at a
time at a time is staggering (2 at a time is 120). 3 at a time is
560, 4 at a time is 1820.

-Tony

--- In basicx@basi..., "nuepatrick" <nuepatrick@y...> wrote: >
> Hello all,
>
> What I would like to do is decode a Grayhill keypad so I select
> different sub programs. This will allow me to control how lights are
> turned on and off. What is the best way to go about decoding the
> matrix. The digikey part # is DH5003-nd.
>
> Thanks for the help.
>
> Patrick

Reply by jstjohnz●April 26, 20052005-04-26

--- In basicx@basi..., "arhodes19044" <spamiam@c...> wrote:

>
> You have to raise the voltage on one pin which is connected to one row
> (or column, since your size is symmetrical). Then read all 4 column
> pins, shift the bits left 4 places and strobe the next row, and read 4
> columns, add that to the 4 bits you already have then left shift 4
> more bits. Do this 2 more times and you have a 16 bit number that
> corresponds to ALL the buttons that were active. You can read
> multiple simultaneous presses this way.
>
> The possible combinations of 16 buttons taken even just a few at a
> time at a time is staggering (2 at a time is 120). 3 at a time is
> 560, 4 at a time is 1820.
>
> -Tony

I don't think that will necessarily work for every case of multiple
simultaneous buttons. I think it would be OK for 2 at a time, but
some instances of more than 2 would give a false reading. Say you
simultaneously press (1,1), (2,1), and (2,2). This will also cause
yout to read (1,2) as being pressed even though it's not.

-jim-

Reply by arhodes19044●April 28, 20052005-04-28

--- In basicx@basi..., "jstjohnz" <jim@j...> wrote: >
> --- In basicx@basi..., "arhodes19044" <spamiam@c...>
wrote:
>
> >
> > You have to raise the voltage on one pin which is connected to one row > > (or column, since your size is symmetrical).
Then read all 4 column > > pins, shift the bits left 4 places and strobe
the next row, and read 4 > > columns, add that to the 4 bits you already
have then left shift 4 > > more bits. Do this 2 more times and you have
a 16 bit number that > > corresponds to ALL the buttons that were
active. You can read
> > multiple simultaneous presses this way.
> >
> > The possible combinations of 16 buttons taken even just a few at a > > time at a time is staggering (2 at a time is
120). 3 at a time is > > 560, 4 at a time is 1820.
> >
> > -Tony
>
> I don't think that will necessarily work for every case of multiple
> simultaneous buttons. I think it would be OK for 2 at a time, but
> some instances of more than 2 would give a false reading. Say you
> simultaneously press (1,1), (2,1), and (2,2). This will also cause
> yout to read (1,2) as being pressed even though it's not.
>
> -jim-

Hmmmmm, I have to check this out, but the idea surprises me.
The "scan codes" for the keys turn out to be a geometric
progression.

I thought they were unique codes. I will have to check.
The keypad is arranged 4 wide and 3 high. The scan codes are

so, the top row will add up to 0x0F, one less than the next key
which is 0x10.

Is there some combination which is not unique? I have not thought
about this extensively, but nothing jumped out to me....

-Tony

Reply by jstjohnz●April 28, 20052005-04-28

> > I don't think that will necessarily work for every case of
multiple > > simultaneous buttons. I think it would be OK
for 2 at a time, but
> > some instances of more than 2 would give a false reading. Say you
> > simultaneously press (1,1), (2,1), and (2,2). This will also cause > > yout to read (1,2) as being pressed even
though it's not.
> >
> > -jim-
>
> Hmmmmm, I have to check this out, but the idea surprises me.
> The "scan codes" for the keys turn out to be a geometric progression. >
> I thought they were unique codes. I will have to check.
> The keypad is arranged 4 wide and 3 high. The scan codes are
>
> 0x01 0x02 0x04 0x08
> 0x10 0x20 0x40 0x80
> 0x100 0x200 0x400 0x800
>
> so, the top row will add up to 0x0F, one less than the next key
> which is 0x10.
>
> Is there some combination which is not unique? I have not thought
> about this extensively, but nothing jumped out to me....
>
> -Tony

It's not that the individual key-codes aren't unique, the problem is
that when you have multiple keys pressed simultaneously the matrix
can't be properly scanned. For example, assume that you press 6
buttons at one time, the entire top row and the entire left column.
Now all 7 keypad leads are effectively tied together by those closed
contacts, and your scan routine will return 0xFFF even though not all
keys are pressed.

I *think* it will work fine with two keys pressed simultaneously, and
there probably aren't many applications where you would need more than
that (except maybe ctrl-alt-del!).

-jim-

Reply by arhodes19044●April 28, 20052005-04-28

--- In basicx@basi..., "jstjohnz" <jim@j...> wrote: > > > I don't think that will necessarily work
for every case of
> multiple
> > > simultaneous buttons. I think it would be OK for 2 at a time, but > > > some instances of more than 2 would give
a false reading. Say you > > > simultaneously press (1,1), (2,1), and
(2,2). This will also
> cause
> > > yout to read (1,2) as being pressed even though it's not.
> > >
> > > -jim-
> >
> > Hmmmmm, I have to check this out, but the idea surprises me.
> > The "scan codes" for the keys turn out to be a geometric
> progression.
> >
> > I thought they were unique codes. I will have to check.
> >
> >
> > The keypad is arranged 4 wide and 3 high. The scan codes are
> >
> > 0x01 0x02 0x04 0x08
> > 0x10 0x20 0x40 0x80
> > 0x100 0x200 0x400 0x800
> >
> > so, the top row will add up to 0x0F, one less than the next key
> > which is 0x10.
> >
> > Is there some combination which is not unique? I have not thought > > about this extensively, but nothing jumped
out to me....
> >
> > -Tony
>
> It's not that the individual key-codes aren't unique, the problem is > that when you have multiple keys pressed
simultaneously the matrix
> can't be properly scanned. For example, assume that you press 6
> buttons at one time, the entire top row and the entire left column. > Now all 7 keypad leads are effectively tied
together by those closed > contacts, and your scan routine will return 0xFFF
even though not all > keys are pressed.
>
> I *think* it will work fine with two keys pressed simultaneously, and > there probably aren't many applications where you
would need more than > that (except maybe ctrl-alt-del!).
>
> -jim-
Ah, I see what you are saying. I now agree. Fortunately, in my
application the need for multiple keys is rare. I will keep this in
mind.