Connecting Binary Keypads

Binary keypads (we will use this short name to describe "keypads that output binary key codes") do not require scanning — they contain a (typically microcontroller-based) circuit that performs the scanning and outputs encoded binary codes of pressed keys. Such keypads are sometimes called "encoded keypads."

Shown in the diagram below is a 4x4 binary keypad. If this was a matrix keypad, connecting it to your TiOS system would require eight I/O lines: four scan lines and four return lines. Being of the binary type, this keypad only needs five return lines to interface to your TiOS system.

A wiring diagram of an "encoded" keypad.

You will, of course, immediately ask: why is it necessary to have five return lines when four would appear to be enough? Indeed, there are 16 keys, so you will need key codes &h0~&hF and these fit in 4 bits of data, right? Wrong! You need one extra code to indicate that no key is pressed, so for a keypad of 16 keys you will need 17 codes. A binary keypad always outputs some code, even if all its keys are released.

A dedicated setting — kp.idlecode — defines the code that your TiOS system should expect for the no-key-pressed situation. For example, you can set kp.idlecode = &h1F, which means that when all keys are released, your binary keypad is supposed to output "all 1s."