ST AN431 Application note

INTRODUCTION
AN431
Application note
Using ST6 analog inputs for multiple key decoding
The ST6 on-chip Analog to Digital Converter (ADC) is a useful peripheral integrated into the sili con of the ST6 family members.The flexibility of the I/O port structure allows the multiplexing of up to 13/8 Analog Inputs into the converter in a 28/20 pin device for the ST6210/15 2k ROM and ST6220/25 4k ROM families, enabling full freedom in circuit layout. Many other members of the ST6 family also offer the Analog to Digital converter.
One of the more novel and practical applications of this converter, is to decode a number ofkeys. The technique is to connect the keys by resistive voltage dividers to the converter inputs.An ex­ample of key detection using 10 keys is illustrated in this note.
Using the Analog to Digital converter in this fashion does not require a static current and avoids false key detection.
BASIC CIRCUIT
The basic circuit of the key decoder consists of a pull-up resistor connected to the ST6 Analog to Digital converter input with the first key directly switching to ground. The following keys are then connected in sequenceto the ADCinput through serial resistors.The number of keys which may be detected depends on the tolerance of the resistors used. It can be seen that if more than one key is pressed at the same time, the key detected will be the next key in the chain closest to the ADC input. This also allows the keys in the keyboard to be prioritized.
-
June 2008
Rev 2 1/15
ANALOG KEYBOARD
PRINCIPLE OF OPERATION
The combination of the pull-up resistor, the serial resistors and the pressed key form a resistive voltage divider, generating a different voltage at the ADC input for each key pressed. The serial resistors are selected in order to give an equal distribution of voltage between V
and VSSfor
DD
each switch combination to give the best noise margin between keys. When a key is pressed, the voltage at the ADC input is given by the activated voltage divider.
This analog voltage is converted by the ADC and the digital value is used to determine which switch is closed. Two successive conversions may be madeto avoid the influence of key bounce.
If the top key is pressed, the voltage measured is always zero.For n keys, the resistor values should be selected such that the voltage for the second key from top is V
/n, for the 3rd - 2xVDD/n, for the
DD
Figure 1. Analog Keyboard resistor key matrix
Figure 2. Multiple key press
2/15
Table 1. Key code ranges
Key Nr
10 E5-E6 25
Valid Code
Range
10 24
2 18-1A 22
3 30-33 22
4
5 63-68 20
6 7C-81 22
7 97-9B 21
8 B0-B4 22
9 CA-CD 24
49-4E 21
Distance to
next key
Table 2. Used resistors and Tolerance
ANALOG KEYBOARD
4th - 3xV
/n and for the nth - (n-1)xVDD/n. Re
DD
sistor values from the tolerance set used must be selected to meet this requirement.
The recommended resistor values for a 10-key keyboard with 2% resistors from the E24 series, used with a 10kΩ pull-up resistor, are shown intable 2. If more current can be al lowed, then a 1kΩ resistor can be used in which case the serial resistor values should be divided by 10.
-
-
Resistor
Rp 10000 9800
R1 1100 1078
R2 1300 1274
R3 1800 1764
R4 2400 2352
R5 3300 3234
R6 5100 4998
R7 8200 8036
R8 16000 15680
Active Key R Error Range (LSB) Distance to next Key
S0 0 24
Value ( ) -2% ( )
3/15
ANALOG KEYBOARD
PRACTICAL LIMITATIONS
Theoretically, for an ideal power supply, ADC and resistors, 255 keys could be detected. Practi cally however, it is necessary to take into account potential errors coming from:
- the power supply - the key resistivity - the resistor tolerance - the ADC error The power supply tolerance can normally be neglected providing noise is not present at a fre
quency within or above the frequency range of the RC delay of the resistive divider, as the ADC reference is normally provided by the powersupply of the ST6. For ST6 family members with ex ternal ADC reference voltage inputs, AV
and AVSSmay be used instead of VDDand VSS.
DD
The sensitivity of the key can normally be neglected, as the resistance of the divider is high in comparison to it. If the key resistivity is significant, it should be added to the “serial” pull-down re sistance of the different dividers. The key resistivity variation must also be added to the toler ance of the serial pull-down resistor (see resistor tolerance following).
The resistor tolerance affects the tolerance of the dividers. Two situations must be taken into ac count:
a) minimum value of pull-up combined withmaximum values of pull-down = maximum voltage of the divider at the ADC input.
b) maximum value of the pull-up combined with the minimum values of pull-down = minimum voltage at the ADC input. These two cases give the maximum voltage variation of each divider (see Table 3). The voltage variation ranges of two dividers must not overlap otherwise the key cannot be decoded, even with an ideal converter.
Table 3. Effective Divider Resistors RX
Active
Key
S0
S1
S2
S3
S4
S5
S6
S7
S8
S9
R -2% ( ) R +2% ( )
00
1078 1122
2352 2448
4116 4284
6468 6732
9702 10098
14700 15300
22736 23664
38416 39984
88396 92004
Realistic converters require a margin be­tween the range of variation. In the case of a significant variation in the key resistivity, the maximum resistivity of the key has to be added to the value of the pull-down resistor in case a). For case b) no error needs to be added as the resistivity cannot be less than 0 Ω.
-
-
-
-
-
-
4/15
ANALOG KEYBOARD
The linearity of the ADC converter of the ST6 is normally specified for ⎛2 LSB, therefore a minimum distance of 4 LSB is needed between the edges of the resistance tolerance ranges.For the best re sults, a minimum of 8 LSB should be used (see Table 4).
Table 4. Voltage at the ADC-Input,Converter Results (5V supply)
V (Rxmin-Rpmax) V (Rxmax-Rpmin)
Active Key
V hex. dec. V hex. dec.
S0 0.00 00 0 0.00 00 0
S1 0.48 18 24 0.51 1A 26
S2 0.94 30 48 1.00 33 51
S3 1.44 49 73 1.52 4E 78
S4 1.94 63 99 2.04 68 104
S5 2.44 7C 124 2.54 81 129
S6 2.95 97 151 3.05 9B 155
S7 3.45 B0 176 3.54 B4 180
-
S8 3.95 C9 201 4.02
Table 5. AD-Converter Results
Active Key
S0 0 24 0-0
S1 2 22 18-1A
S2 3 22 30-33
S3 4 21 49-4E
S4 5 20 63-68
S5 5 22 7C-81
S6 5 21 97-9B
S7 4 22 B0-B4
S8 3 24 C9-CD
S9 2 25 E5-E6
R Error Range
(LSB)
Distance to next
Key
CD
Valid Key Range
205
5/15
Loading...
+ 10 hidden pages