You are on page 1of 26

Sampling and Reconstruction

of Analog Signals

Lecture 5
Sampling and reconstruction of analog
signals
Analogy signals can be converted into discrete signals using
sampling and quantization operations: analogy-to-digital
conversion, or ADC
Digital signals can be converted into analog signals using a
reconstruction operation: digital-to-analogy conversion, or DAC
Using Fourier analysis, we can describe the sampling operation
from the frequency-domain view-point, analyze its effects and then
address the reconstruction operation.
We will also assume that the number of quantization levels is
sufficiently large that the effect of quantization on discrete signals
is negligible.
Sampling
Continuous-time Fourier transform and inverse CTFT

+
X a ( j) = xa (t )e jt dt
1 +
a
jt
xa (t ) = X ( j ) e d
2

1. Absolutely integrable
2. Omega is an analogy frequency in radians/sec
Sampling
Sample xa(t) at sampling interval Ts sec apart to obtain the discrete-
time signal x(n)

x(n) = xa (nTs )

Let X(ej) be discrete-time Fourier transform of x(n).

X(ej) is a countable sum of amplitude-scaled, frequency-scaled,


and translated version of the Fourier transform Xa(j)

1 + 2
j
X (e ) = X a j l
Ts l = Ts Ts

This is known as the aliasing formula


The analog and digital frequencies

w = Ts
1
Fs = Fs: the sampling frequency, sam/sec
Ts

Amplitude scaled factor: 1/Ts;


Frequency-scaled factor: =Ts (=0~2)
Frequency-translated factor: 2k/Ts;
1 + 2
j
X (e ) = X a j l
Ts l = Ts Ts
The discrete signal is an aliased
version of the corresponding
analog signal

It is possible to recover Xa(j)


from X(ej), or xa(t) from x(n)
if the infinite replicas of Xa(j)
do not overlap with each other
to form X(ejw).

This is true for band-limited


analog signals.
1 + 2
j
X (e ) = X a j l
Ts l = Ts Ts

Suppose signal band is


limited to 0,
If Ts is small, 0Ts<, or
F0= 0/2 < Fs/2=1/2Ts
Then the freq. Resp. of x(t)
is an infinite replica series
of its analog signal xa(t),
If Ts is large, 0Ts>, or
F0= 0/2 > Fs/2=1/2Ts
Then the freq. Resp. of x(t)
is a overlaped replica of its
analog signal xa(t), so
cannot be reconstructed
Ban-limited signal
A signal is band-limited if there exists a finite radians frequency 0
such that Xa(j ) is zero for | |> 0.
The frequency F0= 0 /2pi is called the signal bandwidth in Hz

Referring to this picture, if pi> 0Ts, then

1 w w
X (e ) = X a j ; <
jw

Ts Ts Ts Ts Ts
Sampling Principle
A band-limited signal xa(t) with bandwidth F0 can be
reconstructed from its sample values x(n)=xa(nTs) if the
sampling frequency Fs=1/Ts is greater than twice the
bandwidth F0 of xa(t) ,
Fs >2 F0.

Otherwise aliasing would result in x(n). The sampling rate of 2


F0 for an analog band-limited signal is called the Nyquist rate.

After xa(t) is sampled, the highest anal og frequency that x(n)


represents is Fs/2 Hz (or = )
MATLAB implementation

Let t be the grid interval such that t <= Ts


xG (m) = xa (mt )

Can be used as an array to simulate an analog signal


The Fourier transform relation should also be approximated:

X a ( j) xG (m)e jmt t =t xG (m)e jmt


m m
Example 1
Let xa(t)=e-1000|t|
0
0.002
x (t )e dt = e dt + e dt =
jt 1000 t jt 1000 t jt
X a ( j ) = e e

a 2

0 1+
1000

To evaluate Xa(j) numerically, we have to approximate xa(t) by a


finite duration grid sequence xG(m)
Using the approximation e-5=0, xa(t) can be approximate by a finite
duration signal over -0.005 <= t <= 0.005
Xa(j) = 0 for >= 2(2000)
Hence, choosing
1
5
t = 5 10 = 25 10 5
2(2000)
We can obtain xG(m) and then implement in MATLAB
Dt = 0.00005; A n a lo g S ig n a l
1

t = -0.005:Dt:0.005;

xa(t)
0.5
xa = exp(-1000*abs(t));

% Continuous-time Fourier Transform


0
-5 -4 -3 -2 -1 0 1 2 3 4 5
t in m s e c .
Wmax = 2*pi*2000; C o n t in u o u s -t im e F o u rie r Tra n s fo rm
2

K = 500; k = 0:1:K; 1.5

Xa(jW)*1000
1
W = k*Wmax/K;
0.5

Xa = xa * exp(-j*t'*W) * Dt; 0
-2 -1 . 5 -1 -0 . 5 0 0.5 1 1.5 2
F re q u e n c y in K H z
Xa = real(Xa);

W = [-fliplr(W), W(2:501)]; % Omega from -Wmax to Wmax

Xa = [fliplr(Xa), Xa(2:501)];
To reduce the number of computation
subplot(1,1,1)
we compute Xa(j) over [0,4000] rad/sec
subplot(2,1,1);plot(t*1000,xa); then duplicate it over [-4000,0] for plotting
xlabel('t in msec.'); ylabel('xa(t)')
purpose

title('Analog Signal')

subplot(2,1,2);plot(W/(2*pi*1000),Xa*1000);

xlabel('Frequency in KHz'); ylabel('Xa(jW)*1000')

title('Continuous-time Fourier Transform')


Example 2a
Sample xa(t) in example 1 at Fs = 5000 sam/sec to obtain x1(n)
Nyquist rate is 4000 sam/sec. Fs = 5000 > 4000
No aliasing Discrete Signal
1
% Analog Signal
Dt = 0.00005;
t = -0.005:Dt:0.005;

xa(t)
xa = exp(-1000*abs(t)); 0.5
% Discrete-time Signal
Ts = 0.0002; n = -25:1:25;
x = exp(-1000*abs(n*Ts));
0
% Discrete-time Fourier transform -5 -4 -3 -2 -1 0 1 2 3 4 5
K = 500; k = 0:1:K; t in msec.
w = pi*k/K; Discrete-time Fourier Transform
10
X = x * exp(-j*n'*w);
X = real(X);
w = [-fliplr(w), w(2:K+1)];
X = [fliplr(X), X(2:K+1)]; X(w)
5
subplot(1,1,1)
subplot(2,1,1);plot(t*1000,xa);
xlabel('t in msec.'); ylabel('xa(t)') 0
title('Discrete Signal'); hold on -1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
Frequency in pi units
stem(n*Ts*1000,x); hold off
subplot(2,1,2);plot(w/pi,X);
xlabel('Frequency in pi units'); ylabel('X(w)')
title('Discrete-time Fourier Transform')
Example 2b
Sample xa(t) in example 1 at Fs = 1000 sam/sec to obtain x1(n)
Nyquist rate is 4000 sam/sec. Fs = 1000 < 4000
Some aliasing Discrete Signal
1

% Analog Signal
Dt = 0.00005;

xa(t)
t = -0.005:Dt:0.005; 0.5
xa = exp(-1000*abs(t));
% Discrete-time Signal
Ts = 0.001; n = -5:1:5; 0
x = exp(-1000*abs(n*Ts)); -5 -4 -3 -2 -1 0 1 2 3 4 5
% Discrete-time Fourier transform t in msec.
Discrete-time Fourier Transform
K = 500; k = 0:1:K; 3
w = pi*k/K;
X = x * exp(-j*n'*w);
2
X = real(X);
w = [-fliplr(w), w(2:K+1)]; X(w)
X = [fliplr(X), X(2:K+1)]; 1
subplot(1,1,1)
subplot(2,1,1);plot(t*1000,xa); 0
xlabel('t in msec.'); ylabel('xa(t)') -1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
Frequency in pi units
title('Discrete Signal'); hold on
stem(n*Ts*1000,x); hold off
subplot(2,1,2);plot(w/pi,X);
xlabel('Frequency in pi units'); ylabel('X(w)') Shape of X(ej) is different from Xa(j)
title('Discrete-time Fourier Transform')
Result of adding overlapping replicas
Reconstruction

Impulse train Ideal lowpass xa (t )


x(n) conversion filter
+
x(n) (t nTs ) = L + x(1) (t + Ts ) + x(0) (t ) + x(1) (t Ts ) + L
n =
+
xa (t ) = x(n)sinc[ Fs (t nTs )] Interpolating formula
n =

sinc(x) = sin(x)/x
Lowpass filter band-limited to the [-Fs/2,Fs/2] band
The ideal interpolation is not practically feasible because the entire
system is noncausal and hence not realizable.
Reconstruction of band-limited signal
Practical D/A converters
Zero-order-hold (ZOH) interpolation:
In this interpolation a given sample value is held for the
sample interval until the next sample is received.
It can be obtained by filtering the impulse train through an
interpolating filter of the form

x a (t ) = x(n), nTs n (n + 1)Ts


1 0 t Ts
h0 (t ) =
0 otherwise
The resulting signal is a piecewise-constant (staircase) waveform which
requires an appropriately designed analog post-filter for accurate
waveform reconstruction.

x(n) ZOH xa (t ) Post-Filter xa (t )


First-order-hold (FOH) interpolation

In this case the adjacent samples are joined


by straight lines.
t
1 + T 0 t Ts
s
t
h1 (t ) = 1 Ts t 2Ts
Ts
0 otherwise

Cubic-order-hold (COH) interpolation

This approach uses spline interpolation for a smoother, but not


necessarily more accurate, estimate of the analog signal between
samples.
Hence this interpolation does not require an analog post-filter
The smoother reconstruction is obtained by using a set of
piecewise continuous third-order polynomials called cubic splines

xa (t ) = 0 (n) + 1 (n)(t nTs ) + 2 (n)(t nTs ) 2 + 3 (n)(t nTs ) 3 ,


nTs t (n + 1)Ts

Where {i(n), 0 <= i <= 3} are polynomial coefficients determined


by using least squares analysis on the sample values
Matlab Implementation
sinc function which generates the sin(x)/x can be use to
implement interpolation
+
xa (t ) = x(n)sinc[ Fs (t nTs )]
n =

If {x(n), n1 <= n <= n2} is given, to interpolate xa(t) with grid


interval t
n2
xa (mt ) = x(n)sinc[ Fs (mt nTs )], t1 mt t 2
n = n1

N=n1:n2; t=t1:t2; Fs=1/Ts; nTs = n*Ts


Xa = x*sinc(Fs*(ones(length(n),1)*t- nTs*ones(1,length(t))))
Example 3
From the sample x(n) in example 2a, reconstruct xa(t)
x(n) was obtained by sampling xa(t) at Ts = 1/Fs = 0.0002 sec.
We will use the grid spacing 0.00005 sec over -0.005 <= t <= 0.005,
which gives x(n) over -25 <= n <= 25
Ts = 0.0002; Fs = 1/Ts; n = -25:1:25; nTs = n*Ts;
x = exp(-1000*abs(nTs));

% Analog Signal reconstruction


Dt = 0.00005;
t = -0.005:Dt:0.005;
xa = x * sinc(Fs*(ones(length(nTs),1)*t-nTs'*ones(1,length(t))));
R e c o n s t r u c t e d S i g n a l fr o m x 1 ( n ) u s i n g s i n c fu n c t i o n
1
% check
error = max(abs(xa - exp(-1000*abs(t)))) 0.9

0.8
% Plots
0.7
plot(t*1000,xa);
0.6
xlabel('t in msec.'); ylabel('xa(t)')
xa(t)

stem(n*Ts*1000,x); hold off 0.5

0.4
error =
0.3

0.2
0.0363
0.1

0
-5 -4 -3 -2 -1 0 1 2 3 4 5
t in m s e c .
Example 4
From the sample x(n) in example 2b, reconstruct xa(t)
x(n) was obtained by sampling xa(t) at Ts = 1/Fs = 0.001 sec.
We will use the grid spacing 0.00005 sec over -0.005 <= t <= 0.005,
which gives x(n) over -5 <= n <= 5
Ts = 0.001; Fs = 1/Ts; n = -5:1:5; nTs = n*Ts;
x = exp(-1000*abs(nTs));

% Analog Signal reconstruction


Dt = 0.00005;
t = -0.005:Dt:0.005;
xa = x * sinc(Fs*(ones(length(nTs),1)*t-nTs'*ones(1,length(t))));

% check R e c o n s t r u c t e d S i g n a l fr o m x 2 ( n ) u s i n g s i n c fu n c t i o n
error = max(abs(xa - exp(-1000*abs(t)))) 1 .2

1
% Plots
plot(t*1000,xa); 0 .8

xlabel('t in msec.'); ylabel('xa(t)')


0 .6
stem(n*Ts*1000,x); hold off
xa(t)

0 .4
error =
0 .2

0.1852
0

-0 . 2
-5 -4 -3 -2 -1 0 1 2 3 4 5
t in m s e c .
Example 5a

Reconstruct signal from the samples in example 2 using ZOH


interpolation
It is a crude one and the further processing of analog signal is
neccessary

R e c o n s t ru c t e d S ig n a l fro m x 1 (n ) u s in g z e ro -o rd e r-h o ld
1

0.9
Ts = 0.0002; n = -25:1:25; nTs = n*Ts; 0.8

0.7
x = exp(-1000*abs(nTs));
0.6
% Analog Signal reconstruction using stairs
xa(t)

0.5

0.4
stairs(nTs*1000,x);
0.3
xlabel('t in msec.'); ylabel('xa(t)') 0.2

0.1
stem(n*Ts*1000,x); hold off
0
-5 -4 -3 -2 -1 0 1 2 3 4 5
t in m s e c .
Example 5a
Reconstruct signal from the samples in example 2 using FOH
interpolation
It appears to be good but a carefully observation near t=0
reveals that the peak is not carefully reproduce
In general, if the sampling frequency is much higher than the
Nyquist rate, FOH provides acceptable reconstruction

R e c o n s t ru c t e d S ig n a l fro m x 1 (n ) u s in g firs t -o rd e r-h o ld


1

Ts = 0.0002; n = -25:1:25; nTs = n*Ts; 0.9

0.8
x = exp(-1000*abs(nTs));
0.7

% Analog Signal reconstruction using plots 0.6


xa(t)

0.5
plot(nTs*1000,x);
0.4

xlabel('t in msec.'); ylabel('xa(t)') 0.3

0.2

stem(n*Ts*1000,x); hold off 0.1

0
-5 -4 -3 -2 -1 0 1 2 3 4 5
t in m s e c .
Example 6a
Reconstruct the sample in example 2a using spline function
Maximum error is lower due to nonideal interpolation and the
fact that xa(t) is nonband-limited
The ideal interpolation suffers more from time-limitedness
The plot is excellent
Ts = 0.0002; n = -25:1:25; nTs = n*Ts;
x = exp(-1000*abs(nTs));
R ec ons truc ted S ignal from x 1(n) us ing c ubic s pline func tion
% Analog Signal reconstruction 1

Dt = 0.00005; 0.9
t = -0.005:Dt:0.005;
0.8
xa = spline(nTs,x,t);
0.7
plot(t*1000,xa);
0.6
xa(t)

xlabel('t in msec.'); ylabel('xa(t)') 0.5

stem(n*Ts*1000,x); hold off 0.4


% check 0.3
error = max(abs(xa - exp(-1000*abs(t))))
0.2

error = 0.1

0
-5 -4 -3 -2 -1 0 1 2 3 4 5
0.0317 t in m s ec .
Example 6b
Reconstruct the sample in example 2b using spline function
Maximum error is high and cannot be attributed to the
nonideal interpolation or nonband-limitedness of xa(t)
The reconstructed signal differs from the actual one

Reconstructed Signal from x2(n) using cubic spline function


Ts = 0.001; n = -5:1:5; nTs = n*Ts; 1
x = exp(-1000*abs(nTs));
0.9

% Analog Signal reconstruction 0.8


Dt = 0.00005;
0.7
t = -0.005:Dt:0.005;
xa = spline(nTs,x,t); 0.6
% check xa(t) 0.5
error = max(abs(xa - exp(-1000*abs(t))))
% Plots 0.4

plot(t*1000,xa); 0.3
xlabel('t in msec.'); ylabel('xa(t)')
stem(n*Ts*1000,x); hold off 0.2

error = 0.1

0
0.1679 -5 -4 -3 -2 -1 0 1 2 3 4 5
t in msec.

You might also like