You are on page 1of 9

Department of Biomedical Engineering

Faculty of Engineering & Applied Sciences


Riphah International University, Lahore, Pakistan

Program B.Sc. Bio-Medical Engineering Semester V

Subject BML-312 Biomedical Signal Processing Level of Enquiry: 0

CLO 1 Date

Experiment 2: Verification and Implementation of Sampling Theorem and Nyquist Criteria.

Lab Performance Lab Report

Ability to Conduct Marks Calculations and Marks


Experiment Data Presentation
/5 /5

Remarks (if any)………………………………………………..

Name & Signature of faculty: …………………………………


Understanding Sampling Theorem and Nyquist Criteria
Introduction:
Digital sampling is the process of converting a signal that is continuous in time and magnitude into a
finite number of discrete data points. Using a computer-controlled data acquisition system, this is typically done
by periodically measuring the signal voltage and converting it into a series of discrete binary numbers.
Sampling is used extensively in biomedical engineering to study time-varying bio-signals.
In analog domain, the signal that is of concern is continuous in both time and amplitude. The process of
discretization of the analog signal in both time domain and amplitude levels yields the equivalent digital signal.

When sampling the analog signal with an A/D board, we must satisfy two constraints:
1. We must sample long enough to include at least one full period of the lowest frequency we want to
resolve in the sample.
2. We must sample fast enough to capture the highest frequency present in the signal.

Sampling Rate:
The sampling operation samples (“chops”) the incoming signal at regular interval called “Sampling Rate”
(denoted by Ts). Sampling Rate is determined by Sampling Frequency (denoted by ƒs) as

Ts = 1/Fs

Nyquist-Shannon Sampling Theorem:


The following sampling theorem is the exact reproduction of text from Shannon’s classic paper.

“If a function f(t) contains no frequencies higher than Ѡ cps, it is completely determined by giving its
ordinates at a series of points spaced ½ Ѡ seconds apart.”

If the signal is confined to a maximum frequency of ƒM Hz, in other words, the signal is a baseband
signal (extending from 0 Hz to maximum ƒM Hz).
In order for a faithful reproduction and reconstruction of an analog signal that is confined to a maximum
frequency Fm, the signal should be sampled at a Sampling frequency (Fs) that is greater than or equal to twice
the maximum frequency of the signal.
ƒs ≥ 2 ƒM
We can see from Figure.1

That we best reproduce the signal if we sample at least 10 points per cycle of the highest frequency (=
sampling rate is 5 times the highest frequency). If we sample the signal at just the high and low points of each
cycle (2 points per cycle - the Nyquist sampling limit), then connecting our data points
reproduces the true frequency but not a representation of the shape of the signal. If we sample any slower than
this, the connect-a-dot waveform will begin to show a lower frequency than the true signal. Aliasing refers to
this mapping of the real frequency to a different frequency. As a rule of thumb, we always want to have at least
2 data points per cycle (Nyquist criterion) but should try to achieve 5-10 data points per cycle.
Of course, the faster we sample, the more data we collect and also the measurement equipment becomes pricier
once we need high sample rates. Therefore, we will have to make a judgement on how fast we can afford to
sample our data. An analog filter or signal conditioner should always be used with any sensor to remove
unwanted or unexpected high frequency noise, which could cause aliasing in the sampled data.

Methodology:

The concepts of the Sampling Theorem and Nyquist Criteria are fundamental in the field of signal processing
and are not part of any mythology. However, I can provide we with a brief explanation of these concepts.

Sampling Theorem (Nyquist-Shannon Theorem):


The Sampling Theorem, also known as the Nyquist-Shannon Theorem, is a fundamental principle in
signal processing and digital communication. It was formulated by Claude Shannon and Harry Nyquist in the
early 20th century. This theorem states that to accurately represent an analog signal in a digital format (i.e., to
sample and convert it into a discrete signal), the sampling rate must be at least twice the frequency of the
highest component in the signal. In mathematical terms, the theorem can be expressed as follows:

If we have an analog signal with a maximum frequency component of "f," then the minimum sampling rate,
often denoted as "fs," should be greater than or equal to 2f. This ensures that we can reconstruct the original
analog signal from its discrete samples without loss of information.

If the sampling rate is less than 2f, a phenomenon called aliasing occurs, and it leads to the distortion of the
original signal when it is reconstructed from the samples. To prevent aliasing, we need to follow the Nyquist-
Shannon Theorem and sample at a rate of at least 2f.

Nyquist Criteria for Bandwidth:


In the signal transmission and communication systems, the Nyquist Criteria, also known as the Nyquist
Rate, is an extension of the Sampling Theorem. It is used to determine the minimum bandwidth required to
transmit a signal without loss of information. The Nyquist Criteria states that the minimum bandwidth
necessary to accurately transmit a signal is twice the signal's highest frequency component.

Mathematically, if a signal has a maximum frequency component of "f," the minimum required bandwidth,
often denoted as "B," should be greater than or equal to 2f. This means that if we want to transmit a signal
without distortion or loss of information, the communication channel or transmission system must have a
bandwidth of at least 2f.
Program Code:

% Signal Parameters
Fs = 100; % Sampling Frequency
F = 1.5;
Fsig = F; % Signal Frequency
T = 1/Fsig; % Signal Period
L = 1000; % Length of Signal
t = (0:L-1)*(1/Fs); % Time Vector

% Signal Generation
x = cos(2*pi*Fsig*t); % Signal

% Nyquist-Shannon Sampling Theorem


fs_nyquist = Fsig*2;
[b, a] = butter(1, 2*fs_nyquist/(Fs-1));

% Filter Signal
x_filtered = filter(b, a, x);

% Plot Signal
subplot(3, 1, 1);
plot(t, x ,'r');
title('Adequately Sampled Signal');
xlabel('Time');
ylabel('Amplitude');

% Plot Filtered Signal


subplot(3, 1, 2);
plot(t, x_filtered, 'g');
title('Signal After Low-Pass Filter');
xlabel('Time');
ylabel('Amplitude');

% Plot under-sampled signal


subplot(3, 1, 3);
plot(t, x, 'b');
title('Under-Sampled Signal');
xlabel('Time');
ylabel('Amplitude');
Results:

Figure 1

Figure 2
Task1 :
Create a signal of a particular frequency and perform sampling on it.
Reconstruct the original signal from the sampled one.
Now change the values of f and fs and check the effect on sampling and reconstruction. Add your observations
and result snips in lab your report.

Program Code:
% Create a signal of a particular frequency and perform sampling on it
% Clear all the data base and close other window
clear all;
close all;

Fs = 1000; % Sampling frequency


T = 1/Fs; % Sampling period
L = 1000; % Length of signal
t = ((0:L-1)*T); % Time vector

% Frequency of the signal


f = 5;

% Amplitude of the signal


A = 1;

% Generate the signal


x = A*sin(2*pi*f*t);
y = A*cos(2*pi*f*t);

%Plot the signals


subplot(2,1,1);
plot(t,y,'r')
xlabel('Number of Samples');
ylabel('Amplitude');
title('input Sin Signal');

subplot(2,1,2);
plot(t,x,'g')
xlabel('Number of Samples');
ylabel('Amplitude');
title('input Cos Signal');
Results:

Figure 3

Figure 4
Figure 5

Figure 6

Observation:
Conclusion:

You might also like