Basic Circuit Eliminates Numeric Keypad Polling

STMicroelectronics STM32F100

Rick Malley, Independent Designs LLC

Electronic Design

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.

Basic Circuit Eliminates Numeric Keypad Polling
Figure 1. To simplify decoding of a 4×4 keypad matrix, an 8-bit port was configured
as inputs using internal pull-up and pull-down resistors the microprocessor.

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.

Basic Circuit Eliminates Numeric Keypad Polling
Figure 2. This alternate to Figure 1 uses external pull-up and pull-down resistor arrays.

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.

electronicdesign.com

You may have to register before you can post comments and get full access to forum.
Fragments of discussion:Full version of discussion »
  • This scheme has known. Write code is not a difficult task.
EMS supplier