• Channels
Part Inventory
Go
 
powered by:

 
  • Quick Poll
What Social Networking site do you use the most?



VOTE VIEW RESULTS
Previous Polls

Premium Content

New Signal Chain Technical Papers from Texas Instruments:

 

 

 

Use a tiny microcontroller with a large keypad


Contributing Author

September 02, 1997

Print
Reprints Comment Subscribe

Like a student needing just one more night to prepare for a coming exam, a microcontroller designer often wishes for just one more I/O line as a project approaches its final stages. Even for the relatively capable 8X752 microcontroller at 28 pins, with its high processing power, direct connection of a 5 × 5 keypad would steal 10 I/O lines from a total of 21 lines, or would require a special interface.

For a small, low-cost 16-pin microcontroller like SGS-Thomson’s ST6201/2, with only 9 I/O lines, the prospect of using any keypad isn’t a glamorous one. Fortunately, the microcontroller designers have included an 8-bit analog-to-digital converter (ADC) into this microcontroller. The ADC may not be completely suitable to monitor high-resolution sensors, but it can be an excellent resource for scanning a keypad of theoretically up to 256 keys. Without being too ambitious, I will describe a connection for a 16-key keypad. Having 16 keys makes the design (hardware and software) much simpler, but the following guidelines also will work for a larger number of keys.

The 4 × 4 keypad shown is a typical layout, except that the rows and columns are separated by resistors (see the figure). The resistance between point A and ground—R(n)—depends on which key (n) is pressed: 0 Ω if the first key is pressed, 0.5 kΩ if the second is pressed, and so on with steps equal to 0.5 kΩ, up to 7.5 kΩ if the 16th key is pressed. R(n) = (n − 1) × 0.5 kΩ. The current source will excite the resistor network and the resulting voltage drop will be measured by the ADC. For a 0-5 V analog-to-digital range, a current source slightly higher than 2.5 V/7.5 kΩ = 0.33 mA is suggested. For instance, the value 0.34 mA fits the bill; it will offset the voltage drop, excluding jumps of 2 LSBs due to possible analog-to-digital conversion noise. Also notice that only half of the maximum input range is used. This makes it possible to:

  1. Get a 17th condition: No key is pressed when the ADC data equals 0xFF.
  2. Get the pressed key’s number by shifting the analog-to-digital conversion data three bits to the right (or division by 8).

The larger the keypad, the more attention you must pay to the resistor values and tolerances, ADC noise, and the accuracy of the current-source setting. In addition, if the result of the 256 divide by keys’ number isn’t power of 2, your software will be a little more complicated. Another approach might be just to use the second analog input for an additional 16 keys.

Average (0 Ratings):

Subscribe
Subscribe to Electronic Design and start receiving more articles like this one
Filed Under:

Check for price and availability on Source ESB:

Go
powered by  
  • Scott Humphreys
    1 year ago
    Jan 20, 2011

    It appears all of the bottom row switches will produce zero volts at the ADC input. This is obvious for switch 13, but unless there is a current sourced out of the ADC input, switches 1, 5 and 9 will present ground and no current flow through (and no voltage across) the 2k resistors. Additional resistors are needed in the bottom row.

You must log on before posting a comment.

Are you a new visitor? Register Here
Acceptable Use Policy

Sponsored Links