micro controller
micro controller
IV semester (ECE)
Subject Code: BECL404
LABORATORY MANUAL
DEPARTMENT OF
ELECTRONICS & COMMUNICATION ENGINEERING
2023-2024
Department of Electronics & Communication
Engineering
Course Outcomes 7
List of Experiments
2022 Scheme
Course Objectives
This course will enable students to
• Understand and analyse concepts of Analog Modulation schemes viz; AM, FM
• Design and analyse the electronic circuits for AM and FM modulation and demodulation.
• Understand the concepts of random variable and random process to model communication
systems.
• Understand and analyse the concepts of digitization of signals.
• Evolve the concept of SNR in the presence of channel induced noise
S.No. Experiments
Basic Signals and Signal Graphing: a) unit Step, b) Rectangular, c) standard triangle
1
d) sinusoidal and e) Exponential signal.
Illustration of signal representation in time and frequency domains for a rectangular
2
pulse
Amplitude Modulation and demodulation: Generation and display the relevant
3 signals and its spectrums.
1. Louis E Frenzel, Principles of Electronic Communication Systems, 3rd Edition, Mc Graw Hill
Education
(India) Private Limited, 2016. ISBN: 978-0-07-066755-6.
2. Simon Haykin & Michael Moher, Communication Systems, 5th Edition, John Wiley, India Pvt.
Ltd, 2010, ISBN:978-81-265-2151-7.
Course Outcomes
CO1 Identify and associate the random variables and random process in Communication
systemdesign
CO2 Understand the principles of amplitude modulation in analog communication systems
C06 Generate the basic signal, construct the different modulation techniques reconstruction,
multiplexing, pulse code modulation, pulse shaping, statistical analysis, and audio signal
analysis.
CORRELATION LEVELS
Correlation Levels: Slight (low) =1, Moderate (Medium) =2, Substantial (High) =3.
CO-PO MATRIX:
PO 1 3 3 3 3 3 - 3
PO 2 3 3 3 3 3 - 3
PO 3 - - - - - - -
PO 4 - - - - - - -
PO 5 - - - - - 3 3
PO 6 - - - - - - -
PO 7 - - - - - - -
PO 8 - - - - - - -
PO 9 - - - - - - -
PO 10 - - - - - - -
PO 11 - - - - - - -
PO 12 - - - - - -
CO-PSO MATRIX:
PSO CO 1 CO 2 CO 3 CO 4 CO 5 Course
PSO 1 - - - - - -
PSO 2 - - - - - -
1. Should come on time with thorough preparation for the experiment to be conducted.
2. Should bring the practical record fully completed in all respects pertaining to the experiment
conducted in the previous lab/s.
3. After completion of the program, certification of the concerned Faculty -in-charge in the
observation book is necessary.
4. Turn off the systems/Fans/Lights after use.
5. Keep the Computer lab premises clean and tidy.
6. Do not misbehave in the computer laboratory.
7. Do not touch, connect or disconnect any plug/cable/flash drive without your
Faculty/laboratory technician’s permission.
8. Do not read or modify other users' files.
9. Replace the materials/equipment in proper place after work.
10. Ask your Faculty-in-charge or lab technician for assistance if you have any problem.
Experiment No. 1
BASIC SIGNALS AND SIGNAL GRAPHING
Aim : To plot basic signals using matlab functions a) unit Step, b) Rectangular, c) standard triangle d) sinusoidal
and e) Exponential signal f)Square signal g)Ramp signal h)Triangular signal
APPARATUS:
1. Personal Computer
2. MATLAB software R2013a.
PROCEDURE:
1. Open MATLAB version R2013a
2. Open new file and enter the program and save it.
3. Add the path to the location of the file in the system.
4. Compile the program and check for any error and debug it.
5. Note down the output.
Matlab Program
WAVEFORMS:
IPCC PCS Lab
Experiment No.2
PROCEDURE:
3. Open MATLAB version R2013a
4. Open new file and enter the program and save it.
5. Add the path to the location of the file in the system.
6. Compile the program and check for any error and debug it.
7. Note down the output.
Matlab Program
clear
;clc;
% Define parameters
A = 2; % Amplitude of the rectangular pulse
tau = 4; % Duration of the rectangular pulse in
seconds t_step = 0.001; % Time step in seconds
t_range = -10:t_step:10; % Time range from -10 to 10 seconds
% 1. Generating rectangular pulse in the time
domain rect_pulse = A * (abs(t_range) < (tau/2));
% 2. Transforming the signal from the time domain into the frequency
domain N = length(t_range); % Number of points in the signal
f_signal = fft(rect_pulse, N); % Compute the FFT of the signal
f_signal1 = fftshift(f_signal); % Shift the zero frequency component to the
center f_range = (-N/2:N/2-1)*(1/(t_step*N)); % Frequency range
% 3. Plot the signal in the time
domain figure;
subplot(2,1,1);
plot(t_range,
rect_pulse);
title('Rectangular Pulse in Time
Domain');xlabel('Time (s)');
ylabel('Amplitude'
);grid on;
% Plot the magnitude of the signal in the frequency
domain subplot(2,1,2);
14
IPCC PCS Lab
plot(f_range, abs(f_signal1)/N); % Normalized
magnitude title('Rectangular Pulse in Frequency
Domain'); xlabel('Frequency (Hz)');
ylabel('Magnitude'
);grid on;
15
IPCC PCS Lab
Output waveform
16
IPCC PCS Lab
Experiment No.3
APPARATUS:
1. Personal Computer
2. MATLAB software R2013a.
PROCEDURE:
1. Open MATLAB version R2013a
2. Open new file and enter the program and save it.
3. Add the path to the location of the file in the system.
4. Compile the program and check for any error and debug it.
5. Note down the output.
MATLAB program
clc; clear all;close
all; fm=40;
fc=500;
vm=1;vc=1;
mu=0.8; % modulation index
% x-
axis:Time(second)
t=0:0.00001:0.1;
f=0:1:9999;
% y-axis:Voltage(volt)
V1=vc+mu*sin(2*pi*fm*t); %upper
envelop V2=-(vc+mu*sin(2*pi*fm*t)); %
lower envelop Vm=vm*sin(2*pi*fm*t);
Vc=vc*sin(2*pi*fc*t);
Vam=vc*(1+mu*sin(2*pi*fm*t)).*(sin(2*pi*fc*t)); %%AM
signal Vr=Vam.*Vc; % Synchronous detector
Vf=abs(fft(Vam,10000))/500; % Spectrum
[b a] =
butter(3,0.002); out=
filter(b,a,Vr);
%Plot modulating,carrier
signalfigure(1);
Subplot(411
) plot(t,Vm);
title('AM modulating signal');
xlabel('time'), ylabel('amplitude');grid
on; subplot(412)
plot(t, Vc);
17
IPCC PCS Lab
title('AM carrier signal');
xlabel('time'), ylabel('amplitude');grid on;
subplot(413)
plot(t,Vam);hold on;
plot(t,V1,'r'),plot(t,V2,'r
');
title('AM waveform time-domain');
xlabel('time'), ylabel('amplitude');grid
on; subplot(414)
plot(t,1.81*out)
18
IPCC PCS Lab
title('AM Demodulated
signal'); xlabel('time'),
ylabel('amplitude');grid;
% Plot AM in time domain and Frequency domain
figure(2)
plot(f*10,Vf);
axis([(fc-6*fm) (fc+6*fm) 0 10]);
title('AM waveform frequency-
domain');
xlabel('frequency'), ylabel('amplitude');grid on;
Output Waveform:
Spectrum
19
IPCC PCS Lab
Experiment No.4
APPARATUS:
1. Personal Computer
2. MATLAB software R2013a.
PROCEDURE:
3. Open MATLAB version R2013a
4. Open new file and enter the program and save it.
5. Add the path to the location of the file in the system.
6. Compile the program and check for any error and debug it.
7. Note down the output.
MATLAB program
clc; clear
all;close
all;
fs=10000;
Ac=1;
Am=1;
fm=35
;
fc=500
;B=10;
t=(0:0.1*fs)/fs;
wc=2*pi*fc;
wm=2*pi*fm;
m_t=Am*cos(wm*t
); figure(1);
subplot(411);
plot(t,m_t);
xlabel('Time');ylabel('Amplitude');
title('Modulating or Message
signal');c_t=Ac*cos(wc*t);
subplot(412
);plot(t,c_t);
xlabel('Time');ylabel('Amplitude
'); title('Carrier signal');
s_t=Ac*cos((wc*t)+B*sin(wm*
t)); subplot(413);
plot(t,s_t);
xlabel('Time');ylabel('Amplitud
e'); title('Modulated signal');
20
IPCC PCS Lab
d=demod(s_t,fc,fs,'fm');
subplot(414);
plot(t,d);
xlabel('Time');ylabel('Amplitud
e');
title('demodulated
signal');figure(2);
vf=(fft(s_t,10^4))/500;
f=0:10:99990; plot(f,vf);
21
IaPxiCs(C[ 0 10^4 0 0.4]); PCS Lab
xlabel('frequency');
ylabel('amplitude'); title('FM
frequency-domain'); grid on;
Output Waveform:
Spectrum
22
IPCC PCS Lab
Experiment No.5
SAMPLING AND RECONSTRUCTION OF LOW PASSSIGNALS
AIM: Simulate the process of sampling and reconstruction of low pass signals, and displaythe
waveforms
APPARATUS:
1. Personal Computer.
2. MATLAB Simulink
PROCEDURE:
1. Open MATLAB version R2013a
2. Open SIMULINK Library
3. Open new file and draw the Sampling and reconstruction diagram and save it.
4. Go to Simulation Menu and set model configuration parameters.
5. Go to Simulation menu and click on RUN
6. Note down the output waveform for following conditions.
i. For oversampling fs>2fm
ii. For sampling at Nyquist rate fs=2fm
iii. For undersampling fs<2fm
7. Sampling frequency can varied by varying the width of the pulse in pulse generator
blockshown in Simulink block diagram.
23
IPCC PCS Lab
Figure 5.1: Sampling and reconstruction of signal
24
IPCC PCS Lab
Table 5.1: Parameter Settings for the Various Blocks in the Model
EXPECTED WAVEFORM:
CONCLUSION:
25
IPCC PCS Lab
Experiment No.6
APPARATUS:
Personal Computer
MATLAB software
R2013a.
PROCEDURE:
1. Open MATLAB version R2013a
2. Open new file and enter the program and save it.
3. Add the path to the location of the file in the system.
4. Compile the program and check for any error and debug it.
5. Note down the output.
MATLAB program
clc;
close
all; clear
all;
% Signal generation
t=0:0.001:0.1; % siganal taken upto 4pi
sig1=2*sin(2*pi*100*t); % generate 1st sinusoidal
signall=length(sig1);
sig2=2*sin(2*pi*200*t); % Generate 2nd Sigal
% Display of Both
Signalsubplot(2,2,1);
plot(t, sig1);
title('Sinusoidal Signal
1'); ylabel('Amplitude---
>');
xlabel('Time---
>');
subplot(2,2,2);
plot(t, sig2);
title('Sinosoidal Signal
2'); ylabel('Amplitude---
>');
26
IPCC PCS Lab
xlabel('Time--->');
% Display of Both Sampled
Signalsubplot(2,2,3);
stem(sig1);
title('Sampled Sinusoidal Signal
1');ylabel('Amplitude--->');
xlabel('Time---
>');
subplot(2,2,4);
stem(sig2);
title('Sampled Sinusoidal Signal
2');ylabel('Amplitude--->');
xlabel('Time--->');
27
IPCC PCS Lab
l1=length(sig1
);
l2=length(sig2
);for i=1:l1
sig(1,i)=sig1(i); % Making Both row vector to a
matrix sig(2,i)=sig2(i);
end
% TDM of both quantize
signal
tdmsig=reshape(sig,1,2*l1);
% Display of TDM
Signalfigure
stem(tdmsig);
title('TDM Signal');
ylabel('Amplitude---
>');
xlabel('Time--->');
% Demultiplexing of TDM
Signal
demux=reshape(tdmsig,2,l1);
for i=1:l1
sig3(i)=demux(1,i); % Converting The matrix into row
vectors sig4(i)=demux(2,i);
end
% display of demultiplexed
signalfigure
subplot(2,1,
1) plot(sig3);
title('Recovered Sinusoidal Signal
1');ylabel('Amplitude--->');
xlabel('Time---
>');
subplot(2,1,2)
plot(sig4);
title('Recovered Sinusoidal Signal
2');ylabel('Amplitude--->');
xlabel('Time--->');
Output waveforms
28
IPCC PCS Lab
29
IPCC PCS Lab
30
IPCC PCS Lab
Experiment No.7
Simulate the pulse code modulation and demodulation system, and display the waveforms
APPARATUS:
1. Personal Computer.
2. MATLAB Simulink
PROCEDURE:
1. Open MATLAB version R2013a
2. Open SIMULINK Library
3. Open new file and draw the Transmitter and Receiver diagram and save it.
4. Go to Simulation Menu and set model configuration parameters.
5. Go to Simulation menu and click on RUN
6. Note down the output waveform.
31
IPCC PCS Lab
32
IPCC PCS Lab
Table 7.1: Parameter Settings for the Various Blocks in the Models of PCM
33
IPCC PCS Lab
EXPECTED WAVEFORM:
PCM Transmitter & Receiver
CONCLUSION:
34
IPCC PCS Lab
Experiment No.8
LINE CODING AND EYE DIAGRAM
AIM:
To simulate NRZ, RZ, half-sinusoid and raised cosine pulses and generate eye diagram for
binary polar signaling.
APPARATUS:
1. Personal Computer
2. MATLAB software R2013a.
PROCEDURE:
1. Open MATLAB version R2013a
2. Open new file and enter the program and save it.
3. Add the path to the location of the file in the system.
4. Compile the program and check for any error and debug it.
5. Note down the output.
36
IPCC PCS Lab
disp('one')
;end
n=n+
1 end
end
2. MATLAB program for Unipolar Return to Zero
function URZ1(h)
h=[1 1 0 1 1 0 1 0 1
0];
clf;
n=1
;
l=length(h
);h(l+1)=1;
while n<=length(h)-
1;t=n-1:0.001:n;
if h(n) == 0
if
h(n+1)==
0 y=(t>n);
else
y=(t==n)
; end
d=plot(t,y);grid on
title('Line code UNIPOLAR
RZ');set(d,'LineWidth',2.5);
hold on;
axis([0 length(h)-1 -1.5
1.5]); disp('zero');
else
if h(n+1)==0
y=(t<n-
0.5);
else
y=(t<n-0.5)+1*(t==n);
end
d=plot(t,y);grid
on;
title('Line code UNIPOLAR
RZ');set(d,'LineWidth',2.5);
hold on;
axis([0 length(h)-1 -1.5
1.5]); disp('one');
end
n=n+1
; end
end
38
IPCC PCS Lab
t=n-1:0.001:n;
if h(n) == 0
if h(n+1)==0
y=-(t<n)-
(t==n); else
y=-
(t<n)+(t==n); end
d=plot(t,y);grid
on;
title('Line code POLAR
NRZ');
set(d,'LineWidth',2.5);
hold on;
axis([0 length(h)-1 -1.5
1.5]); disp('zero');
else
if h(n+1)==0
y=(t<n)-
1*(t==n);
else
y=(t<n)+1*(t==n
);end
d=plot(t,y)
;grid on;
title('Line code POLAR
NRZ');
set(d,'LineWidth',2.5);
hold on;
axis([0 length(h)-1 -1.5
1.5]); disp('one');
end
n=n+1
;end
40
IPCC PCS Lab
else
if h(n+1)==0
y=(t<n-0.5)-1*(t==n);
else
y=(t<n-0.5)+1*(t==n);
end
d=plot(t,y);grid
on;
title('Line code POLAR
RZ');set(d,'LineWidth',2.5);
hold on;
axis([0 length(h)-1 -1.5
1.5]); disp('one');
end
n=n+1
;end
41
IPCC PCS Lab
axis([0 length(h)-1 -1.5
1.5]); disp('zero');
else
ami=ami*-1;
if h(n+1)==0
if ami==1
y=(t<n);
else
y=-
(t<n); end
else
42
IPCC PCS Lab
if ami==1
y=(t<n)-
(t==n);
else
y=-
(t<n)+(t==n); end
end
d=plot(t,y);grid
on;
title('Line code AMI
NRZ');
set(d,'LineWidth',2.5);
hold on;
axis([0 length(h)-1 -1.5
1.5]); disp('one');
end
n=n+1
;
%pause
;end
43
IPCC PCS Lab
title('Line code AMI
RZ');
set(d,'LineWidth',2.5);
hold on;
axis([0 length(h)-1 -1.5
1.5]); disp('zero');
else
ami=ami*-
1;if
h(n+1)==0 if
ami==1
y=(t<n-0.5);
else
y=-(t<n-0.5);
44
IPCC PCS Lab
en
d else
if ami==1
y=(t<n-0.5)-(t==n);
else
y=-(t<n-0.5)+(t==n);
end
end
d=plot(t,y);grid
on;
title('Line code AMI
RZ');
set(d,'LineWidth',2.5);
hold on;
axis([0 length(h)-1 -1.5
1.5]); disp('one');
end
n=n+1
;end
46
IPCC PCS Lab
axis([0 length(h)-1 -1.5
1.5]); disp('zero');
end
n=n+1
;end
47
IPCC PCS Lab
amp= sqrt(2/16);
Halfsine=amp*sin((2*pi*[0:15]/16)
/2);
fvtool(Halfsine,'Analysis','impulse')
;
Output Waveform
Imp ulse Re sp on se
0.35
0.3
0.25
0.2
Amplitude
0.15
0.1
0.05
0 5 10 15
Samples
20
48
IPCC PCS Lab
10
-10
-20
Magnitude (dB)
-30
-40
-50
-60
-70
-80
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
49
IPCC PCS Lab
CONCLUSION:
50
IPCC PCS Lab
Experiment No.9
PROCEDURE:
• Open MATLAB version R2013a
• Open new file and enter the program and save it.
• Add the path to the location of the file in the system.
• Compile the program and check for any error and debug it.
• Note down the output.
Matlab Code
clc; clear all; close all;
colors=['r','g','b'] ;
m = 0;
sig = [0.25 0.6 1];
x = -5:0.05:5;
f=zeros(1,length(x)
); for w =
1:length(sig) for ii
= 1:length(x)
f(ii) = 1/(sig(w)*sqrt(2*pi)) .* exp(-((x(ii)-m)^2 /
(2*(sig(w))^2))); end
plot(x,f,colors(w
)) hold on
end
xlabel('x')
;
ylabel('PDF');
title('probability density function')
hleg1 =
legend('sigma=0.25','sigma=0.6','sigma=1');
set(hleg1,'Location','NorthEast')
axis([-5 5 0 2]);
grid on
Output Waveform
51
IPCC PCS Lab
52
IPCC PCS Lab
Experiment No.10
• PROCEDURE:
• Open MATLAB version R2013a
• Open new file and enter the program and save it.
• Add the path to the location of the file in the system.
• Compile the program and check for any error and debug it.
• Note down the output.
Matlab Code
clc;
clear
all;
close
all;
subplot(2,1,1);
plot(time,y); % Plot the waveform w.r.t. time
title('Time domain representation of audio
signal');xlabel('Time');
ylabel('Amplitude'); grid on;
subplot(2,1,2);
plot(abs(f_signal1)/N); % Normalized magnitude
title('Frequency Domain representation of audio
signal');xlabel('Frequency (Hz)');
ylabel('Magnitude'
);grid on;
53
BEC402 PCS LAB