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 on the diagram below is a 4x4 binary keypad. If this was a matrix keypad, connecting it to your TiOS system would require 8 I/O lines: 4 scan lines and 4 return lines. Being of the binary type, this keypad only needs 5 return lines to interface to your TiOS system.


You will, of course, immediately ask: why is it necessary to have 5 return lines when 4 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".