I want to build a 7 Rows x 15 Columns keyboard from scratch, thus I have started from the theoretical design of the matrix. The classic way should be to assign directly the Rows and Columns to (7+15) I/O of a microcontroller and also connect 7X15 diodes to every each switch in order to prevent the "ghost" effect.
Yet, I redesigned a matrix using multiplexers - demultiplexers as follows:
Just to keep it simple, let's say that I have a 8x4 matrix, the columns connected to a demultiplexer and the rows connected to a multiplexer. That should work with the pseudocode:
for each output of the demux:
for each input of the mux:
check if a individual button has been pressed, else \\
send HIGH due to pull up resistors
Since in every each loop only one switch can be inspected and there is not any physical connection to other switches, I think I could prevent the "ghost effect" without the need for any diode component.
Also, for a 15x7 matrix, instead of using (15+7) pins, I could use a 16:4 demux and a 8:3 mux, thus only 4+3 = 7 pins.
Please, tell me your opinion, or point any flaws of the design.
1 Answer 1
There is still a ghost effect.
Let's say that the user has pressed R4C9, R4C10 and R3C10. When C9 is energized by the demultiplexer, current can flow onto line R4 via R4C9, then line C10 via R4C10, then line R3 via R3C10. The R3 line will be energized. When you energize C9 and check R3, you will see the signal present that means the key is pressed, even though the key is not pressed.
There's no problem with using multiplexers instead of separate I/O pins. It might affect how quickly you can scan all the keys.
-
\$\begingroup\$ Yes, you are absolutely right. Yet, I wonder if connecting all columns to pull down resistors could prevent the ghost effect because any exceed current flow would be drained to Ground instead of recirculating to other rows. Your opinion would be appreciated. \$\endgroup\$user3060854– user30608542019年11月28日 13:14:00 +00:00Commented Nov 28, 2019 at 13:14
-
\$\begingroup\$ @user3060854 the resistor for each line will also pull down the other connected ones \$\endgroup\$Stack Exchange Broke The Law– Stack Exchange Broke The Law2019年11月28日 13:30:02 +00:00Commented Nov 28, 2019 at 13:30
-
\$\begingroup\$ ghost effects are avoided with diodes, not pull down \$\endgroup\$user7082181– user70821812021年05月05日 07:20:32 +00:00Commented May 5, 2021 at 7:20