Idea for different Keyboard Matrix

User avatar
Willy4876

29 May 2020, 05:43

I had an idea for a way to read more keys than is typically possible using a conventional keyboard matrix. I haven't ever seen this done before, but if it has, I would appreciate it if someone could post a link.

In a conventional keyboard matrix the maximum number of keys is determined by the number of pins that are available on the controller that is being used. If a microcontroller like the ATtiny85 is being used then there are 6 General Purpose Input Output (GPIO) pins. If we are going to use the device over PS/2 (it is simpler to implement than USB) then that leaves us with 4 GPIO remaining. Using a typical matrix this would allow only 4 (2 x 2) keys to be read. If 8 were available, then 16 (4 x 4) could be read. If 11 were available, then 30 (5 x 6) could be read etc. But if we use diodes and are willing to make a more complex matrix, then I believe that this can be significantly increased.

Instead of having each pin as only an input or an output, we have each pin change between being an input and an output (and add some diodes). This way we can add a lot more keys to the matrix and still be able to be read them. If this is done, then the number of keys that can be read is n x (n - 1). If we go back to our example of using an ATtiny85, then the 4 free GPIO would allow us to read 12 keys! If we were using a pro micro with its 18 pins then we could read 18 x (18 - 1) = 306 keys instead of the normal 81 with a conventional matrix. This would mean that a $7 pro micro would be able to control just about any keyboard that you want. I also believe that you would be able to have NKRO but I'm not absolutely certain of this.

Looking at the schematic below, if PB0 (IO4) is being driven high then the other 3 GPIO will be able to read if SW1, SW4, or SW7 is pressed. At the same time, the diodes that correspond to SW10, SW11, and SW12 prevent any erroneous changes to the other tree pins. Next PB0 (IO4) is set back to an input and PB1 (IO3) is driven high allowing SW1, SW5, and SW10 to be read.
Spoiler:
ATtiny85 Matrix Idea.PNG
ATtiny85 Matrix Idea.PNG (113.14 KiB) Viewed 2683 times
If you see any reason why this wouldn't work, or any mistake that I've made please point it out. I have not made a design using this principle yet but I'm really excited to experiment with it. The only thing that I can see being an issue is that the the four pins in the matrix might require an external pull-down resistor to prevent any reverse leakage current from the diodes causing pins to be read as high when they should not be.

If anyone on has Altium Designer and wants the project files feel free to PM me and I'll and send them over. Just keep in mind that I didn't bother making footprints or doing any layout so it is just a schematic.

Findecanor

29 May 2020, 06:17

If I understand it correctly, then this is the same as the method called Charlieplexing. It is more commonly used for LED matrices, but has also been used for keyboards. As I understand it, it isn't used because you couldn't get NKRO with Charlieplexing, or at least it wouldn't be possible with a matrix above a certain size.

User avatar
Willy4876

29 May 2020, 07:23

Findecanor wrote: 29 May 2020, 06:17 If I understand it correctly, then this is the same as the method called Charlieplexing. It is more commonly used for LED matrices, but has also been used for keyboards. As I understand it, it isn't used because you couldn't get NKRO with Charlieplexing, or at least it wouldn't be possible with a matrix above a certain size.
Well I guess that there really are no new ideas. Yes that is very similar, just with pull ups instead of pull downs. Thanks for the links they were a nice read.

I think that you could avoid the issue with the microcontroller getting confused by different key combinations as the second article you linked mentioned. By choosing the diode's forward voltages carefully you might be able to have the voltage after a single diode still be considered to be logic high, but have a pair of them in series considered to be logic low. For example, if a diode with a 2.2 V forward drop (some LEDs have forward drops of around this and in a brief search there are at least a few non LEDs) is used with general 5 V logic then a single diode drop will bring it down to 2.8 V which is well above the 2.0 V input high threshold according to this sparkfun page, however, two diode drops would cause the voltage to drop down to 0.6 V which is below the 0.8 V input low voltage. This is definitely inconvenient, however.

Regardless, I don't think that it would be too hard to make a reasonably useful layout even with this limitation. All that would be needed is a carefully optimized matrix, or only use this on smaller scale designs like a macropad.

jkutianski

01 Jun 2020, 18:28


User avatar
Willy4876

02 Jun 2020, 02:09


User avatar
vvp

02 Jun 2020, 16:51

If you interested in the many ways how to scan a keyboard matrix then check:
http://www.openmusiclabs.com/learning/d ... -scanning/

User avatar
Willy4876

02 Jun 2020, 23:16

vvp wrote: 02 Jun 2020, 16:51 If you interested in the many ways how to scan a keyboard matrix then check:
http://www.openmusiclabs.com/learning/d ... -scanning/
I'll check that out. I appreciate it.

Post Reply

Return to “Keyboards”