 |
Email this Article
Printer-Friendly
Reader Comments
[News Feature]
Power-Saving Keypad Controls Multiple Keys Through One MCU Pin
Mehmet Efe Ozbek
ED Online ID #17755
September, 13 2007
Traditionally, interfacing a
microcontroller with an n-by-m keypad required n +
m of the microcontroller’s
I/O pins for keypad scanning.
Keypad designs that conserve
microcontroller pins have been
developed, but they require additional
resources, such as external
ICs or a built-in analog-to-digital
converter (ADC). The design presented
in this article uses only a
single I/O pin and requires only
resistors and a capacitor as the
external components.
I/O is a bidirectional pin initially
configured as an input
(see the figure). When no key is
pressed, the capacitor is discharged
and the pull-up resistor,
RH, keeps I/O High. The microcontroller
is in sleep mode and
will wake up only when a
change in I/O’s state generates
an interrupt. When a key is
pressed, I/O changes to Low,
since the pull-down network is
stronger than the pull-up. The
microcontroller then wakes up to
execute the following steps:
- Wait for contact debouncing.
- Change I/O to an output and
set it High. The capacitor
then starts charging to the
High-state voltage. The charging
time, Ti, is determined by
the key pressed and its associated
R (1, 2,…i).
- Wait until T1.
- Make I/O an input.
Charging of C pauses.
- If I/O is High, key 1 was
pressed. If I/O is Low, make
I/O an output and set it High
to continue charging.
- Wait until T2.
- Make I/O an input.
Charging of C pauses.
- If I/O is High, key 2 was
pressed. If I/O is Low, make
I/O an output and set it High
to continue charging.
- Continue for T3 through Ti.
Resistors should be chosen to
make T1 < T2 < T3...
Charging time can be determined
as follows: When charging
pauses, the voltage at I/O is
(Equation 1) where VC is the
capacitor voltage (Equation 2).
Equation 3 solves the charging
time by equating VI/O to the
switching threshold voltage VTH.
Here, VTH is the switching threshold
voltage for I/O.
As Ri is increased, Ti initially
increases as well. But, subsequently,
it reaches a maximum
and starts to decrease. This
imposes an upper limit on Ri
and, therefore, on the number of keys that can be connected
to the circuit.
Ti may vary between Ti,min and
Ti,max due to resistor tolerances
and variations in VTH. Consequently,
the values should be
chosen so that Ti,max < Ti+1,min.
Assuming resistors with 5% tolerances
and a maximum VTH variation
of 5%, a maximum of 15
keys can be connected to the circuit
using the following Ri values
(in kΩ): 0.01, 0.27, 0.62, 1.1,
1.8, 2.7, 3.9, 5.6, 8.2, 11, 15,
22, 30, 43, and 68. The number
of keys can be increased if
resistor tolerances are tighter.
This design saves power in
three ways. First, energy of CV2
is dissipated each time a capacitor
is charged to V and discharged.
In this design, charging
stops as soon as I/O goes High
and the capacitor is charged to
about VTH (less than 2 V), rather
than VDD. Second, the capacitor
is charged (and discharged) only
once for each key press. Finally,
after determining which key was
pressed, the microcontroller
enters sleep mode and remains
asleep until the key is released
and the state of I/O changes
back to High. So even when
some of the keys are stuck or
held down, power consumption
is minimized.
|
 |