Sticky Notes

This blog is officially closed. Do check out the new blog at http://www.utmrobocon.com

Sunday, March 6, 2011

Matrix Keypad

      Matrices is actually a way of interfacing that is commonly used to interface input such as keyboard and also interface output like LED. Matrix keypad applying the concept of matrices to interface multiple input with limited pin count. Imagine the matrices connection for keypad as figure below.

 The circuit has a 4 x 4 = 16 button that connect any two lines at the intersection point @node once it is pressed. In order to detect which button is pressed, for example, you pressed button[1,1] ,you set pin A as output High, and set pin 1 as input, and you will readily detect the the high at pin 1 which indicate that button one is pressed.

Consequently, you can produce a scanning function, that changes any output pin high at a time, and detect one input pin at a time. This scanning function can be perform routinely to scan whether a button is pressed.


Multiple Pressed Detection
      Lets imagine there is three button pressed. The three button is respectively button node (2,B), node (3,B), and node (4,B). So the scanning can be done by applying logic high at output B, and then input 2, 3 and 4 will detect a logic high, thus the button pressed is known.

      Lets imagine again, three more button is pressed, but this time, node (2,B), node (2,C) and node (2,D). The scanning can be done by setting pin 2 as output, and applying logic high at pin 2, with pin B, C and D as input, you will readily detect the three button is pressed.

      But there is a problem with this kind of scanning. This effect is also commonly known as ghosting.

      Let say 4 button is pressed, respectively is node (2,B), node (2,C), node (3,B) and node (3,D). If you apply the scanning method as mention before, you will be able to detect there is four button pressed. But if you leave any button among the four, you will notice that you still detect four button pressed !
This is because all the button that are pressed connect all the lines and row that are connected, thus as long as any one of the row is high, the row or column will also be high.

To overcome this problem, adding extra circuitry will solve the problem easily. By adding an diode in series with all the button side by side is said to solve the problem well enough.
So when the button is released, the diode block the current flow due to reverse bias of the p-n junction inside the diode, thus only button of the specific row is detected.

Using voltage ladder to read button input : Keypad using ADC method
ADC for short stand for Analog-Digital-Converter. To detect button pressed, you can also utilize ADC peripheral which is commonly available in microcontroller. The advantages of using this kind of configuration is that it only use up 1 pin, with condition that pin from the particular microcontroller must support ADC peripheral. This configuration can also be used to detect multiple pressed, but with appropriate value for each resistor. The circuit is shown as below.
But this kind of configuration is nasty as the all the value of the resistor must be different so that every single button pressed will give unique voltage to the microcontroller.
To make life easier, you can also form a 'REAL' resistor ladder.


The connection is as the figure on the left. By this way you can have same value for all resistor and also add as much segment as you like, but be sure not to add too much resistor and 'starve' your microcontroller. The only weakness with this kind of connection is you can only have one button pressed on a time.

So, what are you waiting for, if you want to try one of those method why not go prepare the hardware now after reading such a looooong article. Stay tuned for more updates.


For more information, please visit the link below.
Most of the picture above are also taken from the website below.
http://pcbheaven.com/wikipages/How_Key_Matrices_Works/
You might also find this site informative.
http://www.avr-asm-tutorial.net/avr_en/keypad/keyboard.html



Inspiring Creative and Innovative Minds

Chai Jun Kong
Faculty of Electrical Engineering
Universiti Teknologi Malaysia

No comments:

Related Posts Plugin for WordPress, Blogger...