You are on page 1of 3

1

Dual Tone Multi-Frequency (DTMF) Detection (November 2010)
Ángel Sánchez Abril & Raúl Suárez Marín. EPSC, UPC
 Abstract—The 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.

I. INTRODUCTION

I

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.
N

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 session’s 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 it’s 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: ( )

so for DTMF we will use the deltas in the left. we can see that we get more resolution than without zero padding method. If we want to get a better result. and the ones in the left are the positive ones.freq]=max(x2) 473. so we had to execute the following commands. For that. as we see we will only get more resolution.16 x2=abs(fft(x)) [amp. If we plot that. This method of adding samples with value zero is called zero padding. the zeros). Fig. 5: Stem of the DFT of the given signal taking 64 samples with zero padding implemented. Knowing the amplitude of the DFT peaks. so we will be able to see in what frequencies are both tones. If we calculate its DFT. So the given position is not the one that we want. but only giving as a parameter a part of the vector where found maximum was not there. And from positions 65 to 1024 we added samples equal to zero. 3: DFT of the signal. For finding where those deltas were placed (k values) we used max function implemented in MATLAB. we first calculated the FFT of the vector. and these values correspond to number 3 in phone keypad. and only used 64 samples. This function returns max values and its positions. Command Amplitude Frequency (k value) 190 In this part of the laboratory session we cut our signal (FFT not done yet). meanwhile it should be from 0 to 1023.27 [amp. b) Zero padding with 64 samples and rectangular window of 1024 samples Fig. That’s because MATLAB plots from 1 to 1024. we will be able to see the DFT of the signal. The two different frequencies are approximately 1477 Hz and 697 Hz. 508. In Fig. 3 we can see two pairs of deltas. we can calculate the amplitude of both tones using this equation: { ( ) Fig. and then its modulus. Using this method will not show us a better result.2 The next step is to calculate the DFT for the array. we have to find the second one. 4: Stem of the DFT of the given signal taking 64 samples without zero padding Once having detected one delta. To know the frequency in Hz of the pressed key. we used the same instruction. For that. The two deltas in the right are the negatives symmetric deltas. we used this equation: . we will have to take more samples of the signal (note that in zero padding we add fake samples. { ( ) Note that we subtract a unit to the index of the delta.freq]=max(x2(1:180)) 90 Table 1: Shows the position of the deltas and their position in the vector.

we lose sample information. we can see that in the first case. If we want to increase our resolution of the DFT. Now we will use another type of window. because for that we would need infinite memory. we have to get only some samples (multiply for a window).3 c) Using hamming window with 64 samples. if we use a hamming window. but two sinc(x). in the last case we can see that if the two tones were together. we may not be able to detect both tones. We follow the same steps as before but taking only 64 of 1024 samples in order to analyze better its behavior. So now. but only one. we can add zeros at the end of the signal (zero padding method). when using a rectangular window. On the other hand. Fig. CONCLUSIONS In this practice we have learned.php?id=707927&subdi r=/LABORATORI/Lab. first of all. we have been able to detect both tones. we only can get more samples from the real signal. we have to decide which is the best option. In fact. Otherwise. 6: Signal using a hamming window If we look to both figures._Session_3 . because some can be better than others. or if we want to get more definition.upc. 8: Rectangular window III. the hamming. REFERENCES [1] Fig. The signal that we are going to analyze is the following: Fig. when we multiply for a window. With this rectangular window. that computers cannot store temporal signals. we could see both tones. we have seen that the secondary lobe is hardly attenuated. There are different types of window. MATLAB itself already multiplies the signal for a rectangular window.edu/moodle/mod/resource/view. with rectangular window we would hardly see if there are two tones or just one. and for each signal. the difference between DFT peaks are not as visible as when using hamming window. So if we calculate the DFT of a two tone signal. 7: Hamming window Guide for the background study of this laboratory session: http://atenea. For that. we will not get two perfect deltas. But with hamming. if the frequency of the tones are near.