Sampling and Reconstruction of Analog Signals
Sampling and Reconstruction of Analog Signals
Sampling and Reconstruction of Analog Signals
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>Sampling</strong> <strong>and</strong> <strong>Reconstruction</strong><br />
<strong>of</strong> <strong>Analog</strong> <strong>Signals</strong><br />
Lecture 5
<strong>Sampling</strong> <strong>and</strong> reconstruction <strong>of</strong> analog<br />
signals<br />
• <strong>Analog</strong>y signals can be converted into discrete signals using<br />
sampling <strong>and</strong> quantization operations: analogy-to-digital<br />
conversion, or ADC<br />
• Digital signals can be converted into analog signals using a<br />
reconstruction operation: digital-to-analogy conversion, or DAC<br />
• Using Fourier analysis, we can describe the sampling operation<br />
from the frequency-domain view-point, analyze its effects <strong>and</strong> then<br />
address the reconstruction operation.<br />
• We will also assume that the number <strong>of</strong> quantization levels is<br />
sufficiently large that the effect <strong>of</strong> quantization on discrete signals<br />
is negligible.
<strong>Sampling</strong><br />
Continuous-time Fourier transform <strong>and</strong> inverse CTFT<br />
X<br />
x<br />
a<br />
a<br />
( jΩ)<br />
=<br />
( t)<br />
=<br />
1<br />
2π<br />
∫<br />
∫<br />
+∞<br />
−∞<br />
+∞<br />
−∞<br />
x<br />
a<br />
X<br />
( t)<br />
e<br />
a<br />
− jΩt<br />
( jΩ)<br />
e<br />
dt<br />
jΩt<br />
dΩ<br />
1. Absolutely integrable<br />
2. Omega is an analogy frequency in radians/sec
<strong>Sampling</strong><br />
• Sample x a (t) at sampling interval T s sec apart to obtain the discretetime<br />
signal x(n)<br />
x ( n ) = x a<br />
( nT s<br />
)<br />
• Let X(e jω ) be discrete-time Fourier transform <strong>of</strong> x(n).<br />
• X(e jω ) is a countable sum <strong>of</strong> amplitude-scaled, frequency-scaled,<br />
<strong>and</strong> translated version <strong>of</strong> the Fourier transform X a (jΩ)<br />
X ( e<br />
⎡<br />
⎢<br />
⎣<br />
jω 1<br />
+ ∞ ω 2<br />
) = ∑ X<br />
⎜<br />
a<br />
j −<br />
Ts<br />
l=<br />
−∞ Ts<br />
Ts<br />
⎛<br />
⎝<br />
π ⎞⎤<br />
l<br />
⎟⎥<br />
⎠⎦<br />
This is known as the aliasing formula
The analog <strong>and</strong> digital frequencies<br />
w = ΩT<br />
F<br />
s<br />
=<br />
1<br />
T<br />
s<br />
s<br />
F s : the sampling frequency, sam/sec<br />
–Amplitude scaled factor: 1/T s ;<br />
–Frequency-scaled factor: ω=ΩT s (ω=0~2π)<br />
–Frequency-translated factor: 2πk/T s ;
X<br />
( e<br />
⎡<br />
⎢<br />
⎣<br />
jω 1<br />
+ ∞ ω 2<br />
) = ∑ X<br />
⎜<br />
a<br />
j −<br />
Ts<br />
l=<br />
−∞ Ts<br />
Ts<br />
⎛<br />
⎝<br />
π ⎞⎤<br />
l<br />
⎟⎥<br />
⎠⎦<br />
The discrete signal is an aliased<br />
version <strong>of</strong> the corresponding<br />
analog signal<br />
It is possible to recover X a<br />
(jΩ)<br />
from X(e jω ), or x a<br />
(t) from x(n)<br />
if the infinite replicas <strong>of</strong> X a<br />
(jΩ)<br />
do not overlap with each other<br />
to form X(ejw).<br />
This is true for b<strong>and</strong>-limited<br />
analog signals.
X ( e<br />
⎡<br />
⎢<br />
⎣<br />
jω 1<br />
+ ∞ ω 2<br />
) = ∑ X<br />
⎜<br />
a<br />
j −<br />
Ts<br />
l=<br />
−∞ Ts<br />
Ts<br />
⎛<br />
⎝<br />
π ⎞⎤<br />
l<br />
⎟⎥<br />
⎠⎦<br />
• Suppose signal b<strong>and</strong> is<br />
limited to ±Ώ 0 ,<br />
• If T s is small, Ώ 0 T s π, or<br />
<br />
<br />
F 0<br />
= Ώ 0<br />
/2 π > Fs/2=1/2T s<br />
Then the freq. Resp. <strong>of</strong> x(t)<br />
is a overlaped replica <strong>of</strong> its<br />
analog signal x a<br />
(t), so<br />
cannot be reconstructed
Ban-limited signal<br />
• A signal is b<strong>and</strong>-limited if there exists a finite radians frequency Ώ 0<br />
such that X a (j Ώ) is zero for | Ώ |> Ώ 0 .<br />
<br />
<br />
The frequency F 0<br />
= Ώ 0 /2pi is called the signal b<strong>and</strong>width in Hz<br />
Referring to this picture, if pi> Ώ 0 T s<br />
, then<br />
X ( e<br />
jw<br />
)<br />
1 ⎛ w ⎞<br />
= X<br />
a<br />
j<br />
T<br />
⎜<br />
s<br />
T<br />
⎟;<br />
⎝ s ⎠<br />
−<br />
π<br />
<<br />
T<br />
s<br />
w<br />
T<br />
s<br />
≤<br />
π<br />
T<br />
s
<strong>Sampling</strong> Principle<br />
• A b<strong>and</strong>-limited signal x a (t) with b<strong>and</strong>width F 0 can be<br />
reconstructed from its sample values x(n)=x a (nT s ) if the<br />
sampling frequency F s =1/T s is greater than twice the<br />
b<strong>and</strong>width F 0 <strong>of</strong> x a (t) ,<br />
F s >2 F 0 .<br />
• Otherwise aliasing would result in x(n). The sampling rate <strong>of</strong> 2<br />
F 0 for an analog b<strong>and</strong>-limited signal is called the Nyquist rate.<br />
• After xa(t) is sampled, the highest anal og frequency that x(n)<br />
represents is Fs/2 Hz (or ω = π)
MATLAB implementation<br />
• Let Δt be the grid interval such that Δt
Example 1<br />
• Let x a (t)=e -1000|t|<br />
X<br />
∞<br />
0<br />
∞<br />
− jΩt<br />
1000t<br />
− jΩt<br />
−1000t<br />
− jΩt<br />
( jΩ)<br />
= ∫ xa<br />
( t)<br />
e dt = ∫ e e dt + ∫ e e dt<br />
−∞<br />
−∞<br />
0<br />
0.002<br />
=<br />
⎛ Ω ⎞<br />
1+<br />
⎜ ⎟<br />
⎝1000<br />
⎠<br />
a<br />
2<br />
• To evaluate X a (jΩ) numerically, we have to approximate x a (t) by a<br />
finite duration grid sequence x G (m)<br />
• Using the approximation e-5=0, x a (t) can be approximate by a finite<br />
duration signal over -0.005
Dt = 0.00005;<br />
t = -0.005:Dt:0.005;<br />
1<br />
<strong>Analog</strong> Signal<br />
xa = exp(-1000*abs(t));<br />
xa(t)<br />
0.5<br />
% Continuous-time Fourier Transform<br />
Wmax = 2*pi*2000;<br />
K = 500; k = 0:1:K;<br />
W = k*Wmax/K;<br />
Xa = xa * exp(-j*t'*W) * Dt;<br />
Xa = real(Xa);<br />
Xa(jW)*1000<br />
0<br />
-5 -4 -3 -2 -1 0 1 2 3 4 5<br />
t in m sec.<br />
Continuous-time Fourier Transform<br />
2<br />
1.5<br />
1<br />
0.5<br />
0<br />
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2<br />
Frequency in KHz<br />
W = [-fliplr(W), W(2:501)]; % Omega from -Wmax to Wmax<br />
Xa = [fliplr(Xa), Xa(2:501)];<br />
subplot(1,1,1)<br />
subplot(2,1,1);plot(t*1000,xa);<br />
xlabel('t in msec.'); ylabel('xa(t)')<br />
To reduce the number <strong>of</strong> computation<br />
we compute X a<br />
(jΩ) over [0,4000π] rad/sec<br />
then duplicate it over [-4000π,0] for plotting<br />
purpose<br />
title('<strong>Analog</strong> Signal')<br />
subplot(2,1,2);plot(W/(2*pi*1000),Xa*1000);<br />
xlabel('Frequency in KHz'); ylabel('Xa(jW)*1000')<br />
title('Continuous-time Fourier Transform')
Example 2a<br />
• Sample x a (t) in example 1 at F s = 5000 sam/sec to obtain x 1 (n)<br />
• Nyquist rate is 4000 sam/sec. F s = 5000 > 4000<br />
• No aliasing<br />
% <strong>Analog</strong> Signal<br />
Dt = 0.00005;<br />
t = -0.005:Dt:0.005;<br />
xa = exp(-1000*abs(t));<br />
% Discrete-time Signal<br />
Ts = 0.0002; n = -25:1:25;<br />
x = exp(-1000*abs(n*Ts));<br />
% Discrete-time Fourier transform<br />
K = 500; k = 0:1:K;<br />
w = pi*k/K;<br />
X = x * exp(-j*n'*w);<br />
X = real(X);<br />
w = [-fliplr(w), w(2:K+1)];<br />
X = [fliplr(X), X(2:K+1)];<br />
subplot(1,1,1)<br />
subplot(2,1,1);plot(t*1000,xa);<br />
xlabel('t in msec.'); ylabel('xa(t)')<br />
title('Discrete Signal'); hold on<br />
stem(n*Ts*1000,x); hold <strong>of</strong>f<br />
subplot(2,1,2);plot(w/pi,X);<br />
xlabel('Frequency in pi units'); ylabel('X(w)')<br />
title('Discrete-time Fourier Transform')<br />
xa(t)<br />
X(w)<br />
1<br />
0.5<br />
Discrete Signal<br />
0<br />
-5 -4 -3 -2 -1 0 1 2 3 4 5<br />
t in msec.<br />
Discrete-time Fourier Transform<br />
10<br />
5<br />
0<br />
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1<br />
Frequency in pi units
Example 2b<br />
• Sample x a (t) in example 1 at F s = 1000 sam/sec to obtain x 1 (n)<br />
• Nyquist rate is 4000 sam/sec. F s = 1000 < 4000<br />
• Some aliasing<br />
% <strong>Analog</strong> Signal<br />
Dt = 0.00005;<br />
t = -0.005:Dt:0.005;<br />
xa = exp(-1000*abs(t));<br />
% Discrete-time Signal<br />
Ts = 0.001; n = -5:1:5;<br />
x = exp(-1000*abs(n*Ts));<br />
% Discrete-time Fourier transform<br />
K = 500; k = 0:1:K;<br />
w = pi*k/K;<br />
X = x * exp(-j*n'*w);<br />
X = real(X);<br />
w = [-fliplr(w), w(2:K+1)];<br />
X = [fliplr(X), X(2:K+1)];<br />
subplot(1,1,1)<br />
subplot(2,1,1);plot(t*1000,xa);<br />
xlabel('t in msec.'); ylabel('xa(t)')<br />
title('Discrete Signal'); hold on<br />
stem(n*Ts*1000,x); hold <strong>of</strong>f<br />
subplot(2,1,2);plot(w/pi,X);<br />
xlabel('Frequency in pi units'); ylabel('X(w)')<br />
title('Discrete-time Fourier Transform')<br />
xa(t)<br />
X(w)<br />
1<br />
0.5<br />
Discrete Signal<br />
0<br />
-5 -4 -3 -2 -1 0 1 2 3 4 5<br />
t in msec.<br />
Discrete-time Fourier Transform<br />
3<br />
2<br />
1<br />
0<br />
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1<br />
Frequency in pi units<br />
Shape <strong>of</strong> X(e jω ) is different from X a<br />
(jΩ)<br />
Result <strong>of</strong> adding overlapping replicas
<strong>Reconstruction</strong><br />
Impulse train<br />
conversion<br />
Ideal lowpass<br />
filter<br />
x (n)<br />
(t)<br />
x a<br />
L<br />
∑ +∞<br />
n=<br />
−∞<br />
x( n)<br />
δ ( t − nTs<br />
) = L + x(<br />
−1)<br />
δ ( t + Ts<br />
) + x(0)<br />
δ ( t)<br />
+ x(1)<br />
δ ( t −Ts<br />
) +<br />
∑ +∞<br />
n=<br />
−∞<br />
x ( t)<br />
= x(<br />
n)sinc[<br />
F ( t − nT )]<br />
a<br />
s<br />
s<br />
Interpolating formula<br />
sinc(x) = sin(πx)/πx<br />
Lowpass filter b<strong>and</strong>-limited to the [-Fs/2,Fs/2] b<strong>and</strong><br />
The ideal interpolation is not practically feasible because the entire<br />
system is noncausal <strong>and</strong> hence not realizable.
<strong>Reconstruction</strong> <strong>of</strong> b<strong>and</strong>-limited signal
Practical D/A converters<br />
• Zero-order-hold (ZOH) interpolation:<br />
<br />
<br />
In this interpolation a given sample value is held for the<br />
sample interval until the next sample is received.<br />
It can be obtained by filtering the impulse train through an<br />
interpolating filter <strong>of</strong> the form<br />
xˆ<br />
h<br />
a<br />
0<br />
( t)<br />
=<br />
⎧1<br />
( t)<br />
= ⎨<br />
⎩0<br />
x(<br />
n),<br />
nT<br />
0<br />
≤<br />
s<br />
t<br />
≤<br />
≤ T<br />
s<br />
otherwise<br />
n ≤ ( n + 1) T<br />
• The resulting signal is a piecewise-constant (staircase) waveform which<br />
requires an appropriately designed analog post-filter for accurate<br />
waveform reconstruction.<br />
x (n)<br />
xˆ<br />
a<br />
( t)<br />
x a<br />
(t)<br />
ZOH<br />
s<br />
Post-Filter
First-order-hold (FOH) interpolation<br />
• In this case the adjacent samples are joined<br />
by straight lines.<br />
⎧ t<br />
⎪<br />
1+<br />
Ts<br />
⎪<br />
t<br />
h ( t)<br />
= ⎨1<br />
−<br />
⎪ Ts<br />
⎪ 0<br />
⎪<br />
⎩<br />
T<br />
0<br />
≤<br />
≤<br />
≤ T<br />
≤<br />
2T<br />
1 s<br />
s<br />
t<br />
t<br />
s<br />
otherwise
Cubic-order-hold (COH) interpolation<br />
• This approach uses spline interpolation for a smoother, but not<br />
necessarily more accurate, estimate <strong>of</strong> the analog signal between<br />
samples.<br />
• Hence this interpolation does not require an analog post-filter<br />
• The smoother reconstruction is obtained by using a set <strong>of</strong><br />
piecewise continuous third-order polynomials called cubic splines<br />
x<br />
a<br />
nT<br />
( t)<br />
s<br />
2<br />
= α ( n)<br />
+ α ( n)(<br />
t − nT ) + α ( n)(<br />
t − nT ) + α ( n)(<br />
t<br />
≤ t ≤<br />
0<br />
( n + 1) T<br />
1<br />
s<br />
s<br />
2<br />
s<br />
3<br />
− nT<br />
s<br />
)<br />
3<br />
,<br />
• Where {α i (n), 0
Matlab Implementation<br />
• sinc function which generates the sin(πx)/πx can be use to<br />
implement interpolation<br />
∑ +∞<br />
n=<br />
−∞<br />
x ( t)<br />
= x(<br />
n)sinc[<br />
F ( t − nT )]<br />
a<br />
• If {x(n), n1
Example 3<br />
• From the sample x(n) in example 2a, reconstruct x a (t)<br />
• x(n) was obtained by sampling x a<br />
(t) at Ts = 1/Fs = 0.0002 sec.<br />
• We will use the grid spacing 0.00005 sec over -0.005
Example 4<br />
• From the sample x(n) in example 2b, reconstruct x a (t)<br />
• x(n) was obtained by sampling x a (t) at Ts = 1/Fs = 0.001 sec.<br />
• We will use the grid spacing 0.00005 sec over -0.005
Example 5a<br />
• Reconstruct signal from the samples in example 2 using ZOH<br />
interpolation<br />
• It is a crude one <strong>and</strong> the further processing <strong>of</strong> analog signal is<br />
neccessary<br />
1<br />
Reconstructed Signal from x1(n) using zero-order-hold<br />
Ts = 0.0002; n = -25:1:25; nTs = n*Ts;<br />
x = exp(-1000*abs(nTs));<br />
% <strong>Analog</strong> Signal reconstruction using stairs<br />
stairs(nTs*1000,x);<br />
xlabel('t in msec.'); ylabel('xa(t)')<br />
stem(n*Ts*1000,x); hold <strong>of</strong>f<br />
xa(t)<br />
0.9<br />
0.8<br />
0.7<br />
0.6<br />
0.5<br />
0.4<br />
0.3<br />
0.2<br />
0.1<br />
0<br />
-5 -4 -3 -2 -1 0 1 2 3 4 5<br />
t in msec.
Example 5a<br />
• Reconstruct signal from the samples in example 2 using FOH<br />
interpolation<br />
• It appears to be good but a carefully observation near t=0<br />
reveals that the peak is not carefully reproduce<br />
• In general, if the sampling frequency is much higher than the<br />
Nyquist rate, FOH provides acceptable reconstruction<br />
Ts = 0.0002; n = -25:1:25; nTs = n*Ts;<br />
x = exp(-1000*abs(nTs));<br />
% <strong>Analog</strong> Signal reconstruction using plots<br />
1<br />
0.9<br />
0.8<br />
0.7<br />
0.6<br />
Reconstructed Signal from x1(n) using first-order-hold<br />
plot(nTs*1000,x);<br />
xlabel('t in msec.'); ylabel('xa(t)')<br />
stem(n*Ts*1000,x); hold <strong>of</strong>f<br />
xa(t)<br />
0.5<br />
0.4<br />
0.3<br />
0.2<br />
0.1<br />
0<br />
-5 -4 -3 -2 -1 0 1 2 3 4 5<br />
t in msec.
Example 6a<br />
• Reconstruct the sample in example 2a using spline function<br />
• Maximum error is lower due to nonideal interpolation <strong>and</strong> the<br />
fact that x a (t) is nonb<strong>and</strong>-limited<br />
• The ideal interpolation suffers more from time-limitedness<br />
• The plot is excellent<br />
Ts = 0.0002; n = -25:1:25; nTs = n*Ts;<br />
x = exp(-1000*abs(nTs));<br />
% <strong>Analog</strong> Signal reconstruction<br />
Dt = 0.00005;<br />
t = -0.005:Dt:0.005;<br />
xa = spline(nTs,x,t);<br />
plot(t*1000,xa);<br />
xlabel('t in msec.'); ylabel('xa(t)')<br />
stem(n*Ts*1000,x); hold <strong>of</strong>f<br />
% check<br />
error = max(abs(xa - exp(-1000*abs(t))))<br />
error =<br />
0.0317<br />
xa(t)<br />
1<br />
0.9<br />
0.8<br />
0.7<br />
0.6<br />
0.5<br />
0.4<br />
0.3<br />
0.2<br />
0.1<br />
Reconstructed Signal from x1(n) using cubic spline function<br />
0<br />
-5 -4 -3 -2 -1 0 1 2 3 4 5<br />
t in msec.
Example 6b<br />
• Reconstruct the sample in example 2b using spline function<br />
• Maximum error is high <strong>and</strong> cannot be attributed to the<br />
nonideal interpolation or nonb<strong>and</strong>-limitedness <strong>of</strong> x a (t)<br />
• The reconstructed signal differs from the actual one<br />
Ts = 0.001; n = -5:1:5; nTs = n*Ts;<br />
x = exp(-1000*abs(nTs));<br />
% <strong>Analog</strong> Signal reconstruction<br />
Dt = 0.00005;<br />
t = -0.005:Dt:0.005;<br />
xa = spline(nTs,x,t);<br />
% check<br />
error = max(abs(xa - exp(-1000*abs(t))))<br />
% Plots<br />
plot(t*1000,xa);<br />
xlabel('t in msec.'); ylabel('xa(t)')<br />
stem(n*Ts*1000,x); hold <strong>of</strong>f<br />
error =<br />
xa(t)<br />
1<br />
0.9<br />
0.8<br />
0.7<br />
0.6<br />
0.5<br />
0.4<br />
0.3<br />
0.2<br />
0.1<br />
Reconstructed Signal from x2(n) using cubic spline function<br />
0.1679<br />
0<br />
-5 -4 -3 -2 -1 0 1 2 3 4 5<br />
t in msec.