Professional Documents
Culture Documents
Chapter 4 Introduction To Sampling: Page 1 of 28
Chapter 4 Introduction To Sampling: Page 1 of 28
This topic like the other worksheet on Fourier can have difficult solutions, here
the objective is to use a software for application in signal processing, come to
appreciate software for signal processing.
The use of software here is for learning the subject matter and software. A learning
experience, gaining software skills, and solving some basic to intermediate
examples/problems. End result should be where we are able to take on difficult or
complex problems.
Page 1 of 28
Signals and Systems Using Mathcad (Tutorial) by Derose and Veronis.
Chapter 4 Introduction To Sampling
Entered by: Karl S Bogha Dhaliwal - Grad Cert Power Systems Protection and Relaying Uni of Idaho. USA.
BSE - Arkansas State U 1990. BSc - USAO Oklahoma 1986.
(t) if (t 0 , 1 , 0)
Page 2 of 28
Signals and Systems Using Mathcad (Tutorial) by Derose and Veronis.
Chapter 4 Introduction To Sampling
Entered by: Karl S Bogha Dhaliwal - Grad Cert Power Systems Protection and Relaying Uni of Idaho. USA.
BSE - Arkansas State U 1990. BSc - USAO Oklahoma 1986.
1
0.9
0.8
0.7
0.6
0.5
0.4 (t)
0.3
0.2
0.1
0
-15 -12 -9 -6 -3 0 3 6 9 12 15
The shifted plot when t=3, which means t=0 had been shifted to t=3. This exercise was
done in the Fourier Series worksheet
(t 3)
1
0.9
0.8
0.7
0.6
0.5
0.4 (t 3)
0.3
0.2
0.1
0
-15 -12 -9 -6 -3 0 3 6 9 12 15
1
0.8
0.6
0.4
0.2
0
-15 -12 -9 -6 -3
-0.2
0 3 6 9 12 15 x (t)
-0.4
-0.6
-0.8
-1
Page 3 of 28
Signals and Systems Using Mathcad (Tutorial) by Derose and Veronis.
Chapter 4 Introduction To Sampling
Entered by: Karl S Bogha Dhaliwal - Grad Cert Power Systems Protection and Relaying Uni of Idaho. USA.
BSE - Arkansas State U 1990. BSc - USAO Oklahoma 1986.
The sinusoidal signal is the signal we want to put through the sampling process.
2
Ts the sampling period multiplied by 2 pi or sampling time
s
N 16
N 1
Xs (t) t k Ts here is it NOT k that takes the value of 0 to 15 (N-1),
k=0 so k Ts is the sampling interval at 16 locations
starting from k=0
Ts = 1 calculated value of Ts
1
0.9
0.8
0.7
0.6
0.5
0.4
0.3 Xs (t)
0.2
0.1
0
-15 -12 -9 -6 -3 0 3 6 9 12 15
Here we had shifted the delta function 15 times to the right of t=0
Lets identify the plot above as a tool, and call it the sampler
Xs(t) is the sampler
1
0.8
0.6
0.4
0.2
0
-15 -12 -9 -6 -3 -0.2 0 3 6 9 12 15 Xd (t))
-0.4
-0.6
-0.8
-1
Page 4 of 28
Signals and Systems Using Mathcad (Tutorial) by Derose and Veronis.
Chapter 4 Introduction To Sampling
Entered by: Karl S Bogha Dhaliwal - Grad Cert Power Systems Protection and Relaying Uni of Idaho. USA.
BSE - Arkansas State U 1990. BSc - USAO Oklahoma 1986.
Now lets place the signal to be sampled and the sampled signal on the
same plot
1
0.8
0.6
0.4
0.2
0
-15 -12 -9 -6 -3 -0.2 0
-0.4
3 6 9 12 15
Xd (t)
-0.6
-0.8
-1
x (t))
t
The signal and the sampled signal are matching each other.
N 1
Xs (t) t k Ts Now lets make kTs =nTs,
k=0 then we define n=0 to N-1,
and then plot the signals (n gives a more discrete
n 0 N 1 representation to the sampler)
N 1
Xs_n (t) t n Ts
n=0
clear Xd
Xd (t) x (t) Xs_n (t)
1
0.8
0.6
0.4
0.2
0
-15 -12 -9 -6 -3 -0.2 0
-0.4
3 6 9 12 15 Xd (t)
-0.6
-0.8
-1
1
0.8
0.6
0.4
0.2
0
-0.2 0
-15 -12 -9 -6 -3
-0.4
3 6 9 12 15
Xd (t)
-0.6
-0.8
-1
x (t)
t
The signal and the sampled signal are matching each other again as expected.
Page 5 of 28
Signals and Systems Using Mathcad (Tutorial) by Derose and Veronis.
Chapter 4 Introduction To Sampling
Entered by: Karl S Bogha Dhaliwal - Grad Cert Power Systems Protection and Relaying Uni of Idaho. USA.
BSE - Arkansas State U 1990. BSc - USAO Oklahoma 1986.
1
0.8
0.6
0.4
0.2
0
-0.2
0 30 60 90 120 150 180 210 240 270 300 330 x( )
-0.4
-0.6
-0.8
-1
Page 6 of 28
Signals and Systems Using Mathcad (Tutorial) by Derose and Veronis.
Chapter 4 Introduction To Sampling
Entered by: Karl S Bogha Dhaliwal - Grad Cert Power Systems Protection and Relaying Uni of Idaho. USA.
BSE - Arkansas State U 1990. BSc - USAO Oklahoma 1986.
0 , 0.1 314
x ( ) sin ( )
1
0.8
0.6
0.4
0.2
0
-0.2
0 20 40 60 80 100 120 140 160 180 200 220 240 260 280 300 320 x( )
-0.4
-0.6
-0.8
-1
6.28
1
0.8
0.6
0.4
0.2
0
-0.2 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6 3.8 4 4.2 4.4 4.6 4.8 5 5.2 5.4 5.6 5.8 6 6.2 6.4 6.6 x( )
-0.4
-0.6
-0.8
-1
The period of the signal above is 6.28 which is 2pi (2x 3.14=6.28)
The signal is defined by the radian value. We can change w to t so long
as the range values on the x axis are the same. It would give the same
wave on the plot. So we simply substitute t for w, and set the plot in the
time domain.
t 0 , 0.1 314
x (t) sin (t)
1
0.8
0.6
0.4
0.2
0
-0.2 0 20 40 60 80 100 120 140 160 180 200 220 240 260 280 300 320 x (t)
-0.4
-0.6
-0.8
-1
Page 7 of 28
Signals and Systems Using Mathcad (Tutorial) by Derose and Veronis.
Chapter 4 Introduction To Sampling
Entered by: Karl S Bogha Dhaliwal - Grad Cert Power Systems Protection and Relaying Uni of Idaho. USA.
BSE - Arkansas State U 1990. BSc - USAO Oklahoma 1986.
We want to create a signal with a period, and then we want to sample it.
So the signal need's a shape, and we use the sine function to create its shape.
Now the signal we want to sample is shown below.
t 30 , 29.01 30
0 the signals angular frequency - radians
8
0 = 0.392699 multiplying 0.3926 to 't' each time
x (t) sin 0 t
1
0.8
0.6
0.4
0.2
0
-0.2
-0.4
-30 -10 10 30 x (t))
-0.6
-0.8
-1
Now remove w (omega) and plug in the multiplier 'm' instead, so we do not associate it with
w (omega) of signal theory. we just want to form a shape for the signal in the time domain.
m 0 = 0.392699
x (t) sin (m t)
1
0.8
0.6
0.4
0.2
0
-30
-0.2
-0.4
-10 10 30 x (t)
-0.6
-0.8
-1
Now plot for one period, as close as possible; same for sin(wo t) plot
16.070624
1
0.8
0.6
0.4
0.2
0
-30 -25 -20 -15 -10 -5 -0.2 0
-0.4
5 10 15 20 x (t)
-0.6
-0.8
-1
Page 8 of 28
Signals and Systems Using Mathcad (Tutorial) by Derose and Veronis.
Chapter 4 Introduction To Sampling
Entered by: Karl S Bogha Dhaliwal - Grad Cert Power Systems Protection and Relaying Uni of Idaho. USA.
BSE - Arkansas State U 1990. BSc - USAO Oklahoma 1986.
The sampling frequency has to be greater than twice the signal frequency
1
f = 0.0622
T
fs 2 f = 0.124456 this is the sampling frequency 2 x f
1
T = 8.035
fs
T 8 set to integer
Now returning to the text book example the authors suggest a sampling
frequency of 8 times w0. Where w0 = pi/8. ws = 8 x (pi/8) = pi
We showed above how we arrived to 8 from the inverse of T
0 s 8 0 = 3.1416
8
Now we set the sampling period Ts or sampling frequency Ts
Remember function is a sine wave its period is from 0 to 2pi in radian (angular frequency)
ws = 2 pi f, f = 1/Ts, ws = 2 pi /Ts, so Ts = 2 pi/ws
2
Ts =2
s
Ts = 2 sampling interval
Next form the sampler:
N 16 take 16 samples starting from 0
t 0,1 N 1
(t) if (t 0 , 1 , 0) delta impulse function
N 1
Xs2 (t) t n Ts the sampler for this example Xs2
n=0
1
0.9
0.8
0.7
0.6
0.5
0.4 Xs2 (t))
0.3
0.2
0.1
0
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Page 9 of 28
Signals and Systems Using Mathcad (Tutorial) by Derose and Veronis.
Chapter 4 Introduction To Sampling
Entered by: Karl S Bogha Dhaliwal - Grad Cert Power Systems Protection and Relaying Uni of Idaho. USA.
BSE - Arkansas State U 1990. BSc - USAO Oklahoma 1986.
The form of the sampled signal in discrete form is used for further
processing in the electronic circuit for whatvever application it is used for.
Signal to be sampled x_sig(t) below:
0
8
t 0 , 0.01 30
xsig (t) sin 0 t
1
0.8
0.6
0.4
0.2
0
-0.2
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 xsig (t))
-0.4
-0.6
-0.8
-1
Page 10 of 28
Signals and Systems Using Mathcad (Tutorial) by Derose and Veronis.
Chapter 4 Introduction To Sampling
Entered by: Karl S Bogha Dhaliwal - Grad Cert Power Systems Protection and Relaying Uni of Idaho. USA.
BSE - Arkansas State U 1990. BSc - USAO Oklahoma 1986.
Note: the intervals and number of iterations for x_sig(t) and Xs2(t) must be the same.
1
0.8
0.6
0.4
0.2
0
-0.2
1 4 7 10 13 16 19 22 25 28 31 Xd_sig (t)
-0.4
-0.6
-0.8
-1
Now with both the signal and sampled signal to show match.
0.8
0.6
0.4
0.2
-0.2
1 4 7 10 13 16 19 22 25 28 31
Xd_sig (t)
-0.4
-1
Note:
The delta function here served to teach the underlying sampling theory.
In the applications for products it is not practical to use the delta function. The signal was
in analog form, we create a sampler with intervals to lock-in to the signal, and generate a
discrete (digital) sampled signal. In real applications an analog to digital converter
associated to a clock is used. The approach is to create a window with length T to sample
the continous signal, this is called the zero order hold or sample-and-hold circuit.
Page 11 of 28
Signals and Systems Using Mathcad (Tutorial) by Derose and Veronis.
Chapter 4 Introduction To Sampling
Entered by: Karl S Bogha Dhaliwal - Grad Cert Power Systems Protection and Relaying Uni of Idaho. USA.
BSE - Arkansas State U 1990. BSc - USAO Oklahoma 1986.
0 s T 0 = 1.5708
8
Now we set the sampling period Ts_under
Remember function is a sine wave its period is from 0 to 2pi in radian (angular frequency)
ws = 2 pi f, f = 1/Ts, ws = 2 pi /Ts, so Ts = 2 pi/ws
2
Ts_under =4
s N 1
Xs2_under (t) t n Ts_under the sampler for this example Xs2_under
n=0
Xd_sig_under (t) xsig (t) Xs2_under (t) The stem plot does not show the sampled wave
accurately compared to T=8
1
0.8
0.6
0.4
0.2
0
-0.2
1 4 7 10 13 16 19 22 25 28 31
Xd_sig_under (t))
-0.4
-0.6 NOxsig (t)
-0.8
-1
Page 12 of 28
Signals and Systems Using Mathcad (Tutorial) by Derose and Veronis.
Chapter 4 Introduction To Sampling
Entered by: Karl S Bogha Dhaliwal - Grad Cert Power Systems Protection and Relaying Uni of Idaho. USA.
BSE - Arkansas State U 1990. BSc - USAO Oklahoma 1986.
Page 13 of 28
Signals and Systems Using Mathcad (Tutorial) by Derose and Veronis.
Chapter 4 Introduction To Sampling
Entered by: Karl S Bogha Dhaliwal - Grad Cert Power Systems Protection and Relaying Uni of Idaho. USA.
BSE - Arkansas State U 1990. BSc - USAO Oklahoma 1986.
Page 14 of 28
Signals and Systems Using Mathcad (Tutorial) by Derose and Veronis.
Chapter 4 Introduction To Sampling
Entered by: Karl S Bogha Dhaliwal - Grad Cert Power Systems Protection and Relaying Uni of Idaho. USA.
BSE - Arkansas State U 1990. BSc - USAO Oklahoma 1986.
Page 15 of 28
Signals and Systems Using Mathcad (Tutorial) by Derose and Veronis.
Chapter 4 Introduction To Sampling
Entered by: Karl S Bogha Dhaliwal - Grad Cert Power Systems Protection and Relaying Uni of Idaho. USA.
BSE - Arkansas State U 1990. BSc - USAO Oklahoma 1986.
Page 16 of 28
Signals and Systems Using Mathcad (Tutorial) by Derose and Veronis.
Chapter 4 Introduction To Sampling
Entered by: Karl S Bogha Dhaliwal - Grad Cert Power Systems Protection and Relaying Uni of Idaho. USA.
BSE - Arkansas State U 1990. BSc - USAO Oklahoma 1986.
0.5
x ti
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
ti
j 1 clear (X)
3
j t
X( ) x (t) e dt
3
0 3
j t j t
X1 ( ) x (t) e dt X2 ( ) x (t) e dt
3 0
Page 17 of 28
Signals and Systems Using Mathcad (Tutorial) by Derose and Veronis.
Chapter 4 Introduction To Sampling
Entered by: Karl S Bogha Dhaliwal - Grad Cert Power Systems Protection and Relaying Uni of Idaho. USA.
BSE - Arkansas State U 1990. BSc - USAO Oklahoma 1986.
0 0
||t|| (t 1i)
e ( )
j t 2
X1 ( ) x (t) e dt e dt
3 3
3
||
j t
X2 ( ) x (t) e dt if 2i 2i
0 6 3i ||
e 1 ( 2+ 1i)) | |
2
+4 ||
||
else if 2i 2i
||
3
(2 t ) t 1i
||
e ( ) dt ||
0 ||
The above evaluation from Prime, the equation below was attempted. Complex
integer evaluations are not easy to do manually and when a software is applied we
need to have a manual calculation done to check its answer or have some
expected result from past exercises.
6 3j i 6 3i i
e e 1 2+ i 1 j e 1 2+ i 1j
Xposble i +
2 2
i +4 i +4
0.9
0.8
0.7
0.6
0.5
Xposble i
0.4
0.3
0.2
0.1
0
-50 -40 -30 -20 -10 0 10 20 30 40 50
The authors of the textbook (tutorial) suggest the following equation - "For
now, lets use the Fourier transform formula, as shown below.
1 ( )) 1 ( )) 1
e( e(
6 3i i 6 + 3i i
X1 i X2 i X3 i
2+j i 2 +j i 2 +j i
1
X4 i
2+j i
X i X1 i + X2 i X3 i + X4 i
The signal to be samples below shows the same shape and amplitude.
So we will proceed with the signal X(w_i).
23 23
0.9
0.8
0.7
0.6
0.5
X i
0.4
0.3
0.2
0.1
0
-50 -40 -30 -20 -10 0 10 20 30 40 50
Textbook set the value of w_m to 22.44 though indicating 23 is more accurate
m 22.44 -23 to +23 is the bandwidth of the signal, before it touches the vertical axis = 0
Page 19 of 28
Signals and Systems Using Mathcad (Tutorial) by Derose and Veronis.
Chapter 4 Introduction To Sampling
Entered by: Karl S Bogha Dhaliwal - Grad Cert Power Systems Protection and Relaying Uni of Idaho. USA.
BSE - Arkansas State U 1990. BSc - USAO Oklahoma 1986.
1
0.9
0.8
0.7
0.6
0.5
0.4 Xt_s ti
0.3
0.2
0.1
0
-50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50
ti
1
0.9
0.8
0.7
0.6
0.5
0.4 Xt_s2 ti
0.3
0.2
0.1
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
ti
The above sampler X_t_s2(ti) has the shape similar to the Fourier transform
signal in frequency domain.
Now the Fourier transform of the first sampler (X_t_s(ti)) in time domain has to be found:
We use the first sampler (delta impulse train) which is in the frequency domain.
Page 20 of 28
Signals and Systems Using Mathcad (Tutorial) by Derose and Veronis.
Chapter 4 Introduction To Sampling
Entered by: Karl S Bogha Dhaliwal - Grad Cert Power Systems Protection and Relaying Uni of Idaho. USA.
BSE - Arkansas State U 1990. BSc - USAO Oklahoma 1986.
s 3 m set the value of the sampling frequency to 3 times the signal bandwidth
- here the bandwidth is (0 - +wm) x 3, this is larger than -wm to wm or
larger than 2wm
Ts = 1
50
2
Xs i i n s
Ts n= 50
67.32 67.32
6.28
6.5
5.85
5.2
4.55
3.9
3.25
2.6
Xs i
1.95
1.3
0.65
0
-100 -90 -80 -70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100
Page 21 of 28
Signals and Systems Using Mathcad (Tutorial) by Derose and Veronis.
Chapter 4 Introduction To Sampling
Entered by: Karl S Bogha Dhaliwal - Grad Cert Power Systems Protection and Relaying Uni of Idaho. USA.
BSE - Arkansas State U 1990. BSc - USAO Oklahoma 1986.
Convolution with a delta function gives the function itself, shifted to the
direction of the delta function.
50
1
Xd_s i X i n s
Ts n= 50
1 67.32 67.32
1
0.9
0.8
0.7
0.6
0.5
0.4 Xd_s i
0.3
0.2
0.1
0
-100 -90 -80 -70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100
6
s m here we set w_s much less then w_m
10
50
1
Xd_s_under i X i n s
Ts n= 50
1
1
0.9
0.8
0.7
0.6
0.5
0.4 Xd_s_under i
0.3
0.2
0.1
0
-100 -90 -80 -70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100
i
The signal above overlaps and does not replicate or reconstruct the
original signal. Though under sampled, the output shows as if its
more content in the plot as if correct! This is called signal overlap.
Page 22 of 28
Signals and Systems Using Mathcad (Tutorial) by Derose and Veronis.
Chapter 4 Introduction To Sampling
Entered by: Karl S Bogha Dhaliwal - Grad Cert Power Systems Protection and Relaying Uni of Idaho. USA.
BSE - Arkansas State U 1990. BSc - USAO Oklahoma 1986.
more content in the plot as if correct! This is called signal overlap.
s 2 m
50
1
Xd_s_2x i X i n s
Ts n= 50
1
1
0.9
0.8
0.7
0.6
0.5
0.4 Xd_s_2x i
0.3
0.2
0.1
0
-100 -90 -80 -70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100
To better see the overlaps in the case when w_m < 2 wm, we plot each individual spike.
6
s m make the sample frequency lower than original signal frequency
10
i i reindexing w - this is important to zoom in the 3 spikes
4
1
Xd_s_3spike i,n X i n s Note: Summation term not included
Ts
Page 23 of 28
Signals and Systems Using Mathcad (Tutorial) by Derose and Veronis.
Chapter 4 Introduction To Sampling
Entered by: Karl S Bogha Dhaliwal - Grad Cert Power Systems Protection and Relaying Uni of Idaho. USA.
BSE - Arkansas State U 1990. BSc - USAO Oklahoma 1986.
1
1
0.9
0.8
0.7
0.6
0.5
0.4
0.3
Xd_s_3spike i, 1
0.2
0.1
0 Xd_s_3spike i,0
-30 -24 -18 -12 -6 0 6 12 18 24 30
i Xd_s_3spike i,1
In the line trace plot above we can see the overlapping signals. Take note on how
this was created in the lines above in the plot and calculation/coding lines.
Lets use Prime 2 to shade the areas the signals are overlapping.
Go to the plot above and see roughly where the demarcations are for wi for each
half of the area in the overlaps
Page 24 of 28
Signals and Systems Using Mathcad (Tutorial) by Derose and Veronis.
Chapter 4 Introduction To Sampling
Entered by: Karl S Bogha Dhaliwal - Grad Cert Power Systems Protection and Relaying Uni of Idaho. USA.
BSE - Arkansas State U 1990. BSc - USAO Oklahoma 1986.
Xd_s_3spike i,1
i
AreaTotal i
i
Page 25 of 28
Signals and Systems Using Mathcad (Tutorial) by Derose and Veronis.
Chapter 4 Introduction To Sampling
Entered by: Karl S Bogha Dhaliwal - Grad Cert Power Systems Protection and Relaying Uni of Idaho. USA.
BSE - Arkansas State U 1990. BSc - USAO Oklahoma 1986.
wi i m
s 3 m set the sampling 3 times the signal bandwidth
50
1
Xd_s i X i n s the equation we used for the sampled signal
Ts n= 50
Plot the low-pass filter and add in the markers for cutoff frequency and
amplitude of the low-pass filter signal
1 44.28 44.679333
1
0.9
0.8
0.7
0.6
0.5
0.4 H i
0.3
0.2
0.1
0
-100 -80 -60 -40 -20 0 20 40 60 80 100
So frequencies within -w_c and wc will pass thru while the rest blocked. This will
help reconstruct the sampled signal closer to the original.
Page 26 of 28
Signals and Systems Using Mathcad (Tutorial) by Derose and Veronis.
Chapter 4 Introduction To Sampling
Entered by: Karl S Bogha Dhaliwal - Grad Cert Power Systems Protection and Relaying Uni of Idaho. USA.
BSE - Arkansas State U 1990. BSc - USAO Oklahoma 1986.
Next we apply the low-pass filter to the sampled signal, by multipling both of them.
Xd_s_fltr i Xd_s i H i
Plot above is cleaner and closer to the original compared to the first sampled signal
below which was overlapped.
1
1
0.9
0.8
0.7
0.6
0.5
0.4 Xd_s i
0.3
0.2
0.1
0
-100 -80 -60 -40 -20 0 20 40 60 80 100
Below is the original signal in time domain which was to be processed - without
any operation on it.
0.5
x ti
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
ti
Page 27 of 28
Signals and Systems Using Mathcad (Tutorial) by Derose and Veronis.
Chapter 4 Introduction To Sampling
Entered by: Karl S Bogha Dhaliwal - Grad Cert Power Systems Protection and Relaying Uni of Idaho. USA.
BSE - Arkansas State U 1990. BSc - USAO Oklahoma 1986.
Plot below with the orignal without any operation in the time domain, and
sampled-filtered signal in the frequency domain.
It shows a close shape while not exactly duplicate, with the same amplitude.
The visible difference being in the signal widths but this is due to one is in the
time domain and the other in the frequency domain.
ti
Page 28 of 28