You are on page 1of 6

DIGICOM LAB REPORT

Muhammad Abdullah Iqbal


110401074
EE-01 Section (A)

Quadrature Amplitude Modulation.


MATLAB Code:
clc
clearvars -except Num
x = round(rand(1,16,1));a
y = buffer(x,4);b
sz = size(y);s
fs = 500;
t = 1/fs:1/fs:1;
for n = 1:15
clear p;
v= 0;q
noise = (n*50)*randn(1,length(t));
sy1 = cos(2*pi*50*t);
sy2 = sin(2*pi*50*t);
l = 1;
for i = 1:sz(2)
o = y(:,i)';
I = thresh(o(1:2)); D
Q = thresh(o(3:4));
trans1 = I*sy1;
trans2 = Q*sy2;
%
figure
%
plot(trans1)
%
figure
%
plot(real(trans2))
send = trans1 + trans2 + noise;
% figure
% plot(send)
% title('Data Transmitted with Noise (Single Bit)');
% xlabel('Index')
% ylabel('Amplitude')
%///////////////////////////////////////////////////////////////////////
%Received Signal
%Demodulation
Ac = send.*(2*cos(2*pi*50*t));
As = send.*(2*sin(2*pi*50*t));
% Ac1 = filter(Ac,Num,1);
Ac1 = conv(Ac,Num);
As1 = conv(As,Num);
Out1 = round(mean(Ac1));
Out2 = round(mean(As1));
% figure
% plot(Ac1);
% title('Real Part Demodulated');
% figure
% plot(As1);
% title('Quadrature Part Demodulated');
p(l,:) = [th_back(Out1) th_back(Out2)];
l = l+1;

%///////////////////////////////////////////////////////////////////////
end
for qw= 1:sz(1)
for qwe = 1:sz(2)
if (y(qw,qwe)==p(qw,qwe))
v = v+1;
end
end
end
op(n) = v;
Error(n) = (16-v)/16;
SNR(n) = sum((trans1+trans2).^2)/sum(noise.^2);
end
figure
plot(SNR, Error);

The following two functions are implemented and used:


function th = thresh(x)
if (x == [0 0])
th = -3;
elseif (x == [0 1])
th = -1;
elseif (x == [1 0])
th = 1;
else
th = 3;
end
end
function cb = th_back(x)
if (x==-3)
cb = [0 0];
elseif (x==-1)
cb = [0 1];
elseif (x==1)
cb = [1 0];
else
cb = [1 1];
end
end

Num in the code is the filter impulse response and is defined using FDA tool
A 31 order lowpass filter having cutoff frequency at 50Hz

Received and Transmitted Data:


The transmitted data with the noise having mean of -0.029 and variance of 97.62

The in-phase part of the received data is

The quadrature part is

Taking the mean of in-phase and quadrature parts we get the threshold close to that
of being transmitted.

SNR Vs BER curve

You might also like