From: "Roger Hamlett"
Subject: Re: Keypad keys per IO pin
X-Newsreader: Microsoft Outlook Express 5.50.4807.1700
X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4807.1700
Date: Mon, 13 Jan 2003 22:38:34 -0000
NNTP-Posting-Date: Mon, 13 Jan 2003 22:49:30 GMT
Organization: ntl Cablemodem News Service
"Jonathan Kirwan" wrote in message
> On Mon, 13 Jan 2003 23:27:23 +1100, "Michael Culley"
> >If I have 16 keys of a keypad attached to a processor I can do it by
> >attaching 5v or gnd to one side of each key and using 16 io pins. I can
> >reduce this to 8 io pins easy enough by putting the keys in a matrix. Is
> >there any way this can be reduced further without using another chip? I
> >don't really need to do this, just curious really and thought it might be
> >interesting topic.
> Since it's just academic, in a sense, if you can guarantee that
> only one switch will be ON at once (or, at least, that certain
> patterns are disallowed) then it can be reduced without the
> addition or even use of diodes or external parts -- to 7 pins
> (15 keys only need 6 pins.) Use a mathematical simplex topology
> and scanning which yields up to (N^2+N)/2 keys given N pins.
You can also go 'silly' on the software. If you use four lines to drive four
keys in a row, and connect the output of these to a single line, which has a
small capacitor to GND, you can then 'charge' the capacitor to one rail, by
switching the line on this pin to be an output. You can then switch it to be
an input, and pulse the four lines one at a time the other way, and see if
the rail discharges. You can then charge the input rail to the other supply,
and use the same four scan lines to test another four keys, by pulsing in
the other direction. This can be repeated with two input lines, again
re-using the same four output lines, to allow 16 keys to be tested, using
just six pins. The extra parts needed are just two capacitors on the two
input lines (assuming only one key is allowed). However the same system will
allow multiple keys to be checked if there is a diode in series with each
key, with reversed direction to the alternate rows. You can do the same
thing the other way 'round', by using four input lines, and two output
lines. You 'gain' two test states, by using the fact that since you no
longer have 'pull up' resistors, but instead the small capacitors, you can
test for the lines being moved in both directions instead of just one.