Vous êtes sur la page 1sur 4

Basco, Dan Cedric D.

Pancho, John Ralph O.


Querijero, Earl Felix C.
4ECEA

Source Code:



Derivations

A second order system is defined by the second order difference equation,

y(n) = -o
1
y(n - 1) - o
2
y(n - 2) + b
o
x(n)


The systems transfer function,


E(z) =
b
o
z
2
z
2
+a
1
z+a
2


The poles of the system are the roots of z
2
+ a
1
z + a
2
. The systems transfer
function varies with the frequency of oscillation. Thus, the system, h(n), oscillates
only at a certain frequency. The system is defined as:

b
o
r
n
|sin (
o
n +
o
)]
sin
o


For the amplitude of the oscillating signal to be constant,
r = 1 and b
o
= sin
o
.
%% 1
Fs=10000; duration=0.75; rest=0.5; % varied parameters
F=[1209 1336 1477 1633 697 770 852 941];
w=2*pi*F/Fs; % omega knot
b=sin(w); % b knot
a=[ones(8,1) -2*cos(w)' ones(8,1)]; % a = [1 -2cos(w) 1]
x=[1 zeros(1,round(duration*Fs-1))]; %impulse, 0.75s (7500 samples)
y=[];
for freq=1:length(F)
y(freq,:) = filter(b(freq),a(freq,:),x);
end
sn=fft(y',1024); %transposed so that 1 fft evals all y per freq
plot((0:511)/512*(Fs/2),abs(sn(1:512,:))) %all sn vs a single axis
%% 2
dial = ['005634'];
pad=['123A';'456B';'789C';'*0#D'];
[row,col]=find(pad==dial(1)); %determine the position of digit in pad
sig=y(row+4,:)+y(col,:); %high tones: 1-4; low tones: 5-8
for cursor=2:length(dial) %continue search for succeeding digits
[row,col]=find(pad==dial(cursor));
sig=[sig zeros(1,round(rest*Fs)) y(row+4,:)+y(col,:)];
end
wavplay(sig,Fs,'async');
%% 3
figure
specgram(sig,512,Fs,256,[]);

For the poles of the system,
z
1
= rc
]o
c

z
2
= rc
-]o
c


for r= 1, so:
z
1
= c
]o
c

z
2
= c
-]o
c
.

The coefficients of z
2
, z, and z
0
should be o
o
= 1, o
1
= -2 cos , and
o
2
= 1 respectively, where = 2FFs. Using the given frequencies:

for F=1209:
b
o
= sin(2 n 12u91uuuu)
a
1
= -2cos(2n 12u91uuuu)

for F=1336:
b
o
= sin(2 n 1SS61uuuu)
a
1
= -2cos(2n 1SS61uuuu)

for F=1477:
b
o
= sin(2 n 14771uuuu)
a
1
= -2cos(2n 14771uuuu)

for F=1633:
b
o
= sin(2 n 16SS1uuuu)
a
1
= -2cos(2n 16SS1uuuu)

for F=697:
b
o
= sin(2 n 6971uuuu)
a
1
= -2cos(2n 6971uuuu)

for F=770:
b
o
= sin(2 n 77u1uuuu)
a
1
= -2cos(2n 77u1uuuu)

for F=852:
b
o
= sin(2 n 8S21uuuu)
a
1
= -2cos(2n 8S21uuuu)

for F=941:
b
o
= sin(2 n 9411uuuu)
a
1
= -2cos(2n 9411uuuu)
The general working equations for H(z) defined above can thus be summarized as:

b
o
= sin(2 n FFs)
o
1
= 1 - 2cos [2n
P
Ps
z
-1
+ z
-2


where F and Fs can be replaced by the given frequencies and sampling rate (10000
Hz), respectively.

The resulting h(n) can be convolved to the impulse input. Alternatively, the
function y=filter(b,a,x) can be used to produce the output given the numerator and
denominator polynomial coefficients for H(z).

The output variable y can be used to store each filter output data in a
separate row. Values of b
o
and a
T
are stored in a similar manner.

Playback Duration

The sampling rate is defined as:

Fs = 1uuuu somplcsscc

from which the playback duration can be obtained. The duration can be defined as
Fs t

since Fs samples (10000 samples) are played in 1 second. If Fs * t does not yield an
integer value, then the value should be rounded off.

Sig Variable

pad =

123A
456B
789C
*0#D
dial =

005634



Row and col designates the position of the current dial digit in pad as n
th
row
and n
th
column respectively

Since the frequencies are stored in vector F as [high(1:4) low(1:4)], where the
high tones are in columns and the low tones in rows, col already specifies the high
tone position in F, whereas the value of row should be adjusted to row+4 to properly
refer to the corresponding low tone.

The 2 corresponding tones from y are added and stored as a single output
that corresponds to the current digit.

Sig is thus formed by storing the resulting tones for each digit specified in dial,
placing a 0.5 second gap or (Fs * 0.5) zeros in between the tones

Plots

To verify the output obtained from each filter, the plot for a 1024-point FFT is
shown for 8 oscillators. The x-axis shown is from 0 Hz to 5000 Hz.



0 500 1000 1500 2000 2500 3000 3500 4000 4500 5000
0
50
100
150
200
250
300
350
400
450
500
Frequency
M
a
g
n
i
t
u
d
e


1209 Hz
1336 Hz
1477 Hz
1633 Hz
697 Hz
770 Hz
852 Hz
941 Hz
The resulting spectrogram for the output given an input 005634 is shown,
highlighting the frequency components used per digit.


The spectrogram is a visual representation of a signal by plotting with respect
to time, frequency and amplitude. It is a signal in terms of the energy density spread
over frequency components and time.

The command specgram(sig,512,Fs,[]) provides the following parameters:

sig: the signal input
512: length of FFT, number of points
Fs: sampling frequency
[] (empty matrix): number of windows

In the graph shown above, the result showed 6 pair of red lines that
corresponds to the 6 DTMF tones supplied having the duration 0.75 seconds and
gap 0.5 seconds:

The first and second digit is 0 having a combination of frequencies of 1336 Hz
and 941 Hz;

The 3
rd
digit, 5, consists of 1336 Hz and 770 Hz tones;
The 4
th
digit is 6 with 1477 Hz and 770 Hz;
The 5
th
digit is 4 with 1209 Hz and 770 Hz;
The 6
th
digit is 3 with 1477 Hz and 697 Hz.

The color of the sections represents the intensity of the energy. (represented
light-to-dark, Red indicates high level amplitude while violet indicates low level
amplitude ). The 5 blue regions represent the pause or delay having no input, or zero
amplitude.


Time
F
r
e
q
u
e
n
c
y
1 2 3 4 5 6
0
500
1000
1500
2000
2500
3000
3500
4000
4500
5000

Vous aimerez peut-être aussi