Hardware Reference
In-Depth Information
the Q voltage is high. When pressed, the key moves toward the reset position.
When the key touches the reset position, the Q voltage will go low. When the key
is bouncing and touching neither the set nor the reset input, both set and reset
inputs are pulled low by the pull-down resistors. Since both set and reset are low,
the Q voltage will remain low and the key will be recognized as pressed.
Noninverting CMOS buffer with high input impedance. The CMOS buffer
output is identical to its input. When the switch is pressed, the input of the buffer
chip 4050 is grounded and hence V OUT is forced to low. When the key switch is
bouncing (not touching the input), the resistor R keeps the output voltage low. This
is due to the high input impedance of 4050, which causes a negligible voltage drop
on the feedback resistor. Thus the output is debounced. This solution is shown in
Figure 7.33b.
Integrated debouncers. The RC constant of the integrator determines the rate
at which the capacitor charges up toward the supply voltage once the ground
connection via the switch has been removed. As long as the capacitor voltage
does not exceed the logic 0 threshold value, the V OUT signal will continue to be
recognized as a logic 0. This solution is shown in Figure 7.33c.
S OFTWARE D EBOUNCING T ECHNIQUES
A simple software debouncing method is wait and see; that is, wait for 10 ms and reexam-
ine the same key to see if it is still pressed. A key is considered pressed if its output voltage is
still low 10 ms after it is detected low. If the output voltage is high, the program will consider
the signal as noise or the key as still bouncing. In either case, the program will continue to per-
form the scanning. For most applications, this simple wait-and-see method is adequate.
7.9.3 ASCII Code Lookup
For an application that needs a keyboard, the easiest way to find out the ASCII code of the pressed
key is to perform a table lookup. However, table lookup is not necessary for the keypad because
ASCII code lookup can be embedded in the program that performs the scanning and debouncing.
Example 7.7
Write a program to perform keypad scanning and debouncing and return the ASCII code of
the pressed key to the caller.
Solution: To implement keypad scanning, debouncing, and ASCII code lookup requires the use
of four local variables.
maskr. the mask to select a row to be scanned
maskc. the mask to select a column to be scanned
column. the column (0 to 3) being scanned
row. the row (0 to 3) being scanned
The following assembly routine will perform scanning and debouncing and return the
ASCII code of the pressed key in accumulator A to the caller:
keypad
equ
PTA
maskr
equ
0
; the mask to scan a row
maskc
equ
1
; the mask to scan a column
 
Search WWH ::




Custom Search