Main | Penguins | Projects | Travel | Photos | Publications | SensorWiki

DTMF Decoding using FFT’s

When dialing a telephone number, the signals are transferred over the phone line using either “tone” or “pulse” signals. At this moment, almost all telephones use tone dialing based on DTMF signals. Although one can buy DTMF decoders it was quite challenging to do the decoding in a microcontroller. I Have used the 80C552 experiment board for this purpose since this one has AD-converters for sampling the phone line. This resulted into a working prototype of a telephone number recognition system. The final aim is a one-chip system, which listens to the phone line and writes all the numbers you have dialled to a memory including the length of the call. When reading out this memory once a month using RS232, you can generate your own specified telephone bill without paying to your phone company. This page describes the number recognition system only.

The basic idea here is that when sampling 32 samples with 3500 Hz, some components of the DFT map sufficiently accurate on the eight frequencies of DTMF signals in order to detect the DTMF symbols.

DTMF Signals

Dual Tone Multi-Frequency (DTMF) signals consist of two frequencies. There are sixteen DTMF symbols encoded by selecting one out of four low tones and one out of four high tones. The tones have equal loudness, although the high tone can be up to 4 dB louder than the lower one (a phenomenon referred to as twist).

In the next table the mapping of the telephone symbols onto the DTMF frequencies is summarised.

    1     2     3     A   | 697 Hz
    4     5     6     B   | 770 Hz
    7     8     9     C   | 852 Hz
    *     0     #     D   | 941 Hz
  1209  1336  1477  1633  |
   Hz    Hz    Hz    Hz   |

Implementing DTMF carrier detection in a microcontroller

Assume a sample frequency of 3.5 kHz. The spectrum of the DTMF signal is plotted in the next picture. The blue spectrum is the result of an FFT after 210 samples (sample time of 293 ms). The red line is the result of an FFT after 25 samples (sample time 9.1 ms).

In the red spectrum one can see that the four low frequencies in the DTMF signal can be detected using frequency number 7, 8, 9, and 10 from the FFT. The higher frequencies can be detected using frequency number 12, 13, 15 and 16 from the FFT. Frequency 15 is not exactly on the frequency to be determined, an alternative is to average sample 14 and 15.

Sampling only 25 points (32 samples) has the advantage that the FFT operation is quite small. It is just a matrix multiplication of the 32 samples with a 17×32 matrix resulting into the frequency vector of size 17. Starting with a vector “T” containing 32 samples from the input signal, the spectrum vector “S” can be found from S = M·T with M the FFT matrix. The FFT matrix can be calculated in a program like MathCad with the following three lines which construct the matrix M recursively:

In this case, the spectrum vector “S” has size 17. Note that the matrix entries can be scaled to integers without any problem if we want to implement the operations in a microcontroller. Since we are only interested in the four low frequency and four high frequency components, it is sufficient to reduce matrix M to rows number 7, 8, 9, 10, 12, 13, 15 and 16.

The total number mathematical operations consists of 132 multiplications and 128 additions. In a general 80C51 microcontroller of 12 MHz this will consume less than 6 ms (assuming that both the ADD and MUL operations are surrounded by two ADD operations).

Next, we must detect which two carriers are present. Taking the strongest one from the low and high frequencies appeared to be the best method. Below a certain value, the phone-line is qualified to be silent.

So, the sampling and DTMF decoding together takes 15 ms. This is sufficiently fast to check the pressed phone buttons 10 times per second. A decision must be made whether a button is pressed for the second time or is continuously pressed.

To play with the calculations you can use my MathCad 6.0 worksheet. If you do not have MathCad you can take a look at the PDF file.