Basic Circuit Eliminates Numeric Keypad Polling
STMicroelectronics » STM32F100
Rick Malley, Independent Designs LLC
Using eight digital inputs, this circuit simplifies decoding of the common membrane 4×4 keypad matrix and eliminates the traditional requirement of scanning rows or columns. Any X-Y switch matrix, which can be part of some apparatus, can be considered with this device.
The design uses eight pre-biased transistors – four NPN and four PNP. When depressing a given switch, two transistors will turn on via the current through their internal biasing networks, providing a unique signature code that can be recognized and decoded. The generated code, which will be unique for each key, is readable with a simple 8-bit input statement. By enabling a pin-change interrupt on all eight inputs, the keyboard decode program can be entirely interrupt-driven.
The eight lines could also be connected to a shift register, thereby only requiring two to three digital I/O lines for the microprocessor to shift out and read the result.
In the simplest setup, an 8-bit port is configured as inputs, with internal pull-up resistors on bits 0-3 and internal pull-down resistors on bits 4-7 (Figure 1). This is possible with several microprocessors, including STMicroelectronics’ STM32F100. In fact, this circuit was prototyped with the STM32F100, and wound up delivering excellent results.
The design in Figure 2 employs external pull-up and pull-down resistors. The best solution implements two resistor arrays, such as the widely available four-element surface-mount types – they’re compact, inexpensive, and add only two components to the circuit board. For most pull-up and pull-down applications, 10 kΩ will suffice.
Of course, several combinations are possible when simultaneously pressing two keys, also leading to the generation of unique codes. This scenario works as well – any combination in which the two keys don’t share a common row or column can be decoded.
News on theme: