piclist 1998\12\23\142630a >
Thread: another post - related to DTMF/tone decoders
www.piclist.com/techref/pots/dtmf.htm?key=dtmf
BY : John Payson email (remove spam text)

> Hi,
> theoretically, there is another interesting approach:
> one can build a Fourier spectrum analyser and then evaluate the power
> spectra. In the Embedded Controller Handbook (AN's) there is one example
> for 17C42. Such way, both dual-tone and single-tone can be reliable
> detected... I did not tried it but maybe I will do it in the future...
> Imre

|I would recommend against this method for two reasons:

|1) FFT computation in real time for a pic sampling signals at a rate up to
|3 or 4kHz is (extremely) difficult.

|2) One of the 'problems' with FFT's is that the frequency bins are evenly
|spaced. However, for DTMF signals they're logarithmically spaced. Ideally,
|you'd like the FFT bins to lie directly on top of the DTMF frequencies.

Using a pair of DFT's (discrete Fourier transform) it is possible
to look for a the existence of any single frequency in a signal
which may also contain other stuff.  Performing /N/ DFT's will
take /N/ times as long as performing one, but if you only need a
few, that's not a problem.

An FFT is primarily useful in cases where you want to decompose
a "sample" [e.g. 256 A/D readings taken at an 8192Hz rate] of a
signal into "all" its constituent frequencies; the result of the
FFT will be equivalent to the result of running a pair of DFT's
on every frequency which divides into the sample length.  The FFT
will be much faster than running all the DFT's individually, but
will take much longer than running a small handful of DFT's.

Note that when running DFT computations, you may (and almost
certainly should) perform the multiply-accumulate-sum operations
on the fly.  Beyond that, there are some gotchas to be aware of:

[1] Multiplies on anything short of a 17Cxx part are going to be
expensive.  Rather than using a sinewave as the integrating
waveform, you may use a simpler step wave.  My favorite wave-
form for this purpose is 1/3 period at +1, 1/6 at zero, 1/3
at -1, and 1/6 at zero.  This waveform has no harmonic content
at multiples of 2 or 3, and its harmonic content drops prop-
ortional to frequency (the first non-zero harmonic is the fifth
harmonic at 1/5 strength).

[2] Another way to simplify your life is to use a zero-crossing
detector rather than an A/D.  I've done a DTMF defector using
just the 16C622's comparator and it worked decently.  Using an
ADC input is better, but it's more expensive and requires more
math.

[3] Rather than running DFT's on chunks of, e.g. 1/32 of a second
and having them independent, it's better to use sliding-window
filtering and averaging techniques to combine them.  This is
especially important if the frequency is not a multiple of the
sample-group length.

|You may wish to look at Analog Devices' DSP apnotes. They discuss this
|more thoroughly. Their solution is to compute 16 DFT's: 8 at the DTMF
|tones and 8 at the 2nd harmonic of DTMF tones. The second set presumably
|allows one to ascertain whether a 'pure' DTMF tone was present or whether
|the DTMF energy is a harmonic of some lower frequency present signal. On
|comp.dsp I have read that people have found this technique to be flawed.
|But I haven't tried it my self (at least not as described here).

A better approach (which I've done on a DSP--it'd be beyond the
abilities of a PIC) is to have two detectors at each frequency,
one of which is more discriminating than the other.  Then require
that the more discriminating detector pickup be at least a certain
fraction of the less detecting one.  This results in negative sen-
sitivity near the frequency of interest, but a very narrow spike in
sensitivity at the desired frequency.  Since more discriminating
filters have slower response times, it's necessary to slow down
the response of the less discriminating filter to match.  Using
these techniques, though, can produce outstanding DTMF detection
and false-tone rejection.

<01BE2E77.5AE537F0@JOHN_WKST1>