Introduction To Digital Signal Processing

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

Forth Class Electrical Dept.

Communication II Nada Nasih

Introduction to Digital Signal Processing(DSP)

Recent developments in digital computers open the way to this subject.


The general block diagram of a DSP system is shown below:

Band
limited ADC Computer DAC Smoothing
filter filter

x(t) fs x(nTs) y(nTs) y(t)

 The input signal x(t) is an analogue signal (speech, video,…). This


signal is first band limited using L.P.F. having a cut-off frequency
fmax.
 The band limited signal is then converted into digital x(nTs) using a
sampler with sampling frequency (fs ≥ 2fmax) and a quantizer.
 The discrete signal x(nTs) or simply written x(n) is entered to a
digital computer with suitable interface card (sound card, video
card, …). Inside this computer a program (high or low level and
real time or off time ) is written to perform any sort of signal
analysis to x(n) such as (linear amplification, log, exponential,
convolution, correlation, and filtering).
 The result of the digital processing is y(nT s). this signal is then
converted to analogue form using DAC, de-sampler, and finally
smoothing filter to remove the stair case shape of y(n).

General concepts in DSP:


1. Linearity :
A DSP system is called linear if superposition theory applies.
For example if y(n)=2x(n), and x(n)=x1(n)+x2(n) then the system is
linear since:
y(n)=2x(n)=2[x1(n)+x2(n)]= 2x1(n)+2x2(n)= y1(n)+y2(n) where y1(n)
and y2(n) are the outputs due to x1(n) and x2(n).

1
Forth Class Electrical Dept.
Communication II Nada Nasih

x1(n) y1(n) If y(n)= y1(n)+y2(n)


then system is linear
If y(n) # y1(n)+y2(n)
then system is not linear
x2(n) y2(n)

2. Causality:
A DSP system is said to be causal if the present value of the output is
not the function of a future value of the input.

x (n) y (n) memory-less (causal)

x (n) y (n-1) memory (causal)

x(n) y (n+1) (a causal)

3. Stability:
A DSP system is said to be stable if the output is bounded for bounded
input.
For example, if y(n)=2x(n)-0.5x(n-1), |x(n)|<G where G is finite, then
|y(n)|<2G-0.5G. hence if x(n) is bounded by G then y(n) is also
bounded i.e. the system is stable.

4. Time Variant and Time Invariant:


A system is said to be time variant if its characteristics depends on the
time index n.
For example, y(n)=n.x(n) is time variant system.

A system is said to be time invariant if its characteristics doesn't


change with time index n.
For example, y(n)=2e-x(n-1) is time invariant system.

2
Forth Class Electrical Dept.
Communication II Nada Nasih

Input/Output relations of the linear systems:

a) Analogue (continuous) systems:


If h(t) is the impulse response of the system then H(w) is the transfer
function which is the Fourier transform of h(t).

y(t)=x(t)  h(t)

where  is the convolution. x(t) h(t) y(t)


t t
y (t )   x( )h(t   )d   h( ) x(t   )d X(w)
H(w)
Y(w)
0 0

Also Y(w)=X(w).H(w) and |Y(w)|2=|X(w)|2.|H(w)|2


Or Gy(w)=Gx(w).|H(w)|2 where Gy(w) and Gx(w) are spectral densities
of x and y respectively.

Also output power y 2 (t )   | H (w) | 2 G x (w)dw


b) Discrete (digital) systems:


Here h(n) is the impulse response of the system, and H(z) is its
transfer function:

H(z)=Y(z)/X(z) x(t) h(t) y(t)


H(w)
And X(w) Y(w)

y(n)=x(n)  h(n) or
y(n)   x(k )h(n  k )  h(k ) x(n  k ) which is called the discrete
k k

convolution.

DSP systems are classified according to their responses h(n) into:

i. FIR (Finite Impulse Response): where h(n) has a finite number of


elements such as : h(n)={1,2,4,3,0,1} where the cursor ↑ indicates
the position where n=0

3
Forth Class Electrical Dept.
Communication II Nada Nasih

1 1

0
-3 -2 -1 0 1 2

ii. IIR (Infinite Impulse Response): where h(n) has infinite number
of elements such as : h(n)=(1/2)n u(n) where is the unit step
function:

u(n)= 1 for n=0,1,2,3,….


u(n)
0 else where 1 1 1 1 1 1

0 1 2 3 4 5

h(n)
1

0.5

0.25
0.125
0.0625 0.03125
0 1 2 3 4 5

Discrete convolution Methods:


1. Graphic Method:
This include the basic convolution steps :-
a. reversing in time using k as time index.
b. shifting by n samples.
c. Multiplication of the corresponding samples.
d. Adding.

4
Forth Class Electrical Dept.
Communication II Nada Nasih

Ex: find the value of y(n) using graphical method


h(n)={1,-1,2} , x(n)={2,1,-1,3}

Sol:
y(n)   x(k )h(n  k )
k

y(0)   x(k )h(0  k )  2  (1)(1)  (1)(3)  6


k

y(1)   x(k )h(1  k )  (2)(1)  (1)(3)  5


k

y(1)   x(k )h(1  k )  (2)(2)  (1)(1)  (1)(1)  2


k

And so on, shifting of h(n) (left and right) until the over lapping
between x(k) and h(n-k) disappears giving 0's at the output y(n).

x(n) 3
h(n)
2
2

1
1

-1 0 1 -2 -1 0 1

-1 -1

h(-n)
2

-1 0 1

-1

h(-1-n) h(1-n)
2
2

1 1

-2 -1 0 0 1 2

-1
-1

5
Forth Class Electrical Dept.
Communication II Nada Nasih

2. Tabular Method: this is a very simple method used for FIR


systems with finite number of samples x(n). A rectangular table
with N1 rows ( number of elements in h(n)) and N2 columns
(number elements of x(n)), or visa versa, is arranged. Then the
cross multiplications are carried out. The sum of the
multiplications diagonally will give the value of y(n).

Ex: Repeat previous example using tabular method

h(n)={1,-1,2} , x(n)={2,1,-1,3}

Sol:

2 1 -1 3
1 2 1 -1 3
-1 -2 -1 1 -3
sum
2 4 2 -2 6
y(-3)=2 sum
y(-2)=-1 sum
sum
y(-1)=2 sum
y(0)=6 sum
y(1)=-5 y(2)=6

Then y(n)={2,-1,2,6,-5,6}

Note that N=N1+N2-1= number of elements in y(n) = 3+4-1=6


And that O1 and O2 are positions of the cursors in h(n) and x(n) (from
the left), then O= O1+O2-1=2+3-1=4 which is the position of y(0).

3. Add-overlap Method:
This is a modified method from the tabular method, when either h(n)
and x(n) has large number of elements, then this can be divided into
sub-segments of smaller length.

6
Forth Class Electrical Dept.
Communication II Nada Nasih

Ex: find the discrete convolution between:


h(n)={1,-1,2} , x(n)={1,2,-1,3,4,-1,0,3}

Sol:
Here x(n) is divided into three segments, first two segments of
length 3, and last segment of length 2.
Hence previous tabular method will be repeated 3 times.
1 -1 2
1 1 -1 2

y1(n)={1,1,-1,5,-2} 2 2 -2 4
-1 -1 1 -2

1 -1 2
3 3 -3 6

y2(n)={3,1,1,9,-2} 4 4 -4 8
-1 -1 1 -2

1 -1 2
0 0 0 0

y3(n)={0,3,-3,6} 3 3 -3 6

Then, add y1, y2, and y3, with y2 shifted to the left by 3 elements (length
of each segment) and y3 shifted to the left by 6 elements:

y1 1 1 -1 5 -2
y2 3 1 1 9 -2
y3 0 3 -3 6
y(n) 1 1 -1 8 -1 1 9 1 -3 6

y(n)={1,1,-1,8,-1,1,9,1,-3,6}

with the cursor for y(n) at O=2+4-1=5

7
Forth Class Electrical Dept.
Communication II Nada Nasih

4. Matrix Method:
Here, [Y]=[A][h], where [y(n)]=output, [h]=[h(n)] and the [A] matrix
has N=N1+N2-1 rows and N2 columns (number of elements of h(n)).
The 1st row in [A] is the 1st element in x(n) (from the left) and the
remaining elements are 0's. the 2nd row in [A] is the 2nd element in
x(n), then the 1st element in x(n) and the remaining elements are 0's.
and so on until the last element in x(n) is entered at the N 1th row (N1 is
the number of elements in x(n)). After that 0's are applied instead of
the elements of x(n) until the last row at N=N1+N2-1.

Ex: find the value of y(n) using matrix method


h(n)={1,-1,2} , x(n)={2,1,-1,3}

Sol:

2 0 0
1 2 0 
1 
 1 1 2
[h]   1 [ A]   
 2   3 1 1 
0 3  1
 
 0 0 3 

2 0 0 2
1 2 0    1
 1  
 1 1 2    2 
then [Y ]     1   
 3 1 1  2   6 
0 3  1    5
   
 0 0 3   6 

Then y(n)={2,-1,2,6,-5,6} where O=2+2-1=3.

5. the Z-transform Method:


This is a general method used either or both of h(n) and x(n) has
infinite elements. The procedure here is to take the z-transform of x(n)
and h(n), then multiply to find Y(z) from which y(n) is found using
inverse z-transform.

8
Forth Class Electrical Dept.
Communication II Nada Nasih

Ex: find the value of y(n) where:


h(n)={1,-1,2} , x(n)=(1/2)n u(n)

Sol:
Note, since x(n) has infinite number of elements, then we must use
z-transform method.
Now, taking the z-transform of both h(n) and x(n):
1
H ( z)   h( n) z
n  1
n
 1.z 1  (1).z 0  2.z 1  z  1  2 z 1
  
X ( z)   x(n) z n   (0.5) n z n   (0.5z 1 ) n
n   n 0 n 0
1 z
X ( z)  1

1  0.5 z z  0.5

Then Y(z)=H(z).X(z)=[z-1+2z-1].[z/(z-0.5)]
z.z z 2
  
z  0.5 z  0.5 z  0.5

And y(n)=(0.5)n+1u(n+1)-(0.5)nu(n)+2(0.5)n-1u(n-1)

Ex: Find 1.  (n  a)   (n  b) 2.  (n  a)  u(n  b)


3. u(n  a)  u(n  b) using the z-transform where a and b are
constants.
Sol:
a. [ (n  a)]  z  a and [ (n  b)]  z ,then: b

Z 1[ z  a z b ]  Z 1[ z ( ab) ]   (n  (a  b))


Hence:  (n  a)   (n  b) =  (n  (a  b))

b. [ (n  a)]  z  a and z  b .z ,then:


[u (n  b)] 
z 1
z z
Z 1[ z a z b .
]  Z 1[ z ( a b ) . ]  u (n  (a  b))
z 1 z 1
Hence:  (n  a)  u(n  b) = u(n  (a  b))

c. z  a .z and z  b .z
[u (n  a)]  [u (n  b)] 
z 1 z 1

z b z z
Z 1[ z a z . ]  Z 1[ z ( a b1) . ]  (n  (a  b))u (n  (a  b  1))
z 1 z 1 ( z  1) 2

9
Forth Class Electrical Dept.
Communication II Nada Nasih

Discrete Deconvolution:
To find h(n) if both x(n) and y(n) are given, we use the z-transform
method since it is valid for both FIR and IIR DSP system.
H(n)=Z-1[H(z)]=Z-1[Y(z)/X(z)]

Ex: Find h(n) if x(n)={1,-1,3} and y(n)={2,3,-1,17,-6}

Sol:
X(z)=1-z-1+3z-2 and Y(z)=2+3z-1-z-2 +17z-3-6z-4 then we use the long
division

2+5z-1-2z-2
1-z-1+3z-2 2+3z-1- z-2 +17z-3-6z-4
2-2z-1+6z-2
5z-1-7z-2 +17z-3-6z-4
5z-1-5z-2 +15z-3
-2z-2 +2 z-3 -6z-4
-2z-2 +2 z-3 -6z-4
0 0 0

Hence H(z)= 2+5z-1-2z-2 or h(n)={2,5,-2} and there is no reminder, then


the system is FIR.

Ex: Find h(n) if x(n)=u(n) and y(n)=2u(n)-(0.5)nu(n).

Sol:
z 2.z z
X ( z)  and Y ( z )  
z 1 z  1 z  0.5
2z z

z 1 2z  1  z  1
Then H(z)= z  1 z  0.5  2 
z
 
z z  0.5 z  0.5 z  0.5
z 1

By taking the inverse z-transform we get :


h(n)=(0.5)nu(n)

10
Forth Class Electrical Dept.
Communication II Nada Nasih

DSP System Implementations:

a. FIR systems:
Here h(n) has finite number of elements:
h(n)={h(0), h(1), h(2), ……. h(m)} with (m+1) elements.
H(z)= h(0)+h(1)z-1+ h(2) z-2, ……. h(m) z-m and if:
H(z)=Y(z)/X(z), then:
y(n)= h(0)x(n)+ h(1)x(n-1)+ h(2)x(n-2) ……. h(m)x(n-m)

i.e., y(n) is obtained from x(n) by the weighted sum (weighted by


h(n)) of the delayed samples of x(n). these delayed samples of x(n) are
obtained using a tapped delay line with m-taps and with Ts time delay
per tap.

x(n)
Z-1 Z-1 Z-1 ---- ---- ---- ---- Z-1

Z-1≡Ts
h(0) h(1)
h(m
)

Ʃ y(n)

Note that the FIR system is always stable, where the system is open
loop without feed back and that is why it is called non-recursive.

11
Forth Class Electrical Dept.
Communication II Nada Nasih

b. IIR systems:
For IIR system having m-zeros and r-poles, then:
Y ( z ) a0  a1 z 1  a 2 z 2  ........  a m z  m
H ( z)  
X ( z) 1  b1 z 1  b2 z 2  ........  br z r

Where we can always set the first term at the denominator to unity by
dividing with a suitable constant(b0).
Fro which :
y(n)= a0x(n)+ a1x(n-1)+a 2x(n-2)+ … + amx(n-m)- b1y(n-1)-b2y(n-2)-
… -bry(n-r)

Note that y(n) depends on present and previous values of x and


previous values of y. Hence:
 IIR system contains a feedback from the output to the input.
 possibility of instability if some poles of H(z) lies outside the unit
circle.
 to implement the IIR system, then 2 tapped delay lines are
required, one with m-taps for the x input and the other with r-taps
for the feedback from the y output.

x(n)
a0
Ʃ y(n)

Z-1 a1 b1 Z-1

Z-1 Z-1

Z-1 Z-1

Z-1 Z-1

Z-1 Z-1

Z-1 am br Z-1

12
Forth Class Electrical Dept.
Communication II Nada Nasih

Ex: implement the DSP system:


4  2 z 2
H ( z) 
2  3z 1  z  2  z 3

Sol:
This is an IIR system. First we divide by 2 to set the first term at the
dominator to unity, then:

2  1z 2
H ( z) 
1  1.5 z 1  0.5 z 2  0.5 z 3

This needs a tapped delay line with 2 taps for x and a tapped delay line
with 3 taps for y.

x(n)
2
Ʃ y(n)

Z-1 1.5
Z-1

Z-1 -1 -0.5 Z-1

0.5 Z-1

13

You might also like