Sie sind auf Seite 1von 18

Assignment Cover Sheet

STUDENT NAME : Bimal Raj Neupane STUDENT NUMBER


S217173
POSTAL ADDRESS: 10/256 Casuarina Drive, Nightcliff

POSTCODE : 0810 PHONE: 0420584555

EMAIL: bimal.neupane@hotmail.com

UNIT NAME: Digital Signal Processing

UNIT CODE: ENG421

Semester __1____
LECTURER NAME : Friso De Boer
Year
ASSESSMENT TITLE: Lab 7 ______2011_____

DUE DATE DATE OF SUBMISSION


APPLIED FOR EXTENSION?  YES  NO  N/A
13/05/2011 13/05/2011
KEEP A COPY
If you have submitted assessment work electronically please make sure you have a backup copy.
PLAGIARISM
Plagiarism is the presentation of the work of another without acknowledgement. Students may use a limited amount of
information and ideas expressed by others but this use must be identified by appropriate referencing.
CONSEQUENCES OF PLAGIARISM
Plagiarism is misconduct as defined under the Student Conduct By-Laws. The penalties associated with plagiarism are
designed to impose sanctions on offenders that reflect the seriousness of the University’s commitment to academic integrity.

I declare that all material in this assessment is my own work except where there is a clear acknowledgement and reference to
the work of others. I have read the University’s Academic and Scientific Misconduct Policy and understand its implications.*
http://www.cdu.edu.au/governance/documents/3.3academicandscientificmisconduct.doc

Signed: _____bimal___________________________________________ Date: 13/05/2011


*By submitting this assignment and cover sheet electronically, in whatever form you are deemed to have made the declaration set out above.

Office use only Assessor use only


PLEASE PLACE GRADE HERE
DATE RECEIVED

DATE SENT TO LECTURER

Bimal Neupane ENG421 s217173


1. Introduction:

The purpose of the lab is familiarity with the DTMF signals, amplitude modulation and FIR filtering.
Moreover, in this lab we generate Dual tone multi frequency (DTMF) by pressing the number on the
keypad which generates a sinusoidal signal that is combination of two sinusoids of different
frequencies.

2. Background:

2.1 Touch tone Dialling:

The keypad of telephone produce dual tone multi frequency (DTMF) signal which is the sinusoidal
signal of two different frequencies i.e. corresponding row and column for each number. For example
if number 7 is pressed, the sinusoidal signal is produced due to the combination of 852 Hz and 1209
Hz.

Frequency 1209 1336 1477


(HZ)
697 1 2 3
770 4 5 6
852 7 8 9
941 * 0 #

Figure.1 Corresponding frequencies for each number on keypad

2.2 Amplitude Modulation:

Amplitude modulation (AM) is the process of transmit the message signal of low frequency using a
high frequency of carrier signal. The AM radio is the best example of amplitude modulation in which
high frequency carrier is multiply with the low frequency message signal i.e.

𝑥(𝑡) = (1 + 𝐴 cos(2𝜋𝑓𝑚 𝑡)) cos(2𝜋𝑓𝑐 𝑡)

When we expand the above signal with the help of Inverse Euler formula we get;

𝐴 𝐴
𝑥(𝑡) = cos⁡(2𝜋𝑓𝑐 𝑡) + cos(2𝜋(𝑓𝑐 + 𝑓𝑚 )𝑡) + cos(2𝜋(𝑓𝑐 − 𝑓𝑚 )𝑡)
2 2

The signal component at 𝑓 = 𝑓𝑐 ± 𝑓𝑚 is the sidebands where 𝑓𝑐 is called the carrier frequency and 𝑓𝑚
is the message signal frequency.

Bimal Neupane ENG421 s217173


2.3 Amplitude Demodulation:

Amplitude demodulation is the process of extract carrier frequency from message signal. There are
numerous methods of demodulating the signal with the envelope detection, notch filter and LTI filter.
However we are using LTI based filter on this practical.

3. Warm-up A: DTMF Synthesis

Figure.2 plot of 1 to 12 input number which shows 12 different frequency components

Figure.3 Spectrogram of tones

Bimal Neupane ENG421 s217173


Matlab file (dtmfdial.m) for DTMF Synthesis:

% Warmup A :DTMF Synthesis

function tones = dtmfdial(nums)


%DTMFDIAL Create a vector of tones which will dial
% a DTMF (Touch Tone) telephone system.
%
% usage: tones = dtmfdial(nums)
% nums = vector of numbers ranging from 1 to 12
% tones = vector containing the corresponding tones.
%
if (nargin < 1)
error('DTMFDIAL requires one input');
end
fs = 8000; %-- This MUST be 8000, so dtmfdeco( ) will work.
dur = 0.5;
t = [0:1/fs:dur];
tone_pairs = ...
[ 697 697 697 770 770 770 852 852 852 941 941 941;
1209 1336 1477 1209 1336 1477 1209 1336 1477 1336 1209 1477 ];
%1 2 3 4 5 6 7 8 9 10 11 12
%tone pairs for different keypad
n1=1;
for i = 1:length(nums);
n2=n1+4000; %0.5 duration i.e sample at 4000Hz
f1 = tone_pairs(1,i);
f2 = tone_pairs(2,i);
keypadfreq =(cos(2*pi*t*f1))+(cos(2*pi*t*f2));
xx(n1:n2)= keypadfreq;
n1=n2+800; %0.1 sec delay i.e. sample of 800Hz
end
%plot(xx);
tones = xx;
soundsc(xx,fs);
specgram(tones)

% for the output type: dtmfdial([1 2 3 4 5 6 7 8 9 10 11 12])in matlab main


% window to get 12 different tones

The dtmfdial.m matlab file is designed to create a DTMF tone of two corresponding
frequencies pairs for each specific number. The main loop is start from the i-vector which is
uses to pull two different frequency from tone pair i.e. from first row (1,i) and second
row(2,i). Later, these two frequencies are adding in terms of cosine function to get DTMF
tone of each number. In other words, if the input is: dtmfdial ([1 2 3 4 5 6 7 8 9 10 11 12]) it
give 12 different tones in which each tone is combination of two different frequencies.

Bimal Neupane ENG421 s217173


4. Warm-up B: Tone Amplitude Modulation

(a)Derive (3) from (2).

Given, modulated signal: 𝑥(𝑡) = (1 + 𝐴 cos(2𝜋𝑓𝑚 𝑡)) cos(2𝜋𝑓𝑐 𝑡)


𝐴 𝐴
To derive: 𝑥(𝑡) = cos⁡(2𝜋𝑓𝑐 𝑡) + 2 cos(2𝜋(𝑓𝑐 + 𝑓𝑚 )𝑡) + 2 cos(2𝜋(𝑓𝑐 − 𝑓𝑚 )𝑡)

Proof:

𝑥(𝑡) = (1 + 𝐴 cos(2𝜋𝑓𝑚 𝑡)) cos(2𝜋𝑓𝑐 𝑡)

𝑥(𝑡) = (cos(2𝜋𝑓𝑐 𝑡) + 𝐴 cos(2𝜋𝑓𝑚 𝑡) cos(2𝜋𝑓𝑐 𝑡)

By using Inverse-Euler formula for the second term;

For example:
1
cos(θ) = 2 (𝑒 𝑗𝜃 +𝑒 −𝑗𝜃 )

Then x (t) becomes;

1 1 1
𝑥(𝑡) = (𝑒 𝑗2𝜋𝑓𝑐 𝑡 +𝑒 −𝑗2𝜋𝑓𝑐 𝑡 ) + 𝐴. (𝑒 𝑗2𝜋𝑓𝑚 𝑡 +𝑒 −𝑗2𝜋𝑓𝑚𝑡 ) (𝑒 𝑗2𝜋𝑓𝑐 𝑡 +𝑒 −𝑗2𝜋𝑓𝑐 𝑡 ))
2 2 2
𝐴 𝑗2𝜋(𝑓 +𝑓 𝑡
𝑥(𝑡) = cos(2𝜋𝑓𝑐 𝑡) + (𝑒 𝑐 𝑚) +𝑒 −𝑗2𝜋(𝑓𝑐 +𝑓𝑚) 𝑡 + 𝑒 𝑗2𝜋(𝑓𝑐 −𝑓𝑚) 𝑡 +𝑒 −𝑗2𝜋(𝑓𝑐 −𝑓𝑚) 𝑡 )
4
𝐴 𝐴
𝑥(𝑡) = cos(2𝜋𝑓𝑐 𝑡) + cos(2𝜋(𝑓𝑐 + 𝑓𝑚) 𝑡 + cos(2𝜋(𝑓𝑐 − 𝑓𝑚) 𝑡
2 2

Figure.4 Spectrum of an Amplitude Modulation

Bimal Neupane ENG421 s217173


Instructor Verification:

Create and explain AM signal:

Amplitude modulation (AM) is the process of transmit the message signal of low frequency using a
high frequency of carrier signal. In the frequency domain, the amplitude modulation power is
concentrated at the central carrier frequency,⁡⁡𝑓𝑐 and its two sidebands i.e.⁡(𝑓𝑐 − 𝑓𝑚) and (𝑓𝑐 + 𝑓𝑚 ).
Moreover, each side band has a mirror image in the negative frequency axis and each sideband is
equal to the bandwidth of that modulating signal i.e. Message signal.

The following characteristics are given to create the AM test signal:

(a)

Carrier frequency, fc=1200 Hz

Duration= 1 second

Sampling rate, fs = 8000 Hz

And phase angle (ø) = 0

(b)

Message frequency, fc=100 Hz

Amplitude (Am) = 0.8

Waveform and Spectrum of the Signals:

Figure.4 Waveform of the Modulating, Message and Carrier Signal

The lower frequency signal is the message signal i.e. blue, and the black colour- signal is the
modulated signal.

Bimal Neupane ENG421 s217173


Figure.5 Spectrum of a Modulated Signal

Figure.6 Spectrum of a Carrier Signal

Bimal Neupane ENG421 s217173


Figure.7 Spectrum of a Message Signal

Matlab file (warm_b.m) for Warm-up B: Tone Amplitude Modulation

%warm-up B
clc
clear

fc = 1200;
fm = 100;
fs = 8000;
dur = 1;
pi = 3.14;
Ac=1;
Am=0.8;
t= 0:1/fs:dur;
cs = Ac*cos(2*pi*fc*t);
%carrier signal
ms = Am*cos(2*pi*fm*t);
%message signal
xx = cs.*(ms+1);
%modulated signal
yy=xx;

plot(t(1:200),yy(1:200),'k')
hold on
plot(t(1:200),ms(1:200),'b')
xlabel('Time')
ylabel('Amplitude')
title('Modulated signal and Message signal ')
hold on;
legend ('Modulated signal', 'message signal',
'Location','NorthEastOutside')
figure

Bimal Neupane ENG421 s217173


showspec(yy,8000)
title('Modulated signal')

figure
showspec(cs,8000)
title('Carrier signal')

figure
showspec(ms,8000)
title('Message signal')

5. Lab A: DTMF Decoding:

5.1 Filter Design:

(a)

Figure.8 Filter Coefficient of h770 band pass filter

(b)

Figure.9 Filter Coefficient of h1336 band pass filter

Bimal Neupane ENG421 s217173


(c)

Figure.10 Magnitude response of h770 band pass filter

(d)

Figure.11 Magnitude response of h770 and DTMF location

Bimal Neupane ENG421 s217173


(e) Comment on the selectivity of the band pass filter h770:

From figure 10, we can analyse that the band pass filter h770 only passes the frequency
component 770 Hz and reject (attenuates) other frequency components below and above
770Hz. The amplitude response of the band pass filter is going to flat from its central
frequency i.e. in this case 770 Hz and above and below the central frequency it’s going to
down and up to points where it begins to roll off. The standard reference points for these roll-
offs are the points where the amplitude has decreased by 3 dB, to 70.7% of its original
amplitude. For the length L= 64 which is large so that the band pass filter is narrow enough to
separate individual frequencies. For this lab L= 64 which is the filter length. If we increase
the filter length the pass band going to decrease i.e. the bandwidth of the filter is controlled
by filter length (L).

(f) Plot the magnitude response of the h1336 filter and compare its pass band to that of
the h770 filter.

From the figure 10 and 12 we can conclude that h770 band pass filter only passes the
frequency component of 770 Hz while in case of h1336, the pass band is shifted to frequency
1336 Hz.

Figure.12 Magnitude response of h1336 band pass filter

Bimal Neupane ENG421 s217173


Matlab file (lab7_4a.m) for Filter Design: h770 Band pass filter

%4.1(a) filter design


%question(a)
%bandpass filter, h770
%given transfer function h[n]=(2/L)*cos((2*pi*f_bp*n)/fs);
clear
clc
L = 64;
n = 0:1:L;%length is 64
fs = 8000;
f_bp = 770;
h770 = (2/L)*cos((2*pi*f_bp*n)/fs);
%impulse response of band pass filter
stem(h770)
title('h770 Bandpass Filter Coefficients')
xlabel('Time Index n')
ylabel(' Impulse response h[n]')

Matlab file (lab7_4b.m) for Filter Design: h1336 Band pass filter

%4.1(b) filter design


%question(b)
%bandpass filter, h1336
%given transfer function h[n]=(2/L)*cos((2*pi*f_bp*n)/fs);
clear
clc
L = 64;
n = 0:1:L;%length is 64
fs = 8000;
f_bp = 1336;
h1336 = (2/L)*cos((2*pi*f_bp*n)/fs);
%impulse response of band pass filter
stem(h1336)
title('h1336 Bandpass Filter Coefficients')
xlabel('Time Index n')
ylabel(' Impulse response h[n]')

Matlab file (lab7_4c.m) for frequency response of h770 Band pass filter

%4.1(c)filter design
%question(c)
%plot the frequency response (magnitude) of h770 bandpass filter
clear
clc
L = 64;
n = 0:1:L;%length is 64
f_bp = 770;
fs = 8000;

h770 = (2/L)*cos((2*pi*f_bp*n)/fs);
%impulse response of band pass filter
ww = 0:(pi/256):pi; %-- only need positive freqs
ff = ww/(2*pi)*fs;
H = freqz(h770,1,ww);
figure
plot(ff,abs(H)); grid on;
hold on;

Bimal Neupane ENG421 s217173


title('Magnitude of h770 Band Pass Filter')
xlabel('Frequency Hz')
ylabel(' Magnitude')

Matlab file (lab7_4d.m) for frequency response of h770 and DTMF location

%4.1(d) filter design


%question (d)
%plot the frequency response (magnitude) of h770 bandpass filter
clear
clc
L = 64;
n = 0:1:L;%length is 64
f_bp = 770;
fs = 8000;

h770 = (2/L)*cos((2*pi*f_bp*n)/fs);
%impulse response of band pass filter
ww = 0:(pi/256):pi; %-- only need positive freqs
ff = ww/(2*pi)*fs;
H = freqz(h770,1,ww);
figure
plot(ff,abs(H)); grid on;
% for part d
hold on;
%STEM(Y) plots the data sequence Y as stems from the x axis
%terminated with circles for the data value.
stem(690,0,'r')
stem(770, 1,'r')
stem(852, 0,'r')
stem(941, 0,'r')
stem(1209, 0,'r')
stem(1336, 0,'r')
stem(1477, 0,'r')
title('Magnitude of h770 Band Pass Filter and DTMF Frequency Location')
xlabel('Frequency Hz')
ylabel(' Magnitude')

Matlab file (lab7_4f.m) for frequency response of h1336 Band pass filter

%4.1(f) filter design


%question(f)
%plot the frequency response (magnitude) of h1336 bandpass filter
clear
clc
L = 64;%length is 64
n = 0:1:L;
fs = 8000;
f_bp = 1336;

h1336 = (2/L)*cos((2*pi*f_bp*n)/fs);
%impulse response of band pass filter
ww = 0:(pi/256):pi; %-- only need positive freqs
ff = ww/(2*pi)*fs;
H = freqz(h1336,1,ww);
figure
plot(ff,abs(H)); grid on;
hold on;

Bimal Neupane ENG421 s217173


title('Magnitude of h1336 BandPass Filter')
xlabel('Frequency Hz')
ylabel(' Magnitude')

5.2 A Scoring Function:


(a) The scoring function is the binary detection technique to get the presence and absence of
the individual tones.

Matlab file (dtmfscor.m) for a scoring Function

%4.2 (a)DTMF Scoring Function


function ss = dtmfscor(xx, freq, L, fs)
%DTMFSCOR
% ss = dtmfscor(xx, freq, L, [fs])
% returns 1 (TRUE) if freq is present in xx
% 0 (FALSE) if freq is not present in xx.
% xx = input DTMF signal
% freq = test frequency
% L = length of FIR bandpass filter
% fs = sampling freq (DEFAULT is 8000)
%
% The signal detection is done by filtering xx with a length-L
% BPF, hh, squaring the output, and comparing with an arbitrary
% setpoint based on the average power of xx.
%
if (nargin < 4), fs = 8000; end;
n=0:L;
hh = (2/L)*cos((2*pi*freq*n)/fs); %<======== define the bandpass filter
coeffs here
ss = (mean(conv(xx,hh).^2) > mean(xx.^2)/5);

(b) Explain the last line in dtmfscor.m:


ss = (mean(conv(xx,hh).^2) > mean(xx.^2)/5);

In general terms, the last line in dtmfscore.m says that if the condition is true it gives output
‘1’ otherwise it gives the output zero. Moreover, Average output power can be calculated as
a r.m.s (root mean square) value and the output signal yy is the convolution of the input
signal xx and impulse respond hh which is then root squared and finally it has been
compared with the actual input signal xx.

Bimal Neupane ENG421 s217173


5.3 DTMF Decode Function:

Matlab file (dtmfdeco.m) for a DTMF Decode Function

function key = dtmfdeco(xx,fs)


%DTMFDECO key = dtmfdeco(xx,[fs])
% returns the key number corresponding to the DTMF waveform, xx.
% fs = sampling freq (DEFAULT = 8000 Hz if not specified.
%
if (nargin < 3), fs = 8000; end;L=64;
tone_pairs = ...
[ 697 697 697 770 770 770 852 852 852 941 941 941;
1209 1336 1477 1209 1336 1477 1209 1336 1477 1336 1209 1477 ];

for i= 1:12
x1 = dtmfscor(xx,tone_pairs(1,i), L,fs) ;
x2 = dtmfscor(xx,tone_pairs(2,i), L,fs);
if((x1==1)&&(x2==1))
key= i;
i=12;
end
end

%check: a=dtmfdial(1)
%let, b = dtmfscor(a,697,64,8000);it output should be 1
%similarlly if, b = dtmfscor(a,1209,64,8000);it output should be 1
% however, if b = dtmfscor(a,770,64,8000);it output should be 0; because
% there is no component from first pair........

Matlab file (dtmfmain.m) for a DTMF Main Function

Note: the file is taken from the C:\Program Files\MATLAB\R2009b\toolbox\DSPFIRST


(as a reference file)

function d = dtmfmain(x)
%DTMFMAIN run the entire DTMF decoder
% usage:
% d = dtmfmain(x)
%
% x = input signal vector
% d = decoded output
%
% NOTE: the user must provide the function called dtmfdeco.m
%

setpoint1 = 0.01; setpoint2 = 0.02;


d = [];
z = conv([1 1 1],abs(x));
N = length(x);
n1 = 1; n2 = 1;
while (sum(z(n2:N)) > setpoint2),
q = find(z(n2:N)>setpoint2)+n2;
n1 = q(1);
if (n1 > N) break; end;
q = find(z(n1:N)<setpoint1)+n1;
if (~isempty(q)), n2 = q(1);
else n2 = N; end;

Bimal Neupane ENG421 s217173


if (n1 == n2) break; end;
if (exist('dtmfdeco')==2)
d = [d dtmfdeco(x(n1:n2))];
elseif (exist('dtmfdecod')==2)
d = [d dtmfdecod(x(n1:n2))];
else
error('dtmfdeco function not found, you must write this function.');
end
end;

For the output:


1. To check decoding: type in the matlab main window
a = dtmfdial(1)
The function loads the two frequency components from the DTMF dial function i.e. 697Hz
and 1209 Hz and ignores other frequency pairs. From figure 13, it can be seen that the graph
only consists of the two frequency components corresponding to 1 button.

Figure 13 Spectrogram of the decoded tones corresponding to button 1

Bimal Neupane ENG421 s217173


2. To check Scoring Function:

(i) b = dtmfscor(a,697,64,8000)

b =1

If we input

(ii) b=dtmfscor(a,1336,64,8000)

b=0

We know the scoring function is the binary detection technique to get the presence and
absence of the individual tones. Before we input a = dtmfdial(1), which only loads the two
frequency component related to the 1 button i.e. 697Hz and 1209 Hz. When we type the b =
dtmfscor(a,697,64,8000) to check the scoring function, the function is consist of the
frequency component 697 Hz, so it gives the output 1.However for the second one i.e. b =
dtmfscor(a,1336,64,8000) the frequency component is different i.e. 1336 and 697 is different
so, it gives the output zero.

3. To check DTMF Main Function:

dtmfmain(dtmfdial([1:12]))

ans =

1 2 3 4 5 6 7 8 9 10 11 12

It shows the 12 individual signal segment pairs.

Bimal Neupane ENG421 s217173


6. Conclusion:

Thus, from the above lab, we get the idea about how to generate, filtration and decoding of
the DTMF signals. For the DTMF generation, the basic idea of the telephone touch tone
dialling is implementing to generate the DTMF function in which we sampled the frequency
at 8KHz. Similarly, for the decoding function, we detect the input through scoring function
which presents the presence and absence of the frequency component in terms of binary digit.

Reference:

1. H. McClellan et al., DSP first, a multimedia approach, Prentice Hall, 1998.


2. DSP First Laboratory Exercise #7 Everyday sinusoidal signals

Bimal Neupane ENG421 s217173

Das könnte Ihnen auch gefallen