Reading from a large number of inputs, like this piano keyboard, can be tedious. Even when multiplexing there’s a lot to keep track of. But if you choose the right microcontroller, you may have hardware assistance. Here’s an ATmega640 is using it’s external memory interface to read the key matrix.
You may remember the Open Music Labs article about reading from a shift register using just one pin of a microcontroller. This time around a shift register is still used, but instead of pulling in a long line of parallel inputs, the switches are multiplexed to reduce the number of I/O pins used to read them.
A 74HC573 is used to facilitate the multiplexing. We won’t go into how that part is accomplished; there’s a separate post that explains the process. What’s unique here is that the XMEM peripheral of the AVR microcontroller is used to grab the data. This is intended for external memory chips, but if you get the timing just right, it greatly simplifies reading in a matrix of up to 128 inputs.
Yay, nice work!
I’ve got mine lying around somewhere with a simmilar approach.
An ATMEGA32, two 8 bit registers. The first one as output, the second one as input.
You shift a one through the cleared output register and read all 8 inputs from the other register.
Between the two registers, there is the 8×8 diode/switch matrix (with up to 64 switches as you said).
Not hard, but still took me some time to figure out everything. Too bad, the only thing mine did, was sending the names of pressed buttons via RS232 to a terminal.
Hey, cool work.
I’ve been working on something like this myself. I have an 88key weighted keyboard with 2 switches per key, where the time interval between the 2 switches is used to calculate velocity. I had to do a 12×16 driver, so i did a 16×16 with only 2 outputs (clock and clear) and single input.
Image of bread board
Video of me playing it
Are you working on a complete synthesizer/keyboard?
This is some really quality hacking! Keep your eyes on OpenMusicLab. I can see them blowing sky-high!