Network

C

Chinmay Pendharkar

Jan 1, 1970
0
Hi,

I was just given a 4x3 Matrix Keypad for a project. It did not come
with a data sheet. The wierd this is that it has 10 output pins.

I had expected 7 or 13. But 10 is an wierd number. Any of you know
about these type of keypads and how one can interface them with
microControllers?

Thanks,

-Chinmay

B

Bob Monsen

Jan 1, 1970
0
Hi,

I was just given a 4x3 Matrix Keypad for a project. It did not come
with a data sheet. The wierd this is that it has 10 output pins.

I had expected 7 or 13. But 10 is an wierd number. Any of you know
about these type of keypads and how one can interface them with
microControllers?

Thanks,

-Chinmay

You can figure this out with an ohmmeter and a bit of patience. The
buttons close little switches. Each row is connected to one pin, and each
column to another. Often, the bottom buttons have their own pins for some
reason.

Thus, plug it into a solderless breadboard, and start trying to find sets
of pins that are 0 resistance when a button is pushed. When you figure one
out, write it down, move only one wire, and find the button that makes it
low resistance, etc.

Once you have all the buttons figured out, you can set one of the rows and
scan the columns one at a time to figure out if a button is pressed. You

http://www.elecdesign.com/Articles/ArticleID/6303/6303.html

C

Chris

Jan 1, 1970
0
Chinmay said:
Hi,

I was just given a 4x3 Matrix Keypad for a project. It did not come
with a data sheet. The wierd this is that it has 10 output pins.

I had expected 7 or 13. But 10 is an wierd number. Any of you know
about these type of keypads and how one can interface them with
microControllers?

Thanks,

-Chinmay

Hi, Chinmay. I would guess you've got a ribbon cable coming from your
matrix keypad, terminating with an IDC connector. If that's the case,
you've got 10 lines simply because that's the smallest practical IDC
connector. It's not weird -- three of the lines are just there for
form.

Take the advice of Mr. Monsen and tease out the pinout using an
ohmmeter. It's not the elegant solution, but there are many times when
"just find out" is the fastest way to get where you want to go. And
no, there isn't a standard matrix keypad pinout -- they vary all over
the place.

Once you get to that point, you've asked a classic newbie question --
"How can I interface a matrix keypad with a microcontroller?" The
answer depends on the type of uC you have.

In days of yore, microcontrollers had byte- or nybble-wide ports, which
were programmable as either all inputs or all outputs. If you had one
of those (or you wanted to do this with standard I/O port logic) you
would do something like this (view in fixed font or M\$ Notepad):

 Old Tyme Matrix Keypad Interface 2 X 3

 .------------o-----------.
| | |
 | 1 | 2 | 3
| T | T | T
 D | --- | --- | ---
Ao-->|----o--o o--. o--o o--. '--o o--.
 | | |
| | |
 .-------|----o-------|---. |
| | | | | |
 | 4 | | 5 | | 6 |
| T | | T | | T |
 D | --- | | --- | | --- |
Bo-->|----o--o o--o o--o o--o '--o o--o
 | | |
| | |
 Co----------------o | |
| | |
 | | |
Do-----------------------------o |
 | | |
| | |
 Eo-----------------------------------------o
| | |
 .-. .-. .-.
R | | R | | R | |
 | | | | | |
'-' '-' '-'
 | | |
=== === ===
 GND GND GND
created by Andy´s ASCII-Circuit v1.24.140803 Beta www.tech-chat.de

For a 2 X 3 matrix (you can make this arbitrarily large -- I've made a
small one here due to space constraints) you have two rows and three
columns. The left side of the switches are the rows and the right side
the columns. A and B are uC output pins, and C, D, and E are input
pins. Initially, keep A and B low. To read the first row, make A high
and B low. Read C, D, and E. This will give you the status of
switches 1, 2, and 3. Then make B high and A low. Read C, D and E to
get the status of switches 4, 5, and 6.

(If you were using TTL logic in days of yore, you would make the
resistors pullup instead of pulldown, and reverse the diodes. A and B
would be normally high instead of normally low. You would then read a
logic "0" for an actice switch rather than a logic "1".)

Fast forward from those thrilling byte/nybble programmable port days of
yesteryear to more recent times, where each individual pin is
programmable as input or output on the fly. When a uC pin is an input,
it is effectively removed from the circuit, acting like a tri-state
output (or like a reverse biased 1N914 diode in the circuit above).
You can then just replace the diodes with software (always a good trade
-- software is free) like this:

Bit Selectable Tristate Matrix Keypad Interface

 .------------o-----------.
| | |
 | 1 | 2 | 3
| T | T | T
 | --- | --- | ---
Ao--------o--o o--. o--o o--. '--o o--.
 | | |
| | |
 .-------|----o-------|---. |
| | | | | |
 | 4 | | 5 | | 6 |
| T | | T | | T |
 | --- | | --- | | --- |
Bo--------o--o o--o o--o o--o '--o o--o
 | | |
| | |
 Co----------------o | |
| | |
 | | |
Do-----------------------------o |
 | | |
| | |
 Eo-----------------------------------------o
| | |
 .-. .-. .-.
R | | R | | R | |
 | | | | | |
'-' '-' '-'
 | | |
=== === ===
 GND GND GND
created by Andy´s ASCII-Circuit v1.24.140803 Beta www.tech-chat.de

Now, in order to read the keypad, you normally have A - E as inputs.
You then program A as an output bit, output a logic 1, and read C thru
E. This gives you the status of SW 1-3. You then program A as input,
and B as output, output a logic 1 on B, and read C-E to get status of
switches 4-6. You are using the bit-programmable Input/output select
to replace the diodes. Neat.

Of course, there is another improvement in more recent
microcontrollers. Many now have pin-programmable weak pulldown
resistors. This allows you to dispose of the external resistors
entirely, like this:

Bit Selectable Tristate Matrix Keypad Interface
 with Internal Pulldowns
.------------o-----------.
 | | |
| 1 | 2 | 3
 | T | T | T
| --- | --- | ---
 Ao--------o--o o--. o--o o--. '--o o--.
| | |
 | | |
.-------|----o-------|---. |
 | | | | | |
| 4 | | 5 | | 6 |
 | T | | T | | T |
| --- | | --- | | --- |
 Bo--------o--o o--o o--o o--o '--o o--o
| | |
 | | |
Co----------------' | |
 | |
| |
 Do-----------------------------' |
|
 |
Eo-----------------------------------------'
created by Andy´s ASCII-Circuit v1.24.140803 Beta www.tech-chat.de

Programming is accomplished the same way as above, except you
initialize the pins C-E with the weak pulldown resistors.

This scheme works well for any size keypad matrix, if you have enough
I/O pins. Actually, you've got one right under your fingers now. The
keyboard you're using right now almost certainly has the same setup --
a dedicated keyboard microcontroller reading a switch matrix and
communicating with your computer, either through the keyboard port or
USB.

If your microcontroller has 7 spare pins you can dedicate to your 4 X 3
matrix keypad, you're home free. If you don't have enough I/O (a
common problem -- feature creep always uses up existing I/O in the real
world), post again and describe your problem in more detail. Usually a
combination of hardware tricks and crafty software can solve the
problem. Mr. Monsen's link is one of the more creative possible
solutions if you are out of pins.

Please be aware that, in the real world, you would also have to make
some provision for ESD protection to protect the I/O pins of your
microcontroller. But this should be enough to get you through your
project.

Good luck
Chris

J

Jasen Betts

Jan 1, 1970
0
Hi,

I was just given a 4x3 Matrix Keypad for a project. It did not come
with a data sheet. The wierd this is that it has 10 output pins.

I had expected 7 or 13. But 10 is an wierd number. Any of you know
about these type of keypads and how one can interface them with
microControllers?

it has 10 "outputs" to simplify the internal wiring of the unit.

it's probably wired in rows and columns with some of the rows (or columns)
split across two pins.

it'd take only a few minutes with a continutiy tester to figure out the
wiring of it. less if it's easily dissasembled or passes sunlight.

Bye.
Jasen

Replies
10
Views
2K
C
Replies
2
Views
948