There are several ways to interface keys with a microcontroller to create a HMI. The matrix layout is known to be one of the most port-pin-optimized solutions for interfacing keys to a microcontroller. The maximum number of keys that can be connected through matrix layout is given by
This post proposes a solution for increasing the number of keys to (NC*NR)+NC without affecting the performance of the device. It can be effectively applied to scenarios where more number of keys is required to be applied with limited number of port-pins.
Matrix layout is one of the most efficient ways of interfacing keys to a logic device (it will be referenced as a microcontroller, for the sake of ease, from here onwards). The number of keys that can be connected to a microcontroller with matrix layout is given by the expression NC*NR; where NC is the number of columns and NR is the number of rows. The schematic of matrix layout is shown in figure 1.1.
Proposition of Overloaded Matrix Keyboard: With a little help from hardware and little help from software, it is possible to get another row of keys in the matrix keyboard. The total count now would be (NC*NR)+NC/R where NC/R is the number of columns or rows, whichever is configured as input. For the sake of simplicity, I will assume here that columns are always configured as input and rows as output.
An additional row is added the input of which is +Vcc. Each key is named corresponding to the intersection of row and column. The fourth row is named as ‘HI’ and the corresponding keys are referenced as HIC1, HIC2, HIC3 respectively after the corresponding column. Below flowchart outlines flow that needs to be implement to decode and identify the key-press. The fourth row, which is connected to +Vcc, has the highest priority
3. Software Flow:
It is worthwhile to note the following:
Related but unrelated: