Data Sheet
MEDIAN AND AVERAGING FILTERS
As explained in the Touch Screen Principles section, touch
screens are composed of two resistive layers, normally placed
over an LCD screen. Because these layers are in close proximity
to the LCD screen, noise can be coupled from the screen onto
these resistive layers, causing errors in the touch screen
positional measurements.
The AD7879/AD7889 contain a filtering block to process the
data and discard the spurious noise before sending the
information to the host. The purpose of this block is not only
the suppression of noise; the on-chip filtering also greatly
reduces the host processing loading.
The processing function consists of two filters that are applied
to the converted results: the median filter and the averaging filter.
The median filter suppresses the isolated out of range noise
and sets the number of measurements to be taken. These
measurements are arranged in a temporary array, where the
first value is the smallest measurement and the last value is
the largest measurement. Bit 6 and Bit 5 in Control Register 2
(MED1 and MED0, respectively) set the window of the median
filter and, therefore, the number of measurements taken.
Table 8. Median Filter Size
MED1
MED0
Number of Measurements
0
0
Median filter disabled
0
1
4
1
0
8
1
1
16
The averaging filter size determines the number of values to
average. Bit 8 and Bit 7 in Control Register 2 (AVG1, AVG0)
set the average to 2, 4, 8, or 16 samples. Only the final averaged
result is written into the result register.
Table 9. Averaging Filter Size
AVG1
AVG0
Filter Size
0
0
Average of 2 middle samples
0
1
Average of 4 middle samples
1
0
Average of 8 middle samples
1
1
Average of 16 samples
AD7879/AD7889
When both filter values are 00, only one measurement is
transferred to the register map.
The number specified with the MED1 and MED0 settings must
be greater than or equal to the number specified with the AVG1
and AVG0 settings. If both settings specify the same number,
the median filter is switched off.
Table 10. Median Averaging Filters (MAVF) Settings
Setting Function
M=A
Median filter is disabled; output is the average of
A converted results
M>A
Output is the average of the middle A values from
the array of M measurements
M<A
Not possible because the median filter size is always
larger than the averaging window size
Example
In this example, MED1, MED0 = 11 and AVG1, AVG0 = 10;
the median filter has a window size of 16. This means that 16
measurements are taken and arranged in descending order in a
temporary array.
The averaging window size in this example is 8. The output is
the average of the middle eight values of the 16 measurements
taken with the median filter.
12-BIT SAR
ADC
MEDIAN
FILTER
AVERAGING
FILTER
CONVERTED
RESULTS
6
2
13
4
16
5
15
10
9
3
11
8
1
12
14
7
16 MEASUREMENTS
ARRANGED
AVERAGE OF
MIDDLE 8 VALUES
1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
9
M = 16
8
9
10
10
11
11
12
12
13
13
14
14
15
15
16
16
A=8
Figure 27. Median and Averaging Filter Example
It takes approximately 2 μs to sort the data in the rank filter
(tSORT in Figure 33); tSORT adds to the update rate of the AD7879.
Rev. D | Page 17 of 40