Twowire, fourbyfourkey keyboard interface saves power
You can use a microcontroller that includes an ADC to design a twowireplusground keyboard interface. For example, you can use a resistive voltage divider to identify a pressed key (Reference 1). A microcontroller's integrated ADC typically presents an input resistance on the order of hundreds of kilohms, and, for adequate accuracy, its keypad divider should comprise relatively lowvalue resistors of 10s of kilohms. However, in batterypowered systems, a resistive divider can consume a few hundred microamperes, forcing a designer to choose an alternative classic digitalmatrix array of switches and multiple I/O lines. Moreover, portableequipment designs typically place constraints on the number of components.
To satisfy both requirements, the circuit in Figure 1 uses a matrix keypad and a resistor network divided into two row and column sections. For the fourbyfourkey keypad, seven resistors are sufficient to encode any pressed key, and the circuit consumes power only while a key remains closed. Conversely, with no keys pressed, the standby current approaches zero. Using only two values of resistors, let R_{A}=R_{B}=R_{C}=R_{1} and R_{D}=R_{E}=R_{F}=R_{G}=R_{2}. Assigning values from zero to three for the keys' x and y addresses, you can calculate the voltage across resistor R_{G} for any key closure by solving the following equation:
Driving the resistor array from V_{REF}, the ADC's reference voltage, allows you to perform a ratiometric conversion that eliminates errors in key encoding due to fluctuations in V_{REF}. The following equation describes the voltagedivision ratio, r(x,y), for any keystroke.
The ratio p=R_{1}/R_{2} represents the ratio between row and columngroup resistors' values. For p=4, you calculate 16 values of r(x,y), in the [1/16, 1] range, as a function of the pressed key's position. In general, the minimum difference between r partitioning ratios occurs for the nearest keys as the (3,2) and (3,3) x,y indexes indicate. For an Nbit ADC and a ratio of p=4, the ADC should have a resolution that satisfies the following equation: 2^{–N}^{–1}–16^{–1}=240^{–1}. Note that the reciprocal of 240 (0.0041...) exceeds the reciprocal of 2^{8}, and the circuit thus requires an ADC capable of at least 8bit resolution (N≥8 bits).
Unfortunately, standardvalue components with nominal tolerance, T, cannot provide an ideal solution to this equation. Instead, you calculate a partitioningratio difference, d=r(3,2)–r(3,3), for the worstcase condition. The lowest value of d occurs for a minimum value of R_{G} and R_{D} and the maximum value of R_{A}, R_{B}, R_{C}, R_{E}, and R_{F}. You can account for all the resistors' values and define a generic ratio, p, for the nominal values of R_{1} and R_{2}:
The same value of T applies to all resistors. If n=8 and p=4, the previous equation yields a solution of T&0.018, which indicates that resistors of ±1% tolerance correctly encode 16 keys. Moreover, if you now impose the chosen fixed tolerance, T, you can solve the equation to obtain the required limit on the p ratio between the values of R_{1} and R_{2}. If T=0.01, the solution to the equation becomes p&4.074.
The circuit in Figure 2 uses Freescale's Nitron MC68HC908QT4 microprocessor, which serves as a test bed for a keypad based on the abovecalculated values, and uses powersupply voltage V_{CC} as the resistor matrix's reference voltage, V_{REF}. To satisfy the requirement for p(4.074>p>4), use R_{1}=10 kΩ±1% tolerance and R_{2}=40.2 kΩ±1% tolerance, both standard values that the E48 series offers. Table 1 lists output codes corresponding to 16 individually pressed keys, and Table 2 lists data obtained when simultaneously pressing two keys and illustrates that twokey combinations can evoke special functions.
If your application requires a microcontroller that lacks an internal interrupt that the ADC generates, you can connect an external comparator to the output voltage in Figure 1. Set the comparator's threshold lower than the lowest voltage developed at the output voltage—approximately V_{REF} divided by 16 in the example—and the comparator's output serves as a keypadinterrupt source for the microcontroller.
Note that a microcontroller with a 10bit ADC, such as a Freescale MC68HC908QB or a Texas Instruments MSP430F11 can service a fiverow by sixcolumn keypad matrix encoded by 10 resistors. Repeating the analysis shows that a rowtocolumn p ratio of 5 to 5.51 and a required resistor tolerance of less than 4.3% correctly encode the keys. You can use values of 10 kΩ for R_{1}and 51.1 kΩ or 53.6 kΩ for R_{2} of the ±1%tolerance E48 series.
Reference 

Understanding the basics of setup and hold time
Control an LM317T with a PWM signal
Remembering Jim Williams, 5 years later
Addressing core loss in coupled inductors
AM detector more sensitive than simple diode
Vintage electrical measuring instruments from the 1950s
Simple reversepolarityprotection circuit has no voltage drop
Air pressure sensors in smartphones: Transforming navigation and fitness tracking
Autonomous cars on various terrains
Sensor conditioning amidst a sea of focus on MEMS and sensors
Almost Done
Please confirm the information below before signing in.
{* #socialRegistrationForm *} {* firstName *} {* lastName *} {* displayName *} {* emailAddress *} {* addressCountry *} {* companyName *} {* ednembJobfunction *} {* jobFunctionOther *} {* ednembIndustry *} {* industryOther *}