May
2006, Issue 190
ARM-Based
Modern Answering Machine
Philips
ARM Design Contest 2005 First Prize
DTMF
DEMODULATION
A
DTMF tone consists of two tones sent simultaneously.
The first tone is selected from a group of four low
frequencies. The second tone is selected from a group
of four high frequencies. This gives 16 possible configurations.
The DTMF demodulator uses the Goertzel algorithm. The
difference here is that the algorithm is written in
C and doesn’t use a single line of assembly code. The
implementation of the algorithm itself was borrowed
from an older implementation in the Asterisk Linux-based
PBX.
The
Goertzel algorithm performs a simple discrete Fourier
transform (DFT). The key to the algorithm involves finding
the number of samples required to be accumulated before
running the detection loop. This is the DTMF_NPOINTS
parameter. There are numerous parameters affecting the
selection of this parameter. The larger the value, the
longer it will take to perform the detection and the
narrower the frequency detection. The algorithm performs
its analysis on discrete frequencies (also called “bins”)
that are located at:
where
i is an integer. For the detection to work well, fi
must match the DTMF frequencies as closely as possible;
otherwise, the energy will bleed from one bin into another.
Tests
and simulations have shown that a value of 205 gives
the best result at a sampling rate of 8,000 Hz. A value
of 205 gives a window of samples of 25.6 ms. In order
to prevent the false detection of DTMF tones, the algorithm
looks for two consecutive positive detections in adjacent
windows. This means that the minimum tone duration is
51.2 ms, but it can take a little longer if the tone
was started in the middle of a sampling window. After
the samples are accumulated in the interrupt, the detection
is performed quickly with the Goertzel routine (see
Listing 1). At the end of the routine, the result
variable has a bit set for each filter that has energy
above a preprogrammed threshold. The detection routine
finally checks that there is only a single bit set in
each nibble representing the low and high frequency
groups.
My
algorithm is simple but reliable. Also, the time slice
during which the TAM-TAM expects a DTMF digit is short.