You are on page 1of 18

ENTC 4337

Sine Generation
Z-Transform Table
Impulse d(n) 1

Unit Step u(n) z


z 1
Ramp nu(n) z
( z  12
Exponential an z
za
z sin( wt )
Sinusoidal sin(wnT)
z 2  2 z cos(wt )  1
z[ z  cos(wt )]
cos(wnT)
z 2  2 z cos(wt )  1
Digital Oscillator Design
Impulse
Impulse
Response
x(n)={1,0,0,...,0}
h(n)=sin(wnt)

wT  2ft
z sin( wT )
H ( z)  2 f  osc. frequency
z  2 z cos(wT )  1
T  1/ fs
Y ( z )  z 2  z sin( wT )
H ( z)   
  2  2
X ( z )  z  z  2 z cos(wT )  1

Y ( z) z 1 sin( wT )

X ( z ) 1  2 z 1 cos(wT )  z 2


Y ( z ) 1  2 z cos(wT )  z
1 2
 z 1
sin( wT ) X ( z )

y (n)  2 cos(wT ) y (n  1)  y (n  2)  sin( wT ) x(n  1)


y (n)  2 cos(wT ) y (n  1)  y (n  2)  sin( wT ) x(n  1)

Design a digital filter that generates an 800 Hz sine wave in response to an


impulse. Sampling frequency is 10,000 Hz. Test the filter by observing the
first 10 output samples. Hint: Use the Z-transform table and convert H(z) to
a difference equation.

f  800 Hz T  1 / f s  1 / 10,000 Hz  0.0001 s


w  2f  2 800 Hz  5027 rad / s
wT  (5027 rad (0.0001s   0.503 rad
y (n)  2 cos(wT ) y (n  1)  y (n  2)  sin( wT ) x(n  1)
y (n)  2 cos(0.503) y (n  1)  y (n  2)  sin( 0.503) x(n  1)

y (n)  2  0.876 y (n  1)  y (n  2)  0.482 x(n  1)

y (n)  1.753 y (n  1)  y (n  2)  0.482 x(n  1)


y (n)  1.573 y (n  1)  y (n  2)  0.482 x(n  1)
n x(n) x(n-1) y(n) y(n-1) y(n-2)
0 1 0 0 0 0
1 0 1 0.4818 0 0
2 0 0 0.8443 0.4818 0
3 0 0 0.9980 0.8443 0.4818
4 0 0 0.9048 0.9980 0.8443
5 0 0 0.5878 0.9048 0.9980
6 0 0 0.1253 0.5878 0.9048
7 0 0 -0.3681 0.1253 0.5878
8 0 0 -0.7705 -0.3681 0.1253
9 0 0 -0.9823 -0.7705 -0.3681
Types of Sequences
Impulse
function [x,n]=impseq(n0,n1,n2)
%Generates x(n)=delta(n-n0); n1<=n<=n2
%-------------------------------------
2
%[x,n]=impseq(n0,n1,n2)
% 1.8

n=[n1:n2]; x=[(n-n0)==0]; 1.6

1.4

1.2

>>[x,n]=impseq(0,-3,9); 1

>>stem(n,x); grid 0.8


>>axis([0 10 0 2])
0.6

0.4

0.2

0
-4 -2 0 2 4 6 8 10
Sinusoidal Sequence
1

0.8

» n=[0:9]; 0.6

» h=sin(0.503*n); 0.4
» stem(n,h),grid
0.2

-0.2

-0.4

-0.6

-0.8

-1
0 1 2 3 4 5 6 7 8 9
Convolution
» [x,n]=impseq(0,-3,9);
» h=sin(0.503*n);
» y=conv(x,h)

y=

Columns 1 through 7

0 0 0 -0.9981 -0.8447 -0.4821 0

Columns 8 through 14

0.4821 0.8447 0.9981 0.9042 0.5864 0.1233 -0.3704

Columns 15 through 21

-0.7723 -0.9829 0 0 0 0 0

Columns 22 through 25

0 0 0 0
yHAND={0,0.4821,0.8443,0.9980,0.9048,0.5878,0.1253,-0.3681,-0.7705,-0.9823}

yMATLAB={0,0.4821,0.8447,0.9981,0.9042,0.5864,0.1233,-0.3704,-0.7723,-0.9829}
1

0.8

0.6

0.4

0.2

-0.2

-0.4

-0.6

-0.8

-1
0 1 2 3 4 5 6 7 8 9
1

0.8

0.6

0.4

0.2

-0.2

-0.4

-0.6

-0.8

-1
-10 -5 0 5 10 15 20
y (n)  2 cos(wT ) y (n  1)  y (n  2)  sin( wT ) x(n  1)

Design a digital filter that generates an 1000 Hz sine wave in response to an


impulse. Sampling frequency is 10,000 Hz. Test the filter by observing the
first 10 output samples. Hint: Use the Z-transform table and convert H(z) to
a difference equation.

f  1000 Hz T  1 / f s  1 / 10,000 Hz  0.0001 s


w  2f  2 1000 Hz  6283 rad / s
wT  (5027 rad (0.0001s  0.6283 rad
y (n)  2 cos(wT ) y (n  1)  y (n  2)  sin( wT ) x(n  1)
y (n)  2 cos(0.628) y (n  1)  y (n  2)  sin( 0.628) x(n  1)

y (n)  2  0.579 y (n  1)  y (n  2)  0.809 x(n  1)

y (n)  1.158 y (n  1)  y (n  2)  0.809 x(n  1)


MATLAB Implementation

>> [x,n]=impseq(0,-3,25);
>> h=sin(0.628*n);
>> y=conv(x,h);
>> t=[-6:1:length(y)-7];
>> stem(t,y),grid
Note that 1 period is 10
samples and that 10 X
.0001 seconds is 1 ms, or
a frequency of 1 kHz.

You might also like