UPI-41A/41AH/42/42AH USER’S MANUAL
CHAPTER 6
APPLICATIONS
ABSTRACTS
The UPI-41A/41AH/42/42AH is designed to fill a
wide variety of low to medium speed peripheral inter-
face applications where flexibility and easy implementa-
tion are important considerations. The following exam-
ples illustrate some typical applications.
Keyboard Encoder
Figure 6-1 illustrates a keyboard encoder configuration
using the UPI and the 8243 I/O expander to scan a
128-key matrix. The encoder has switch matrix scan-
ning logic, N-key rollover logic, ROM look-up table,
FIFO character buffer, and additional outputs for dis-
play functions, control keys or other special functions.
PORT 1 and PORTs 4 – 7 provide the interface to the
keyboard. PORT 1 lines are set one at a time to select
the various key matrix rows.
When a row is energized all 16 columns (i.e., PORTs
4 – 7 inputs) are sampled to determine if any switch in
the row is closed. The scanning software is code effi-
cient because the UPI instruction set includes individu-
al bit set/clear operations and expander PORTs 4 – 7
can be directly addressed with single, 2-byte instruc-
tions. Also, accumulator bits can be tested in a single
operation. Scan time for 128 keys is about 10 ms. Each
matrix point has a unique binary code which is used to
address ROM when a key closure is detected. Page 3 of
ROM contains a look-up table with useable codes (i.e.,
ASCII, EBCDIC, etc.) which correspond to each key.
When a valid key closure is detected the ROM code
corresponding to that key is stored in a FIFO buffer in
data memory for transfer to the master processor. To
avoid stray noise and switch bounce, a key closure must
be detected on two consecutive scans before it is consid-
ered valid and loaded into the FIFO buffer. The FIFO
buffer allows multiple keys to be processed as they are
depressed without regard to when they are released, a
condition known as N-key rollover.
The basic features of this encoder are fairly standard
and require only about 500 bytes of memory. Since the
UPI is programmable and has additional memory ca-
pacity it can handle a number of other functions. For
example, special keys can be programmed to give an
entry on closing as well as opening. Also, I/O lines are
231318 – 43
Figure 6-1. Keyboard Encoder Configuration
62