Uploaded by 21uec048

21uec048 exp4

advertisement
Design Lab-2
Laboratory report submitted for the partial fulfillment
of the requirements for the degree of
Bachelor of Technology
in
Electronics and Communication Engineering
by
Name – Divya Sureka
Roll No - 21UEC048
Course Coordinator
Dr. Rohit Rana
Department of Electronics and Communication Engineering
The LNM Institute of Information Technology, Jaipur
February 2024
Copyright © The LNMIIT 2024
All Rights Reserved
Chapter 1
Experiment - 4
1.1
AIM
1. Simulate M-QAM modulator and Demodulator.
1.2
Software Used
MATLAB
1.3
Theory
1
1.4
Tasks
1.4.1
Task 1
clc
close all
clear all
N=10^3;
n=N;
SNR_DB=0:3:20;
SNR_LIN=10.^(SNR_DB./10);
N_SD=sqrt(1./SNR_LIN);
for i=1:length(SNR_LIN)
alphabet=[3,1,-1,-3];
x1=randsrc(1,n,alphabet);
x2=randsrc(1,n,alphabet);
x=x1+1j.*x2;
noise=(1./sqrt(2)).*(N_SD(i)).*complex(randn(1,N),randn(1,N));
y1=(1./sqrt(10)).*x+noise;
y=(sqrt(10)).*y1;
for k=1:N
if(real(y(k))>=2)
realdetected(k)=3;
elseif(real(y(k))<2 && real(y(k))>=0)
realdetected(k)=1;
elseif(real(y(k))<0 && real(y(k))>=-2)
realdetected(k)=-1;
else
realdetected(k)=-3;
end
end
for k=1:N
if(imag(y(k))>=2)
imagdetected(k)=3;
elseif(imag(y(k))<2 && imag(y(k))>=0)
imagdetected(k)=1;
elseif(imag(y(k))<0 && imag(y(k))>=-2)
imagdetected(k)=-1;
else
imagdetected(k)=-3;
end
end
detected=realdetected+1j.*imagdetected;
error(i)=size(find(x-detected),2)/n;
end
error_th=1.5*erfc(sqrt(SNR_LIN/10));
semilogy(SNR_DB,error_th,'-o');
hold on
semilogy(SNR_DB,error,'-+');grid on
title("SNR vs BER qam")
1
2
Published with MATLAB® R2022b
2
1.4.2
Task 2
clc
close all
clear all
N=10^5;
SNR_DB=0:3:10;
SNR_LIN=10.^(SNR_DB./10);
for i=1:length(SNR_DB)
N_SD=sqrt(1./SNR_LIN(i));
sim('simul_1.slx');
error(i)=ans.simout1;
end
display(error);
error_th=1.5*erfc(sqrt(SNR_LIN/10));
semilogy(SNR_DB,error_th,'-o');
hold on
semilogy(SNR_DB,error,'-+');
grid on
title("SNR vs BER qpsk")
error =
1
0
0
0
1
4
1.4.3
Task 3
clc
close all
clear all
N=10^5;
SNR_DB=0:3:10;
SNR_LIN=10.^(SNR_DB./10);
for i=1:length(SNR_DB)
N_SD=sqrt(1./SNR_LIN(i));
sim('simul_qam.slx');
error(i)=ans.simout1;
end
display(error);
error_th=1.5*erfc(sqrt(SNR_LIN/10));
semilogy(SNR_DB,error_th,'-o');
hold on
semilogy(SNR_DB,error,'-+');
grid on
title("SNR vs BER qam")
error =
2
0
0
0
1
5
1.5
Simulink
Simulink BPSK
Simulink QAM
6
1.6
Conclusion
1. Utilized Dev C++ to generate C++ code for the modulator, facilitating efficient simulation.
2. Compared simulated results with theoretical Bit Error Rate (BER) calculations for QPSK and
16-QAM.
3. Successfully plotted simulated BER curves for both QPSK and 16-QAM transceivers, providing
insight into system performance under varying signal-to-noise ratios.
7
Download