You are on page 1of 3


Dual Tone Multi-Frequency (DTMF) Detection (November 2010)

ngel Snchez Abril & Ral Surez Marn. EPSC, UPC
AbstractThe laboratory session that we are going to talk about is about detecting the frequency of pulsed tones on a phone. For that, we used MATLAB, a very powerful engineering tool. One of its tools, modulus of the FFT (DFT) allows us to detect the frequencies of the tones and then find out which key was pressed. Index Terms Tone, FFT, DFT, DTMF, Hamming.


this document we are going to explain the digital signal processing for this laboratory session. The main objective of this practice is how to work with signals using DFT (efficiently implemented through the FFT algorithm) for carrying out the DTMF detection for detecting the frequency of the two tones of the signaling signal x.

Fig. 1: Plot of the DFT of the signal B. Laboratory session

a) Using rectangular window of 1024 samples

II. PROCEDURE A. Background study In this sessions background study we studied what we were going to get in MATLAB if we plot the DFT of the signal. So we had to get the mathematical expression corresponding to the DFT of a sinusoidal signal of period N and length a N samples (where a is an integer number). For that, we got the mathematical expression of the sampled signal: [ ] ( ) ( [ ] [ ]) ( )

In this laboratory session, each group had a different file for working. Our file was called N29.mat which contained the samples of the two tone signal. We loaded it in MATLAB just using the instruction load N29.mat. The length of the array with stored samples was of 1024 samples (so its like if we multiply the whole signal for a rectangular window of 1024 samples) and it had been sampled at a sampling frequency of 8KHz. For hearing it, we used wavplay function, so we could hear that it was really a phone tone.

Then, we calculated x[n] in the domain transform of Fourier ( ( )) . As we expected, the solution was two digital ( ) functions placed in the frequency of the tone. That is because we do not have a tone for an infinite time, because it has been multiplied for a rectangular window. If we now calculate its DFT by replacing for (2), we will get a signal sampled in frequency domain. (2) In this case, if we plot the DFT we will see that every time that we get a sample, the value of the digital ( ) function is equal to zero. So in DFT we will see two almost perfect deltas. Fig. 2: Plot of the signal stored in N29.mat file considering a sampling frequency of 8 KHz. The duration in seconds of the signal is: ( )

The next step is to calculate the DFT for the array, so we will be able to see in what frequencies are both tones. For that, we first calculated the FFT of the vector, and then its modulus. If we plot that, we will be able to see the DFT of the signal.

( )

Note that we subtract a unit to the index of the delta. Thats because MATLAB plots from 1 to 1024, meanwhile it should be from 0 to 1023. So the given position is not the one that we want. The two different frequencies are approximately 1477 Hz and 697 Hz, and these values correspond to number 3 in phone keypad.


Zero padding with 64 samples and rectangular window of 1024 samples

Fig. 3: DFT of the signal. In Fig. 3 we can see two pairs of deltas. The two deltas in the right are the negatives symmetric deltas, and the ones in the left are the positive ones, so for DTMF we will use the deltas in the left. For finding where those deltas were placed (k values) we used max function implemented in MATLAB. This function returns max values and its positions, so we had to execute the following commands. Command Amplitude Frequency (k value) 190

In this part of the laboratory session we cut our signal (FFT not done yet), and only used 64 samples. And from positions 65 to 1024 we added samples equal to zero. This method of adding samples with value zero is called zero padding. If we calculate its DFT, we can see that we get more resolution than without zero padding method.

508,16 x2=abs(fft(x)) [amp,freq]=max(x2) 473,27 [amp,freq]=max(x2(1:180)) 90 Table 1: Shows the position of the deltas and their position in the vector.

Fig. 4: Stem of the DFT of the given signal taking 64 samples without zero padding

Once having detected one delta, we have to find the second one. For that, we used the same instruction, but only giving as a parameter a part of the vector where found maximum was not there. Knowing the amplitude of the DFT peaks, we can calculate the amplitude of both tones using this equation:

( )

Fig. 5: Stem of the DFT of the given signal taking 64 samples with zero padding implemented. Using this method will not show us a better result, as we see we will only get more resolution. If we want to get a better result, we will have to take more samples of the signal (note that in zero padding we add fake samples, the zeros).

To know the frequency in Hz of the pressed key, we used this equation:

c) Using hamming window with 64 samples.

Now we will use another type of window, the hamming. We follow the same steps as before but taking only 64 of 1024 samples in order to analyze better its behavior. The signal that we are going to analyze is the following:

Fig. 8: Rectangular window

III. CONCLUSIONS In this practice we have learned, first of all, that computers cannot store temporal signals, because for that we would need infinite memory. For that, we have to get only some samples (multiply for a window). There are different types of window, and for each signal, we have to decide which is the best option, because some can be better than others. MATLAB itself already multiplies the signal for a rectangular window. So if we calculate the DFT of a two tone signal, we will not get two perfect deltas, but two sinc(x). With this rectangular window, if the frequency of the tones are near, we may not be able to detect both tones, but only one. Otherwise, if we use a hamming window, we have seen that the secondary lobe is hardly attenuated. So now, we have been able to detect both tones. On the other hand, when we multiply for a window, we lose sample information. If we want to increase our resolution of the DFT, we can add zeros at the end of the signal (zero padding method), or if we want to get more definition, we only can get more samples from the real signal.

Fig. 6: Signal using a hamming window If we look to both figures, we can see that in the first case, when using a rectangular window, the difference between DFT peaks are not as visible as when using hamming window. In fact, in the last case we can see that if the two tones were together, with rectangular window we would hardly see if there are two tones or just one. But with hamming, we could see both tones.


Fig. 7: Hamming window

Guide for the background study of this laboratory session: r=/LABORATORI/Lab._Session_3