Electronic Design

One-Pin Keypad Interface Conserves Battery Power

This idea builds on a previous IFD, "Connect Any Keypad With Any Microcontroller Using Only One Pin" (electronic design, May 1, 1998, p. 126), where a 555 timer connects a keypad switch matrix to a microprocessor. The timer converts a key press to a frequency of 1 for each key, which the processor measures. The great advantage is that only one processor pin is required.

I was in exactly that situation—needing to connect a 4-by-4 switch matrix to a processor, but having only a few I/O pins left. This idea seemed ideal, except that I also needed low power, while the 555 timer always draws current. As that's not really good for battery operation, I modified the circuit (see the figure). Standby power consumption is now only the leakage of a CMOS IC.

A 74HC14 Schmitt inverter forms an oscillator when a key is pressed. U1C's output is fed back to U1A's input and the timing capacitor, C1. The circuit oscillates and a pulse waveform is output. Resistor networks, SIL1and SIL2, plus C1 set the timing of the pulses. Unfortunately, switching thresholds of a CMOS inverter don't have the same stability as a 555 timer. So using the resistors to select one of 16 frequencies might prove not stable enough with time—and especially temperature.

To overcome this problem, current steering diodes D1 to D10 were added. Now resistor networks SIL1 and SIL2 determine the mark and space output times, respectively. The mark and space have only four different times now, so small variations due to temperature won't cause misreading of a key. In the key matrix, the mark time gives the column, and the space time gives the row. A processor measures these times and uses simple threshold/lookup code to decode them and determine the key pressed. Observation of the output waveform on a scope revealed negligible interaction between a key's row and the mark (column) time, and the column and the space (row) time.

When no key is pressed, the feedback loop is broken and R1 pulls U1A's input to 0 V. Now all inverters have inputs and outputs at 0 V or VCC. So current drain reduces to the very low leakage of the 74HC14 package. This is ideal for battery operation because the circuit is normally off. But oscillation starts immediately when a key is pressed. If the input to the processor is interrupt driven, the processor can remain in sleep mode without even polling the keypad to see if a key is pressed.

Diodes D11 and D12 provide some temperature compensation in the manner described in the IFD, "A New Stable RC Pulse Generator" (electronic design, Feb. 8, 1999, p. 104). These diodes may be omitted if wide temperature-range operation isn't necessary. E-mail the author for code to interface to a PIC16C877.

ifd winners
Jim Lepkowski, ON Semiconductor, "Dual-Gate Inverter Oscillator Saves Power, Boosts LED Brightness," June 24, 2002.

Ricardo Jimenez, Neftali Salazar, and Mayoral Ulises, Technological Institute of Mexicali, "Two-Chip Digital Thermometer Delivers 0.4°C Accuracy," July 8, 2002.

Submit your own Ideas For Design to:
[email protected]

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish