Hardware Reference
In-Depth Information
Figure 9.9 Typical 4 4 matrix keypad interface
CMP
AL, BL
; Has it changed?
JNE
NZ, readsw ; Yes, so try again.
RET
; No, so return with bit set in AL
switch: IN
AL, porta ; Get value from Port A
AND
AL, mask
; and check appropriate bit.
RET
; Go back ...
swdelay: PUSH AX
; preserve the set bit
MOV
CX, 0800H ; and delay for a while.
sloop
LOOP sloop
POP
AX
RET
Keypads
Keypads in process control applications vary from simple arrangements of
dedicated push-button switches to arrangements of 16-keys (either coded or
unencoded) in a standard 4 4 matrix. Keycaps may be engraved or fitted with
suitable legends. Keypads sealed to 1P65 are available as similar units with
individually illuminated keys.
Unencoded keypads are invariably interfaced using row and column lines
to enable scanning of the keyboard. This arrangement is less demanding in
terms of I/O lines than would be the case if the keypad contacts were treated
as individual switches. A typical 16-key keypad arranged on a 4 4 matrix
would make use of 12 digital I/O lines though it is possible to use just eight
lines of a single port by alternately configuring the port for input and output.
A representative arrangement is shown in Figure 9.9.
Unencoded keypads are generally preferred in high-volume applications
where the cost of interfacing hardware has to be balanced at the expense of
the extra overhead required by the software involved with scanning the key-
board, detecting, and decoding a keypress. In low-volume applications, and
Search WWH ::




Custom Search