ADC Lab 01 Fall 2024
ADC Lab 01 Fall 2024
(EL-3003)
LABORATORY MANUAL
____________________________________________________________________________________________________________________________________________________________
FUNDAMENTAL PERIOD:-
The fundamental period is the smallest positive value of ‘T’ (continuous) or ‘N’ (discrete) for which the
equations of periodicity held.
Some Important Properties of Discrete Fourier Transform:
𝑛
For a discrete time signal 𝑥(𝑡), 𝑤ℎ𝑒𝑟𝑒 𝑡 = 𝑛 * 𝑇𝑠 = 𝐹 , its fourier transform would be 𝑋(𝑓).
𝑠
(
If 𝑥(𝑡) = 𝐴𝑚 cos 𝑐𝑜𝑠 2π𝑓𝑚𝑡 ) ( )
* 𝐴𝑐 cos 𝑐𝑜𝑠 2π𝑓𝑐𝑡 , assuming that 𝑓𝑐 > 𝑓𝑚 , then 𝑋(𝑓) would be given
as
𝑋(𝑓) =
𝐴𝑚*𝐴𝑐
4 (
[δ 𝑓 − (𝑓𝑐±𝑓 ) + δ(𝑓 + (𝑓𝑐±𝑓 ))]
𝑚
) 𝑚
If 𝑥(𝑡) = 𝐾 + 𝐴𝑚𝑐𝑜𝑠(2π𝑓𝑚𝑡), where K is DC component, then 𝑋(𝑓) would be given as
𝐴𝑚
𝑋(𝑓) = 𝐾 * δ(𝑓) + 2 ( )
[δ 𝑓 − 𝑓𝑚 + δ(𝑓 + 𝑓𝑚)]
_____________________________________________________________________________________________
Page 2 of 11
Analogue and Digital National University Roll No: 22i-2222 L
Communication Lab
(EL3003)
of Computer and Emerging Sciences
Islamabad Fall 2024
a
b
#
01
____________________________________________________________________________________
Note:- It means if we add a DC componet of magnitude K, there would appear an impulse of K amplitude
at 0 Hz in frequency spectrum.
_____________________________________________________________________________________________
Page 3 of 11
Analogue and Digital National University Roll No: 22i-2222 L
Communication Lab
(EL3003)
of Computer and Emerging Sciences
Islamabad Fall 2024
a
b
#
01
____________________________________________________________________________________
Matlab
Code:-
_____________________________________________________________________________________________
Page 4 of 11
Analogue and Digital National University Roll No: 22i-2222 L
Communication Lab
(EL3003)
of Computer and Emerging Sciences
Islamabad Fall 2024
a
b
#
01
____________________________________________________________________________________
Morse Code:
Morse code is a method of transmitting text information as a series of on-off tones, lights, or clicks that can
be directly understood by a skilled listener or observer without special equipment. It is named for Samuel F.
B. Morse, an inventor of the telegraph. The International Morse Code[1] encodes the ISO basic Latin
alphabet, some extra Latin letters, the Arabic numerals and a small set of punctuation and procedural
signals (prosigns) as standardized sequences of short and long signals called "dots" and "dashes",[1] or "dits"
and "dahs", as in amateur radio practice. Because many non-English natural languages use more than the 26
Roman letters, extensions to the Morse alphabet exist for those languages.
_____________________________________________________________________________________________
Page 5 of 11
Analogue and Digital National University Roll No: 22i-2222 L
Communication Lab
(EL3003)
of Computer and Emerging Sciences
Islamabad Fall 2024
a
b
#
01
____________________________________________________________________________________
TASK 01:
Consider two continuous-time signals 𝑚(𝑡) = cos 𝑐𝑜𝑠 (2π8𝑡) , 𝑐(𝑡) = cos 𝑐𝑜𝑠 (2π12𝑡) , are
converted to discrete-time signals with 𝑡 = 𝑛𝑇𝑠 (Sampling Time = 1/𝐹𝑠 ). Implement following
equation in Matlab, plot its time domain graph and magnitude spectrum. Select a suitable value for
𝐹𝑠 and 𝑁 (number of samples) .
CODE:
clc;close all;clear all
Fs = 100; %sampling Frequency
N = 100; % Total number of samples
n = 0:N-1; % n represents sample number
Ts = 1/Fs; % T represents sampling interval i.e., time between 2 samples
t = n*Ts; % t = nTs = n/Fs
m = cos(2*pi*8*t);
c = cos(2*pi*12*t);
y=m+c;
Xk = fft(y)/N; % Computing fft
Y = abs(Xk);
X = fftshift(abs(Xk));
fx = -Fs/2:Fs/length(X):Fs/2-(Fs/length(X));
subplot(211)
plot(n,y,'linewidth',2);
grid on;
subplot(212)
stem(fx,X,'filled','linewidth',2);
grid on;
xlabel('-Fs/2 to Fs/2','fontweight','bold');
ylabel('|X(k)|','fontweight','bold');
title('Frequency Domain Spectrum');
_____________________________________________________________________________________________
Page 6 of 11
Analogue and Digital National University Roll No: 22i-2222 L
Communication Lab
(EL3003)
of Computer and Emerging Sciences
Islamabad Fall 2024
a
b
#
01
____________________________________________________________________________________
_____________________________________________________________________________________________
Page 7 of 11
Analogue and Digital National University Roll No: 22i-2222 L
Communication Lab
(EL3003)
of Computer and Emerging Sciences
Islamabad Fall 2024
a
b
#
01
____________________________________________________________________________________
TASK 02:
Let 𝑚(𝑡) = cos 𝑐𝑜𝑠 (2π30𝑡) , 𝑐(𝑡) = cos 𝑐𝑜𝑠 (2π400𝑡) , 𝑤ℎ𝑒𝑟𝑒 𝑡 = 𝑛𝑇𝑠
Implement following equation in Matlab, plot its time domain graph and magnitude spectrum.
Select a suitable value for 𝐹𝑠 and 𝑁 (number of samples) .
_____________________________________________________________________________________________
Page 8 of 11
Analogue and Digital National University Roll No: 22i-2222 L
Communication Lab
(EL3003)
of Computer and Emerging Sciences
Islamabad Fall 2024
a
b
#
01
____________________________________________________________________________________
_____________________________________________________________________________________________
Page 9 of 11
Analogue and Digital National University Roll No: 22i-2222 L
Communication Lab
(EL3003)
of Computer and Emerging Sciences
Islamabad Fall 2024
a
b
#
01
____________________________________________________________________________________
TASK 03:
Decoding Morse Code: Since morse code for Letter “D” is “_..” which in binary form is
“1 1 1 0 1 0 1” since dot (.) represents one digt (1), space is equal to one 0 (zero) while dash (-) represents
three (3) ones. Your goal is to write a Matlab code that implements a Morse Code communication system
which includes a Transmitter (Tx), a Channel and a Receiver R(x). The Tx transmits an alphabet like D
(1110101) in the form of 𝑠(𝑡), channel will attenuate the message 𝑠(𝑡) by attenuation factor “α” and add a
random noise 𝑛(𝑡) such that message becomes 𝑟(𝑡) = α𝑠(𝑡) + 𝑛(𝑡). Rx will detect transmitted message by
applying some decision method. If message received correctly, Rx will display a message “Letter D
received correctly” otherwise it displays “Error Occured”. Vary SNR(Standard Deviation-> Sigma) and α
and comment on the results.
Note: Noise can be added in the signal by using ‘awgn’ command or ‘randn’ function. For further details use
MATLAB help. Usage of ‘randn’ function is given below:
𝑟 = 𝑎𝑡 * 𝑠 + 𝑠𝑖𝑔𝑚𝑎 * 𝑟𝑎𝑛𝑑𝑛(1, 𝑙𝑒𝑛𝑔𝑡ℎ(𝑠));
Example: Let s = [ 0 1]; at = 0.6, and let 𝑠𝑖𝑔𝑚𝑎 * 𝑟𝑎𝑛𝑑𝑛(1, 𝑙𝑒𝑛𝑔𝑡ℎ(𝑠)) = [0. 3 − 0. 2], 𝑡ℎ𝑒𝑛 𝑟 = [0. 3 0. 4]
You can set Threshold = 0.5 (Boundary Value) for the detection of the Error. Vary sigma like sigma 0.5 etc.
CODE:
clc,clear all;close all;
D=[1 1 1 0 1 0 1];
at=0.7;
std=0.2;
R=at*D + std*randn(1,length(D));
Z=abs(R)>=0.5
if (isequal(D,Z)==1)
else
_____________________________________________________________________________________________
Page 10 of 11
Analogue and Digital National University Roll No: 22i-2222 L
Communication Lab
(EL3003)
of Computer and Emerging Sciences
Islamabad Fall 2024
a
b
#
01
____________________________________________________________________________________
end
_____________________________________________________________________________________________
Page 11 of 11