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

Posted by arhodes19044●April 25, 2005

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

Posted by jstjohnz●April 26, 2005

--- 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-

Posted by arhodes19044●April 28, 2005

--- 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

Posted by jstjohnz●April 28, 2005

> > 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-

Posted by arhodes19044●April 28, 2005

--- 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.

DSP Developer (f/m) (Berlin) HOLOPLOT has developed a professional audio system that revolutionizes the way we perceive sound. The system allows us to direct audio waves, like light, in any direction, while maintaining a high quality and very constant volume over long distances.