One-Pin Keypad Features Low Component Count

May 26, 2003
Building on the recent Design Brief theme of one-pin keypads, this design uses only one analog microcontroller (MCU) input to scan numerous keys, plus one resistor per key and another resistor and capacitor. The circuit is simply a crude...

Building on the recent Design Brief theme of one-pin keypads, this design uses only one analog microcontroller (MCU) input to scan numerous keys, plus one resistor per key and another resistor and capacitor. The circuit is simply a crude digital-to-analog converter. The MCU reads the analog voltage and quickly computes which key is pressed.

The figure shows the circuit's layout. When a key is pressed, a voltage divider is created and the signal KEY drops from VCC to a lower voltage. The capacitor suppresses noise. The MCU scans the KEY signal periodically—every 10 to 50 ms—and qualifies the key press when the voltage drops below VCC. Using VCC as the analog-to-digital converter's (ADC's) reference ensures that drift and regulator tolerance won't affect system operation.

To compute the resistor values, first choose the pull-up resistor. In this example, R1 = 10 kÙ. Some ADC inputs require lower input impedances for the rated conversion speed. But to save power, you can get away with higher values at low conversion speeds.

Next, note that the divider network must slice the MCU's ADC digital range into equal-sized bins. If B is the bin size, N represents the number of bits in the ADC, and K the number of keys scanned:

B = 2N/K

For a 10-bit converter scanning eight keys, B = 1024/8 = 128 counts per bin. The edges of the bins are simply multiples of this number.

To compute the target "key-pressed" value in the middle of each bin for each key, k (starting at k = 0), we have:

Xk = kB + B/2

For the 10-bit example, the threshold for the first bin is 64, for the second bin 64 + 128 = 192, and so on.

The value of the resistor attached to each switch is then:

R = (Xk R1)/(2N − Xk)

So the first bin's resistor is 667 Ù, the second is 2308 Ù, etc. The closest 5% values are shown in the figure.

The resistor tolerance must be chosen according to the number of keys and bins. With eight keys, the bins are 1/8 = 12.5% wide. By carefully selecting the values, ±5% resistors may be used while keeping each key's voltage within its bin. For 16 or more keys, the bin size is 6.25%, and you will need 1% resistors to ensure that each key's voltage stays within its bin.

This technique really suits low-power systems because the keypad draws zero power until a key is pressed. If the MCU's analog input can be configured for wake-on-pin-change, then the MCU can go to sleep until a key is pressed.

Sponsored Recommendations

Near- and Far-Field Measurements

April 16, 2024
In this comprehensive application note, we delve into the methods of measuring the transmission (or reception) pattern, a key determinant of antenna gain, using a vector network...

DigiKey Factory Tomorrow Season 3: Sustainable Manufacturing

April 16, 2024
Industry 4.0 is helping manufacturers develop and integrate technologies such as AI, edge computing and connectivity for the factories of tomorrow. Learn more at DigiKey today...

Connectivity – The Backbone of Sustainable Automation

April 16, 2024
Advanced interfaces for signals, data, and electrical power are essential. They help save resources and costs when networking production equipment.

Empowered by Cutting-Edge Automation Technology: The Sustainable Journey

April 16, 2024
Advanced automation is key to efficient production and is a powerful tool for optimizing infrastructure and processes in terms of sustainability.

Comments

To join the conversation, and become an exclusive member of Electronic Design, create an account today!