User Interface - Keypad Scan, PSoC® Style
AN2034
Author: Dave Van Ess
Associated Project: Yes
Associated Part Family: CY8C20x34, CY8C21x23, CY8C21x34
CY8C23x33, CY8C24x23A, CY8C24x94
CY8C27x43, CY8C29x66
GET FREE SAMPLES HERE
Software Version: PSoC Designer™ 5.0
Associated Application Notes: AN2354
Application Note Abstract
Introduction
An
This application relies on PSoC General Purpose Input Output (GPIO).
Closure of switch [i, j] (column i, row j) enables current flow from row j to column i. This keypad requires only eight connections to the MCU. The 16 diodes can detect multiple key closures. However, because PSoC microcontroller reduces the cost of external components such as
Well known techniques have been developed to detect multiple key presses without diodes. Figure 2 shows the keypad without diodes.
Figure 2. The Keypad you can Afford
Rows and Columns
This application note uses C columns and R rows. Figure
1 shows an example of such a keypad:
Figure 1. 4-Column by 4-Row Keypad
C0 C1 C2 C3
R0 |
|
|
|
[0,0] | [1,0] | [2,0] | [3,0] |
R1 |
|
|
|
[0,1] | [1,1] | [2,1] | [3,1] |
R2
[0,2] [1,2] [2,2] [3,2]
R3
[0,3] [1,3] [2,3] [3,3]
C0 C1 C2 C3
R0
[0,0] [1,0] [2,0] [3,0]
R1
[0,1] [1,1] [2,1] [3,1]
R2
[0,2] [1,2] [2,2] [3,2]
R3
[0,3] [1,3] [2,3] [3,3]
The standard algorithm for reading a keypad is to individually drive each row and sample the status of all columns. Correctly combining all this information enables detection of at least two simultaneous switch closures. The hardware cost is less but there is software overhead required to scan all four rows, read column status, and condense this information into an answer.
To develop a keypad scan that is low in both hardware and software resources, limit its operation to
January 16, 2009 | Document No. | 1 |
[+] Feedback