Maker Pro
Maker Pro

128 and more input using a PIC16f628

R

roxlu

Hi all,

I'm looking for a way where I can check which of the 128 buttons are
pressed. I don't want to use 'switches' but real buttons, which only
make contact when the user pushes the button. I was thinking about
multiplexing and parallel in -> serial out shift registers.

Any advice?
Greetings
 
M

mmm

roxlu said:
Hi all,

I'm looking for a way where I can check which of the 128 buttons are
pressed. I don't want to use 'switches' but real buttons, which only
make contact when the user pushes the button. I was thinking about
multiplexing and parallel in -> serial out shift registers.

Any advice?
Greetings

something like the mcp23s17 from microchip allow to setup a switch
matrix up to 256 channels and more using SPI
 
J

Jenalee K.

roxlu a écrit :
Hi all,

I'm looking for a way where I can check which of the 128 buttons are
pressed. I don't want to use 'switches' but real buttons, which only
make contact when the user pushes the button. I was thinking about
multiplexing and parallel in -> serial out shift registers.

Any advice?
Greetings

If you will press only one button at a time then you could use a
(precision) resistor string. Every button shorts a different part of
the string and you measure the resistance left. Techniques like these
were used in monophonic analog music synthesizers.

Thanks,
Jenalee K.
 
R

roxlu

something like the mcp23s17 from microchip allow to setup a switch
matrix up to 256 channels and more using SPI

Thanx, but can this also use those push buttons? (how do you call those
?)
 
R

roxlu

Jenalee said:
roxlu a écrit :


If you will press only one button at a time then you could use a
(precision) resistor string. Every button shorts a different part of
the string and you measure the resistance left. Techniques like these
were used in monophonic analog music synthesizers.
Therefore I need a analog input right? And the maximum is very limited,
or not?
 
M

mmm

roxlu said:
Thanx, but can this also use those push buttons? (how do you call those
?)

like every matrix keyboard you must scan continously to check for button
press events.

you should organize the buttons as a 7 x 8 matrix, configure the chip
for 8 (really 7 )outputs and 8 inputs and add pull-up resistors to
inputs and block diodes to the outputs

scan the keyboard lowering an output bit at time for all the ouput
engaged, and check if an ( or more ) inputs go low.

surfing around you shuold be able to find sources that do this kind of
things.
 
J

Jonathan Kirwan

Hi all,

I'm looking for a way where I can check which of the 128 buttons are
pressed. I don't want to use 'switches' but real buttons, which only
make contact when the user pushes the button. I was thinking about
multiplexing and parallel in -> serial out shift registers.

Any advice?
Greetings

This kind of subject has been discussed in this group. You might want
to use google groups and do a search. But to get you started, I'll
quote one of my own replies to one of those threads:
Here's a link to a 4 I/O pin method of reading 12 buttons. Easily
expandable to 16 once you go thru it and understand how it works.
http://www.mikerj.clara.net/keypad.html

The web site incorrectly says that 7 i/o lines are needed when
no external components are added other than the switches. In
the NxM topolgy, that's true. But in the simplex topology, only
6 i/o lines are needed to cover up to 15 switches without
diodes. So the situation isn't quite as bad as postulated.

However, it's interesting for a number of reasons -- when I/O is
tight and lots of diodes are okay -- but also because it's
modeled with binomials:

I/O Binomial Matrix Usable Required
Pins Pattern Columns Switches Diodes

3 1 2 1 3 9 6
4 1 3 3 1 7 28 16
5 1 4 6 4 1 15 75 40

and so on. The number of matrix columns is taken from the sum
of values on each rank, minus 1 (the first value.)

The numbers on each rank of the binomial means something like
this: "How many unique ways can you read <I> zeros back on the
available input lines," where <I> is 0 for the first value, 1
for the second, and so on. For example, on the rank for four
I/O pins, that reads as, "1 way to uniquely read no zeros back
on 3 input lines, 3 ways to uniquely read one zero back on 3
inputs, 3 ways to uniquely read two zeroes back on 3 inputs, and
1 way to uniquely read back three zeroes on 3 inputs." Only the
first one, the one asking about how many ways to read back
nothing at all (always 1 way) isn't useful for making a switch
column, because it's the same as "no key press."

If you arrange the diodes so that you can achieve each of these
patterns, for each possible active line, the number of usable
switches will be the number of I/O lines times the number of
columns.

If N is the number of I/O pins, then:

Columns = [2^(N-1) - 1]
Switches = N*[2^(N-1) - 1]
Diodes = N*[2^(N-2)]

To illustrate an example not shown on that web page, but which
shows how these patterns extend, here's the example for 5 I/O
lines:
-----------x-----x---x-x-x-x-x-x-------------,
---------x-----x---x---x-x-x-x---x---------, |
-------x-----x-----x-x---x-x---x-x-------, | |
-----x-------x-x-x-------x---x-x-x-----, | | |
-----x-x-x-x---------------x-x-x-x---, | | | |
| | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | |
O-O-O-O-O-O-O-O-O-O-O-O-O-O-O---' | | | |
| | | | | | | | | | | | | | | | | | |
O-O-O-O-O-O-O-O-O-O-O-O-O-O-O-----' | | |
| | | | | | | | | | | | | | | | | |
O-O-O-O-O-O-O-O-O-O-O-O-O-O-O-------' | |
| | | | | | | | | | | | | | | | |
O-O-O-O-O-O-O-O-O-O-O-O-O-O-O---------' |
| | | | | | | | | | | | | | | |
O-O-O-O-O-O-O-O-O-O-O-O-O-O-O-----------'

The 'x' values show the diode connections that the particular
column makes.

The ratio of diodes to switches rapidly approaches 1/2. Of
course, only one key press at a time for this scheme and often a
handful of diodes.

Thanks for the site!

Jon
 
J

John Fields

like every matrix keyboard you must scan continously to check for button
press events.

you should organize the buttons as a 7 x 8 matrix, configure the chip
for 8 (really 7 )outputs and 8 inputs and add pull-up resistors to
inputs and block diodes to the outputs

scan the keyboard lowering an output bit at time for all the ouput
engaged, and check if an ( or more ) inputs go low.

---
He wants to scan 128 switches, not 56.

I'd set it up as a 16 X 8 matrix and use use something like an
HC4514 to drive the rows/columns and something like an HC151 to read
the columns/rows.

Total µC I/O's = 7
 
J

John Fields

---
If you were seriously I/O limited you could add an HC595 and get it
down to 4 I/O's. :)
 
R

Rene Tschaggelar

roxlu said:
Hi all,

I'm looking for a way where I can check which of the 128 buttons are
pressed. I don't want to use 'switches' but real buttons, which only
make contact when the user pushes the button. I was thinking about
multiplexing and parallel in -> serial out shift registers.

Any advice?

Yes, have a look at the 74HC597, which are parallel
input latches and serial output shift registers.
They can be cascaded for as many inputs as you like.

Rene
 
M

Michael A. Terrell

roxlu said:
Hi all,

I'm looking for a way where I can check which of the 128 buttons are
pressed. I don't want to use 'switches' but real buttons, which only
make contact when the user pushes the button. I was thinking about
multiplexing and parallel in -> serial out shift registers.

Any advice?
Greetings


If you don't know that pushbuttons are switches, your question should
have been asked at
--
Service to my country? Been there, Done that, and I've got my DD214 to
prove it.
Member of DAV #85.

Michael A. Terrell
Central Florida
 
R

roxlu

I know they are switches but I don't know the 'specific' name of those
types of buttons
 
R

Rich Grise

Therefore I need a analog input right? And the maximum is very limited,
or not?

Don't pay any attention to this person, he/she is a nut. Digital is the
logical choice, pun originally unintended, but I rather like it. ;-)

You make probably an 8 x 16 matrix, like John F. said, and either use
a high-pin-count processor with 8 outputs and 16 inputs, or 16 input and
8 outputs, or use a decoder and a MUX or two or so. :)

If you scan them in firmware, you can do N-key rollover - I did exactly
this with a 64-key keyboard, where each key was a simple contact closure,
i.e. SPST, and I just scanned it. The "brains" was a 6502. :)

Have Fun!
Rich
 
R

Rich Grise

I know they are switches but I don't know the 'specific' name of those
types of buttons

It doesn't really matter - a switch is a switch, electrically. They come
in varoious forms, and yours is SPST - Single-Pole Single-Throw.

As far as the mechanical configuration, you might be thinking of "tact"
switches, which are little teeny tiny things; otherwise just "pusbutton
switch, SPST" is about as close as you're going to get.

Oh, and by the way - in the convention is
to bottom-post.

Good Luck!
Rich
 
M

Michael A. Terrell

roxlu said:
I know they are switches but I don't know the 'specific' name of those
types of buttons


They are momentary normally open pushbutton switches. Like I said
before, this belongs in

--
Service to my country? Been there, Done that, and I've got my DD214 to
prove it.
Member of DAV #85.

Michael A. Terrell
Central Florida
 
R

Rich Grise

.
Some people are telling me its not possible to multiplex serial out
parallel in shift registers.. As I've never used these.. is this true?
Or is it possible?

Well, I'm not sure what you mean by "multiplexing" shift registers. I kind
of envision a matrix of buttons, say 8 rows and 16 columns. You drive the
rows one at a time with something like a 74HC161 and 74HC138. (although,
I hear that this is the 21st century, and someone's inventd a
counter/decoder on one chip, but I don't know which part it is.) For each
count, latch the state of that row of 16 switches^H^H^H^H^H^H^H^Hbuttons
into two cascaded parallel-in serial-out shift registers, clock them out
to whatever's using the information, then scan the next line, and so on.
You might want to give each swi^H^H^Hbutton its own isolation diode as
well, and pullup resistors so the row register inputs don't float.

Then, of course, you'll have to capture the 16 bits from the shift
registers, or maybe use 74HC151 muxes, in which case you just count
through the rows and record the count values when the '151 output goes
low.

Good Luck!
Rich
 
K

Ken Smith

roxlu wrote: [...]
like every matrix keyboard you must scan continously to check for button
press events.

This isn't true. You can pull all the row wires low and watch for any
column lines going low to detect that some key is pressed. Once you know
that there is something to look for, you can then scan the row lines one
at a time.

This allows a simple many input NAND to generate a "keyboard interrupt" to
wake the micro up.
 
Top