Dtmf Detection And Decoding Engineering Essay

Published:

This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

This report is about to show a specific approach to decoding a Dual-tone Multi-Frequency (DTMF) signaling by using MATLAB.

II. Approach

Part 1: DTMF detection and decoding.

1. Generate input signals: As the TouchToneDialler function has been provided, we can simply generate the DTMF signaling by calling this function.

Comments: Each tone generated by the TouchToneDialler function consists of two frequencies: the low frequency and the high frequency. The practical relationship between the keys and the frequency pairs are shown below:

1209 Hz

1336 Hz

1477 Hz

697 Hz

1

2

3

770 Hz

4

5

6

852 Hz

7

8

9

941 Hz

*

0

#

Table 1 The frequency components of each touch tone

And also, from the description of this function we can see that the original input has been affected by the colored noise which may confuse the signal detection with some unexpected high-level noise. Another essential point, mentioned by the function description, is that there is jitter in the timing, i.e. , the duration of each DTMF signal and the gap between each key press are both random values around the theoretical values 100ms and 150ms, respectively. As a result, we are taking a risk while using the assuming values to calculate the number of the input keys.

Fig 1 The ideal signaling '1' and its magnitude in frequency domain

2. DTMF detection: In order to detect the DTMF signaling, firstly, we need to transfer the input signal from the time domain into the frequency domain. In an ideal situation, the Fourier Transform of sinusoid is two ideal impulses which are symmetric about the origin. Since there is redundancy in the frequency domain, we only need to use the positive part of the frequency axis. And also, as the impulse is negative on the positive frequencies, we can use abs function to get the absolute value of the magnitude of the sinusoid in the frequency domain. For example, if we transform the DTMF signaling '1' into the frequency domain using the method above, we can intuitively see how it works in an ideal situation without noise. (See Fig 1)

From Fig 1, we can see that it can be easy for us to detect the DTMF signaling by finding the locations of these two impulses which form the input tone. In order to find the locations of the impulses, we can use max function to extract these two impulses from the DFT of the input sequence. For instance, we can divide the DFT of the input signal into two parts: the low frequency group and the high frequency group. Get the maximum values in both parts by calling the max function and at the same time achieve the indexes of the values.

Comments: Due to the noise in the input signal, we are failed to achieve the ideal impulses, which will have a bad effect on the detection performance. And also, the unexpected jitter in the timing can make us at a risk of decoding error while using the approximate values of duration to extract one single tone from the sequence, because we may unexpectedly take some data from the adjacent tones and this can make the system seriously unreliable. (See Fig 2)

Fig 2 Risk of decoding error Fig 3 PSD of the input signal

We, therefore, have to modify the method to improve the system performance. For example, we can simply square the magnitude of the DFT of the input signal, and then we can achieve the Power Spectral Density (PSD) which can be used to build a more reliable system. Fig 3 shows an impressively better performance given by using the PSD of the input signal.

3. DTMF decoding: After getting the locations of the impulses, we need to, at first, transfer the location indexes into two certain frequencies so that they can be used to compare with the frequency components of each DTMF signaling presented in Table I. As the frequencies we get have kind of difference to the theoretical values in the table, we have to set an appropriate error region so that the input signal can be decoded accurately. For example, in this experiment, I choose the error region to be 20 Hz.

Comments: If the error region is too large, it may cause error decoding. On the other hand, if it is too narrow, the signaling will be failed to be decoded.

Part 2: Touch tone multi-digit decoder.

1. Set an appropriate amplitude threshold: In order to distinguish the valid signaling from the noise, we have to set an amplitude threshold to 1.7 V. And then all the signals under the threshold will be treated as noise, on the other hand, those over the threshold will be regarded as the valid signaling.

Comments: Since the SNR level is required to be 5 dB in this experiment, we can estimate the maximum noise level by using the equation below:

From the graph of input signal, we can see that the maximum value of signal is nearly up to 3 V. Then use the equation above, we can calculate the maximum noise level is around 3/10^(5/20)=3/10^0.25=1.687 V. We can, therefore, make the amplitude threshold equal to 1.7 V.

2. Valid signal detection: At first, we detect all the elements in the input sequence one by one. If the amplitude of the element is under the threshold we set, we will treat it as noise and do nothing but turn to the next element. If the amplitude of the data is over the threshold, we will regard it as a valid signal and then skip the next 1400 elements.

Comments: From the graph of the power spectral density (Fig 3), we can see that the influence made by noise is extremely limited, so it's not necessary for us to remove the noise from the sequence by using the threshold. Once we find a valid signal, we will skip all the valid signals after it in one individual tone by using the theoretical values of the duration mentioned before. In order to protect the whole DTMF signal, the duration we skip is equal to the sum of the duration of each DTMF signal and half the gap between two signals, which is totally 0.175 s or 0.175*8000=1400 elements.

3. Extract individual signals from the sequence: In order to get every individual signaling, we can divide the sequence from half the gap between two signals to the next half gap, which has the total length of 2000 elements, except the last signal of the sequence. It can be more intuitively from the graph below:

Fig 4 The length of the extracted signal

Comments: As mentioned before, there is jitter in the timing, i.e. , the duration of each DTMF signal and the gap between two keys are both random values . In common cases, we will choose the data from half the gap to the next half gap, totally 2000 elements or 0.25 s. In practice, the individual signals extract is one essential part of the valid signal detection. Once we get the valid signal, we assuming this location as the start point of the individual tone, and then we can extract the previous 0.075*fs=600 and the next 0.175*fs=1400 elements as one signaling.

4. Call the function dtmf_decode.m

III. Conclusion

In conclusion, multi-digit DTMF decoding can be described briefly in four steps:

Step 1 Set an appropriate amplitude threshold: Use SNR formula to calculate the amplitude threshold in order to distinguish valid signals from noise.

Step 2 Valid signal detection: Use the threshold above to detect valid signals.

Step 3 Extract individual signals from the sequence: Extract an appropriate length of elements as one tone by using the valid signal we detected above.

Step 4 Call the function dtmf_decode.m: Use the PSD of the input signal to find two characteristic frequencies, then decode the signaling according to Table 1.

Appendix I

test_dtmf_decode.m

clc

clear

global flag

flag = input('You can choose:\n1. Single key detection and decoding.\n2. Multi-digit decoder.\n');

if flag == 1

key = input('Please press a single key: ','s');

s = TouchToneDialler(key,5); %generate the input signal with SNR = 5 dB

fprintf('The received number is: ')

dtmf_decode(s); %decode the single DTMF signaling

fprintf('\n');

elseif flag == 2

key =input('Please enter a phone number£° ','s');

s = TouchToneDialler(key,5);

fprintf('The received phone number is: ')

touch_tone_decoder(s); %decode the multi-digit DTMF signaling

fprintf('\n');

else

error('Wrong Command.');

end

dtmf_decode.m

function dtmf_decode(input)

%function to decode the single DTMF signaling

global flag

N = length(input);

fs = 8000;

psd_input = abs(fft(input)).^2; %calculate the PSD of the input signal

if flag == 1

figure

plot((0:round(N/2)-1).*fs/N,psd_input(1:round(N/2))) %plot the PSD of the input signal

title('Power Spectral Density');xlabel('frequency / Hz');ylabel('Input signal power')

axis tight

end

freq1 = round(1100/fs*N); %the upper limit of the row frequency group

freq2 = round(1600/fs*N); %the upper limit of the column frequency group

[rowf_mag,rowf_index] = max(psd_input(1:freq1)); %the index of the row frequency

[colf_mag,clmf_index] = max(psd_input(freq1+1:freq2));

clmf_index = clmf_index+freq1; %the index of the column frequency

rowf = rowf_index/N*fs; %calculate the row frequency

colf = clmf_index/N*fs; %calculate the column frequency

err_reg = 20; %set the error region

n = 0:511;

if(abs(rowf-697)<=err_reg && abs(colf-1209)<=err_reg) %compare the frequencies and decode the signaling

fprintf('1');

x = sin(2*pi*697*n/8000)+sin(2*pi*1209*n/8000);

elseif (abs(rowf-697)<=err_reg && abs(colf-1336)<=err_reg)

fprintf('2');

x = sin(2*pi*697*n/8000)+sin(2*pi*1336*n/8000);

elseif (abs(rowf-697)<=err_reg && abs(colf-1477)<=err_reg)

fprintf('3');

x = sin(2*pi*697*n/8000)+sin(2*pi*1477*n/8000);

elseif (abs(rowf-770)<=err_reg && abs(colf-1209)<=err_reg)

fprintf('4');

x = sin(2*pi*770*n/8000)+sin(2*pi*1209*n/8000);

elseif (abs(rowf-770)<=err_reg && abs(colf-1336)<=err_reg)

fprintf('5');

x = sin(2*pi*770*n/8000)+sin(2*pi*1336*n/8000);

elseif (abs(rowf-770)<=err_reg && abs(colf-1477)<=err_reg)

fprintf('6');

x = sin(2*pi*770*n/8000)+sin(2*pi*1477*n/8000);

elseif (abs(rowf-852)<=err_reg && abs(colf-1209)<=err_reg)

fprintf('7');

x = sin(2*pi*852*n/8000)+sin(2*pi*1209*n/8000);

elseif (abs(rowf-852)<=err_reg && abs(colf-1336)<=err_reg)

fprintf('8');

x = sin(2*pi*852*n/8000)+sin(2*pi*1336*n/8000);

elseif (abs(rowf-852)<=err_reg && abs(colf-1477)<=err_reg)

fprintf('9');

x = sin(2*pi*852*n/8000)+sin(2*pi*1477*n/8000);

elseif (abs(rowf-941)<=err_reg && abs(colf-1209)<=err_reg)

fprintf('*');

x = sin(2*pi*941*n/8000)+sin(2*pi*1209*n/8000);

elseif (abs(rowf-941)<=err_reg && abs(colf-1336)<=err_reg)

fprintf('0');

x = sin(2*pi*941*n/8000)+sin(2*pi*1336*n/8000);

elseif (abs(rowf-941)<=err_reg && abs(colf-1477)<=err_reg)

fprintf('#');

x = sin(2*pi*941*n/8000)+sin(2*pi*1477*n/8000);

end

sound(x,8000); %play the sound of the touch tone

touch_tone_decoder.m

function touch_tone_decoder(input)

%function to decode the multi-digit DTMF signaling

N = length(input);

fs = 8000;

figure;

plot(input)

title('The input signal');xlabel('sample index');ylabel('Input signal / V');

axis tight

thres = 1.7; %set the amplitude threshold

n = 0.075*fs; %the length of the half gap

r = 0.1*fs; %the length of each tone

k = 1;

while(k < N) %count the number of the input tones

if abs(input(k)) > thres

dtmf_decode(input((k-n):(k+r+n))); %extract every individual signal from the sequence

k = k+r+n;

else

k = k+1;

end

end

Appendix II

Y

N

Y

Y

N

START

Single tone ?

Set the threshold

k<N ?

Signal ?

Skip 1400 elements

Next element

Extract the individual signal

Calculate the PSD

Find two frequencies

Compare with the Table

Decoding the signaling

END

NFlow Diagram

Writing Services

Essay Writing
Service

Find out how the very best essay writing service can help you accomplish more and achieve higher marks today.

Assignment Writing Service

From complicated assignments to tricky tasks, our experts can tackle virtually any question thrown at them.

Dissertation Writing Service

A dissertation (also known as a thesis or research project) is probably the most important piece of work for any student! From full dissertations to individual chapters, we’re on hand to support you.

Coursework Writing Service

Our expert qualified writers can help you get your coursework right first time, every time.

Dissertation Proposal Service

The first step to completing a dissertation is to create a proposal that talks about what you wish to do. Our experts can design suitable methodologies - perfect to help you get started with a dissertation.

Report Writing
Service

Reports for any audience. Perfectly structured, professionally written, and tailored to suit your exact requirements.

Essay Skeleton Answer Service

If you’re just looking for some help to get started on an essay, our outline service provides you with a perfect essay plan.

Marking & Proofreading Service

Not sure if your work is hitting the mark? Struggling to get feedback from your lecturer? Our premium marking service was created just for you - get the feedback you deserve now.

Exam Revision
Service

Exams can be one of the most stressful experiences you’ll ever have! Revision is key, and we’re here to help. With custom created revision notes and exam answers, you’ll never feel underprepared again.