You are on page 1of 24

AMERICAN INTERNATIONAL UNIVERSITY BANGLADESH

Faculty of Engineering
Laboratory Report Cover Sheet

Students must complete all details except the faculty use part.

Please submit all reports to your subject supervisor or the office of the concerned faculty.

Laboratory Title: ___________________________________________________


OBE Assessment Lab Project
Experiment Number: __OBE__ Due Date: 26/04/2021__ Semester: _Spring 2020-2021_
Subject Code: EEE 3211_ Subject Name: Principles of Communication Section: __C__
Course Instructor: NOWSHIN ALAM Degree Program: EEE

Declaration and Statement of Authorship:


1. I/we hold a copy of this report, which can be produced if the original is lost/ damaged.
2. This report is my/our original work and no part of it has been copied from any other student’s work or from
any other source except where due acknowledgement is made.
3. No part of this report has been written for me/us by any other person except where such collaboration has been
authorized by the lecturer/teacher concerned and is clearly acknowledged in the report.
I/we understand that
7. Plagiarism is the presentation of the work, idea or creation of another person as though it is your own. It is a
form of cheating and is a very serious academic offence that may lead to expulsion from the University.
Plagiarized material can be drawn from, and presented in, written, graphic and visual form, including electronic
data, and oral presentations. Plagiarism occurs when the origin of the material used is not appropriately cited.
8. Enabling plagiarism is the act of assisting or allowing another person to plagiarize or to copy your work

Group Number (if applicable): 1 Individual Submission Group Submission

No. Student Name Student Number Student Signature Date


Submitted by:

1 Adnan 19-39561-1
Group Members:

2 Ruham Rofique 19-39473-1

3 Foisal Ahmed 19-39512-1

4 Md Mazharul Islam 19-39555-1

5 Md. Shadman Shakif Bhuiyan 19-39495-1

For faculty use only:


Total Marks: _______ Marks Obtained: _______

Faculty comments___________________________________________________________________________
___________________________________________________________________________________________
American International University- Bangladesh (AIUB)
Faculty of Engineering

Principles of Communications
OBE Assessment Lab Project
Suppose, you want to send a message which contains your FULL NAME.
1. Convert the message to digital data.
2. Organize all binary data to send by serial transmission technique.
3. Convert digital data to digital signal using at least VAL1 sample data.
4. Now, modulate the digital signal (using QPSK or QAM) to send via a transmission channel.
5. Introduce some noise during transmission, assuming that the signal to noise ratio of the
channel is VAL2.
6. Demodulate the received signal.
7. Convert the binary data to retrieve the message.
8. Plot the signal at step 3, 4, 5, 6 and confirm if message in step 7 matches original message.
9. Find the threshold of SNR where transmitted signal starts getting distorted at the receiver.
Parameters:
Consider, your ID = AB-CDEFG-H.
VAL1 = EFB VAL2 = DH

Instructions:
1. Plagiarism is strictly prohibited.
2. Please use MATLAB software to accomplish the project.
3. Submit your lab project before the deadline.
4. Submission should be in PDF format. Add a cover page.
5. Finally submit it in the MS Teams assignment.
Mark distribution (to be filled by Faculty):
Project Attainment and Software Skill (Total Marks: 15)
Level (7.5-6) Level (5-3) Level (2-1) Secured
Objectives
(Proficient) (Good) (Acceptable) Marks
Only few
MATLAB All objectives are Objectives are satisfied at
objectives are
Coding satisfied major extent
satisfied
Results are attained at Only few results
Result All results are attained
major extent are attained
Viva Performance (Total Marks: 15)
Level (15-12) Level (11-6) Level (5-1) Secured
Name
(Proficient) (Good) (Acceptable) Marks
Capable to do the
Capable to do the Hardly capable to
analysis but cannot
analysis independently do the analysis
develop full system
Group 01 Member contributions:
No. Name ID Contributions
1 Adnan 19-39561-1 A. Code for Part 9 (looping)
B. Explanation of code of Part 9 (1st half)
2 Ruham Rofique 19-39473-1 A. Code for Step 1-2
B. Explanation of code of Step 1-2
3 Foisal Ahmed 19-39512-1 A. Code for Step 3-4
B. Explanation of code of Step 3-4
4 Md Mazharul Islam 19-39555-1 A. Introduction
B. Explanation of code of Step 5-6
5 Md. Shadman 19-39495-1 A. Code of Step 5-6
Shakif Bhuiyan B. Explanation of code of Part 9 (2nd half)
Introduction
Quadrature Phase Shift Keying (QPSK) is a form of Phase Shift Keying in which two bits are
modulated at once, selecting possible carrier phase shifts (0, 90, 180, or 270 degrees). QPSK uses
two carriers, one in-phase and the other quadrature but the amplitude is same for all. QPSK uses
four points on the constellation diagram, equal around a circle. With four phases, QPSK can
encode two bits per symbol. Instead of the conversion of digital bits into a series of digital stream,
it converts them into bit pairs. This decreases the data bit rate to half, which allows space for the
other users. QPSK allows the signal to carry twice as much information as ordinary PSK using
the same bandwidth. It provides high performance on bandwidth efficiency and bit error rate.
QPSK is used for wireless communication, mobile communication and satellite Communication.

Part 1:
Sending a message using QPSK modulation

Step 1: Decimal to Serial Binary Conversion

In this step our job is to convert a word from strings into ASCII encoding from where it would be
converted into binary numbers. It will be done by with one input and one output. We will send the
bits of every ASCII encoded character one after another. It will maintain a serial. One convention
that needs to be established is whether the LSB or MSB of each code is sent first. The ASCII code
has seven bits, it is customary to send 8 bits per character and set the MSB to zero. If the
convention of sending the LSB first is used, the word “Alhamdulliah” is converted to the binary
data sequence. This is done by the help of our user-defined function “asc2bin” in MATLAB.

‘asc2bin’ function:

function dn = asc2bn(txt)
dec=double(txt) %Text to ASCII (decimal)
p2=2.^(0:-1:-7) % 2^0,2^-1,.......,2^-7
B=mod(floor(p2'*dec),2) %Decimal to binary conversion
%Columns of B are bits of chars
dn=reshape(B,1,numel(B));%Bytes to serial conbversion
end
Word to ASCII Decimal to Serial Binary Conversion code:

clc;
clear all;
close all;

% Group: 1
% Name: Adnan
% ID: 19-39561-1
% ID: AB-CDEFG-H
amplitude = 11;
freq = 1939;
VAL1 = 569;
VAL2 = 91;

% bit rate
f=freq; % carrier frequency
br=f/100;
bp=1/br;

Transmitted_Message= 'Alhamdulillah'
%Converting Information Message to bit%
x=asc2bn(Transmitted_Message); % Binary Information

Output of Step 1:

Transmitted_Message =
Alhamdulillah

dec =
65 108 104 97 109 100 117 108 105 108 108 97 104

p2 =
1.0000 0.5000 0.2500 0.1250 0.0625 0.0313 0.0156 0.0078

Step 2: Representation of transmitting binary information as digital signal


After we have done step 1, now our job is to representation of the binary information as digital
signal. In this step, we used unipolar (non-return to zero) line coding scheme. We used set the
amplitude of the digital signal be 5 Volts when the binary digit is 1 and a 0 Volts when the binary
digit is 0. This 5 Volts and 0 Volts were samples for VAL1 times which is 569 times in our case
using Adnan’s student ID. Then we plot this digital signal in a graph to view the signal graphically.
Representing digital signal code:

%XXXXX Representation of transmitting binary information as


digital signal XXX
bit=[];
for n=1:1:length(x)
if x(n)==1;
se=5*ones(1,VAL1);
else x(n)==0;
se=zeros(1,VAL1);
end
bit=[bit se];
end
t1=bp/VAL1:bp/VAL1:VAL1*length(x)*(bp/VAL1);
figure(1)
subplot(4,1,1);
plot(t1,bit,'lineWidth',2.5);grid on;
axis([ 0 bp*length(x) -.5 6]);
ylabel('amplitude(volt)');
xlabel(' time(sec)');
title('Transmitting information as digital signal');

Output of Step 2:

Step 3: Modulating this serial data stream to waveform

We converted a text from string to a binary data sequence using ‘‘asc2bin’’ code in MATLAB.
The binary data sequence is then converted into a digital signal. Now in order to transmit the
signal, it must be converted into an analog signal.
In this case, we will perform QPSK modulation. QPSK: In quadrature phase shift keying, the
phase of the carrier signal is varied to create signal elements. Both frequency and amplitude
remain constant while the phase changes. In QPSK, 4 different phases are used for shift keying.
QPSK modulation code:

data_NZR=2*x-1; % Data Represented at NZR form for QPSK modulation


s_p_data=reshape(data_NZR,2,length(x)/2); % S/P convertion of data
T=1/f; % bit duration
t=T/(VAL1-1):T/(VAL1-1):T; % Time vector for one bit information
%XXXXXXXXXXXXXXXXXXXXXXX QPSK modulation
XXXXXXXXXXXXXXXXXXXXXXXXXXX
y=[];
y_in=[];
y_qd=[];
for(i=1:length(x)/2)
y1=amplitude*s_p_data(1,i)*cos(2*pi*f*t); % inphase component
y2=amplitude*s_p_data(2,i)*sin(2*pi*f*t) ;% Quadrature
component
y_in=[y_in y1]; % inphase signal vector
y_qd=[y_qd y2]; %quadrature signal vector
y=[y y1+y2]; % modulated signal vector
end
Tx_sig=y; % transmitting signal after modulation
tt=T/(VAL1-1):T/(VAL1-1):(T*length(x))/2;

figure(2)
subplot(3,1,1);
plot(tt,y_in,'linewidth',3), grid on;
title(' wave form for inphase component in QPSK modulation ');
xlabel('time(sec)');
ylabel(' amplitude(volt0');
subplot(3,1,2);
plot(tt,y_qd,'linewidth',3), grid on;
title(' wave form for Quadrature component in QPSK modulation ');
xlabel('time(sec)');
ylabel(' amplitude(volt0');
subplot(3,1,3);
plot(tt,Tx_sig,'r','linewidth',3), grid on;
title('QPSK modulated signal (sum of inphase and Quadrature phase
signal)');
xlabel('time(sec)');
ylabel(' amplitude(volt0');

figure(1)
subplot(4,1,2);
plot(tt,Tx_sig,'r','linewidth',3), grid on;
title('QPSK modulated signal (sum of inphase and Quadrature phase
signal)');
xlabel('time(sec)');
ylabel(' amplitude(volt0');
axis([ 0 0.0275 -20 20]);
QPSK Modulated graph:

Step 4: Addition of noise


Now, before demodulation noise have to be considered. We have to introduce noise in MATLAB
and it must be added to the transmitted signal so that it can present a real-life scenario. This signal
is being transmitted from one place to another in real life. As this is a simulation, we can replicate
the real case by adding noise to the signal by ourself. This can be done by lowering the SNRdB
as this means that noise is added to the system. According to the question, we will be using SNR
value of VAL2, which is 91 according to the student ID we are using. We used the AWGN,
Additive white Gaussian noise, function to set the SNRdB value of 91.
Representing digital signal code:

%Channel Noise%
Tx_sig_noise=awgn(Tx_sig,VAL2);
figure(1)
subplot(4,1,3);
plot(tt,Tx_sig_noise,'r'), grid on;
axis([ 0 0.0275 -20 20]);
xlabel('time(sec)');
ylabel('amplitude(volt)');
title('Received signal at Receiver');

Signal after adding noise to it:

Step 4: QPSK Demodulation of the noisy analog signal.


Later as disturbance is added to the system, we will assume that the signal has transmitted and to
now we will have to demodulate the signal. This is the code for demodulating the signal. And the
we will be converting it to digital signal again as we have done previously in step 2.
Representing digital signal code:

% XXXXXXXXXXXXXXXXXXXXXXXXXXXX QPSK demodulation


XXXXXXXXXXXXXXXXXXXXXXXXXX
Rx_data=[];
Rx_sig=Tx_sig_noise; % Received signal
for(i=1:1:length(x)/2)
%%XXXXXX inphase coherent dector XXXXXXX
Z_in=Rx_sig((i-1)*length(t)+1:i*length(t)).*cos(2*pi*f*t);
% above line indicat multiplication of received & inphase
carred signal

Z_in_intg=(trapz(t,Z_in))*(2/T);% integration using trapizodial


rull
if(Z_in_intg>0) % Decession Maker
Rx_in_data=1;
else
Rx_in_data=0;
end

%%XXXXXX Quadrature coherent dector XXXXXX


Z_qd=Rx_sig((i-1)*length(t)+1:i*length(t)).*sin(2*pi*f*t);
%above line indicat multiplication ofreceived & Quadphase
carred signal

Z_qd_intg=(trapz(t,Z_qd))*(2/T);%integration using trapizodial


rull
if (Z_qd_intg>0)% Decession Maker
Rx_qd_data=1;
else
Rx_qd_data=0;
end

Rx_data=[Rx_data Rx_in_data Rx_qd_data]; % Received Data


vector
end
%XXXXX Representation of binary information as digital signal which
is achived
%after QPSK
demodulationXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

bit=[];
for n=1:length(Rx_data);
if Rx_data(n)==1;
se=5*ones(1,VAL1);
else Rx_data(n)==0;
se=zeros(1,VAL1);
end
bit=[bit se];
end
t5=bp/VAL1:bp/VAL1:VAL1*length(Rx_data)*(bp/VAL1);
figure(1)
subplot(4,1,4)
plot(t5,bit,'LineWidth',2.5);grid on;
axis([ 0 bp*length(Rx_data) -.5 6]);
ylabel('amplitude(volt)');
xlabel(' time(sec)');
title('Demodulated signal at receiver');

Output after demodulating:


Output in command window:

B=
1 0 0 1 1 0 1 0 1 0 0 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 0 0 1 1 1 1 0 1 1 0 0
0 1 1 0 1 0 0 1 1 1 1 0 1
0 0 0 0 0 0 1 0 0 0 0 0 0
0 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 0 0 0 0 0

Step 5: Conversion from Serial Binary to Text


Serial Binary to Text Conversion: If sequence A is successfully transferred and received at the
channel output, the next move is to transform it back to a text string. This necessitates the
decomposition of the binary data string into 8-bit segments (with any extra bits removed at the
end), which are then converted back to decimal ASCII codes, which can then be displayed as text
using the char function. We used a user defined function called ‘bin2asc’ which works as follows:

‘bin2asc’ function code:

function txt = bin2asc(dn)


%bin2asc Serial binary to ASCII to text conversion
% 8 bits per char , LSB first
% >> txt= bin2asc(dn) <<
% where dn is binary input sequence
% txt is output text string
L=length(dn); %Length of input string
L8=8*floor(L/8); %Multiple of 8 Length
B=reshape(dn(1:L8),8,L8/8); %Cols of B are bits of chars
p2=2.^(0:7); %power of 2
dec=p2*B; %Binary to decimal conversion
txt=char(dec); %ASCII (decimal) to txt
end
Serial Binary to ASCII Decimal to text Conversion code:

%Converting Information bit to Message%


Received_Message=bin2asc(Rx_data)
%>>>>>>>> end of program >>>>>>>>>>>>>>>>%

Output of this part:

Code for part 1 as a whole:


clc;
clear all;
close all;

% Group: 1
% Name: Adnan
% ID: 19-39561-1
% ID: AB-CDEFG-H
amplitude = 11;
freq = 1939;
VAL1 = 569;
VAL2 = 91;

% bit rate
f=freq; % carrier frequency
br=f/100;
bp=1/br;

Transmitted_Message= 'Alhamdulillah'
%Converting Information Message to bit%
x=asc2bn(Transmitted_Message); % Binary Information

%XXXXX Representation of transmitting binary information as digital


signal XXX
bit=[];
for n=1:1:length(x)
if x(n)==1;
se=5*ones(1,VAL1);
else x(n)==0;
se=zeros(1,VAL1);
end
bit=[bit se];
end
t1=bp/VAL1:bp/VAL1:VAL1*length(x)*(bp/VAL1);
figure(1)
subplot(4,1,1);
plot(t1,bit,'lineWidth',2.5);grid on;
axis([ 0 bp*length(x) -.5 6]);
ylabel('amplitude(volt)');
xlabel(' time(sec)');
title('Transmitting information as digital signal');

data_NZR=2*x-1; % Data Represented at NZR form for QPSK modulation


s_p_data=reshape(data_NZR,2,length(x)/2); % S/P convertion of data
T=1/f; % bit duration
t=T/(VAL1-1):T/(VAL1-1):T; % Time vector for one bit information
%XXXXXXXXXXXXXXXXXXXXXXX QPSK modulation XXXXXXXXXXXXXXXXXXXXXXXXXXX
y=[];
y_in=[];
y_qd=[];
for(i=1:length(x)/2)
y1=amplitude*s_p_data(1,i)*cos(2*pi*f*t); % inphase component
y2=amplitude*s_p_data(2,i)*sin(2*pi*f*t) ;% Quadrature component
y_in=[y_in y1]; % inphase signal vector
y_qd=[y_qd y2]; %quadrature signal vector
y=[y y1+y2]; % modulated signal vector
end
Tx_sig=y; % transmitting signal after modulation
tt=T/(VAL1-1):T/(VAL1-1):(T*length(x))/2;

figure(2)
subplot(3,1,1);
plot(tt,y_in,'linewidth',3), grid on;
title(' wave form for inphase component in QPSK modulation ');
xlabel('time(sec)');
ylabel(' amplitude(volt0');
subplot(3,1,2);
plot(tt,y_qd,'linewidth',3), grid on;
title(' wave form for Quadrature component in QPSK modulation ');
xlabel('time(sec)');
ylabel(' amplitude(volt0');
subplot(3,1,3);
plot(tt,Tx_sig,'r','linewidth',3), grid on;
title('QPSK modulated signal (sum of inphase and Quadrature phase
signal)');
xlabel('time(sec)');
ylabel(' amplitude(volt0');

figure(1)
subplot(4,1,2);
plot(tt,Tx_sig,'r','linewidth',3), grid on;
title('QPSK modulated signal (sum of inphase and Quadrature phase
signal)');
xlabel('time(sec)');
ylabel(' amplitude(volt0');
axis([ 0 0.0275 -20 20]);

%Channel Noise%
Tx_sig_noise=awgn(Tx_sig,VAL2);
figure(1)
subplot(4,1,3);
plot(tt,Tx_sig_noise,'r'), grid on;
axis([ 0 0.0275 -20 20]);
xlabel('time(sec)');
ylabel('amplitude(volt)');
title('Received signal at Receiver');

% XXXXXXXXXXXXXXXXXXXXXXXXXXXX QPSK demodulation


XXXXXXXXXXXXXXXXXXXXXXXXXX
Rx_data=[];
Rx_sig=Tx_sig_noise; % Received signal
for(i=1:1:length(x)/2)
%%XXXXXX inphase coherent dector XXXXXXX
Z_in=Rx_sig((i-1)*length(t)+1:i*length(t)).*cos(2*pi*f*t);
% above line indicat multiplication of received & inphase carred
signal

Z_in_intg=(trapz(t,Z_in))*(2/T);% integration using trapizodial


rull
if(Z_in_intg>0) % Decession Maker
Rx_in_data=1;
else
Rx_in_data=0;
end

%%XXXXXX Quadrature coherent dector XXXXXX


Z_qd=Rx_sig((i-1)*length(t)+1:i*length(t)).*sin(2*pi*f*t);
%above line indicat multiplication ofreceived & Quadphase carred
signal

Z_qd_intg=(trapz(t,Z_qd))*(2/T);%integration using trapizodial


rull
if (Z_qd_intg>0)% Decession Maker
Rx_qd_data=1;
else
Rx_qd_data=0;
end

Rx_data=[Rx_data Rx_in_data Rx_qd_data]; % Received Data


vector
end
%XXXXX Representation of binary information as digital signal which
is achived
%after QPSK
demodulationXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

bit=[];
for n=1:length(Rx_data);
if Rx_data(n)==1;
se=5*ones(1,VAL1);
else Rx_data(n)==0;
se=zeros(1,VAL1);
end
bit=[bit se];
end
t5=bp/VAL1:bp/VAL1:VAL1*length(Rx_data)*(bp/VAL1);
figure(1)
subplot(4,1,4)
plot(t5,bit,'LineWidth',2.5);grid on;
axis([ 0 bp*length(Rx_data) -.5 6]);
ylabel('amplitude(volt)');
xlabel(' time(sec)');
title('Demodulated signal at receiver');

%Converting Information bit to Message%


Received_Message=bin2asc(Rx_data)
%>>>>>>>> end of program >>>>>>>>>>>>>>>>%
% XXXXXXXXXXXXXXXXXXXXXXXXX end of program
XXXXXXXXXXXXXXXXXXXXXXXXXX
Output for part 1 all together:
Part 2:
Finding the Threshold of SNR until original message can be successfully received.
In this part, we have to find the minimum SNRdB of the sent signal that allows us to retrieve the
original message back that was sent. Beyond the threshold value, the received analog signal would
not be recognizable at all and hence the original message cannot be retrieved.
So in this code, we used a for loop to repeat the steps of the sending and receiving data. We
removed the figure codes from previous code as we don’t need to view the graphs every time. We
looped it for different values of SNRdB. I used an array to store all the transmitted and received
messages for every SNRdB so that we can compare that where is the threshold of SNR. Later I
wrote some code to view the sending the receiving text messages side by side. This would allow
us to see in which part did the message got distorted. Later I wrote some code to show if the
sending message and the receiving message is exactly the same or not. If they are same, the value
‘1’ would be returned and if not, ‘0’ would be returned. This allows us not to look for the distortion
in the text message manually. So when the 1st distortion occurs, that is when the message is not
being retracted properly and so the last SNR when the message was received correctly would be
the threshold SNR.
I wrote a small code for this as well, for us to determine when the 1st time the message is not the
same, and it returns the SNR value when last time the receiving message was the same as sending
message. In our case, I wrote the word “Alhamdulillah”
With this word “Alhamdulillah”, the Threshold of SNR seems to be at around -39dB. Beyond
that, the message gets distorted. If this decibel value is being converted to SNR ratio, the ratio is
0.000126.

Matlab Code for part 2:


clc;
clear all;
close all;
% Group: 1
% Name: Adnan
% ID: 19-39561-1
% ID: AB-CDEFG-H

amplitude = 11;
freq = 1939;
VAL1 = 569;
VAL2 = 91;

% bit rate
f=freq; % carrier frequency
br=f/100;
bp=1/br;
Transmitted_Message= 'Alhamdulillah'
%Converting Information Message to bit%
x=asc2bn(Transmitted_Message); % Binary Information

count = 0;
sending = [];
recieving = [];
gap = [];
SNR_dB = [];
loop_number = [];
match_gate = [];
snr = [];

for VAL2 = -40:-30

SNR_dB = [SNR_dB VAL2];


gap = [gap ' '];
count = count+1;
loop_number = [loop_number count];
sending = [sending; Transmitted_Message];

%XXXXX Representation of transmitting binary information as


digital signal XXX
bit=[];
for n=1:1:length(x)
if x(n)==1;
se=5*ones(1,VAL1);
else x(n)==0;
se=zeros(1,VAL1);
end
bit=[bit se];
end
t1=bp/VAL1:bp/VAL1:VAL1*length(x)*(bp/VAL1);

data_NZR=2*x-1; % Data Represented at NZR form for QPSK


modulation
s_p_data=reshape(data_NZR,2,length(x)/2); % S/P convertion of
data
T=1/f; % bit duration
t=T/(VAL1-1):T/(VAL1-1):T; % Time vector for one bit information

%XXXXXXXXXXXXXXXXXXXXXXX QPSK modulation


XXXXXXXXXXXXXXXXXXXXXXXXXXX
y=[];
y_in=[];
y_qd=[];
for(i=1:length(x)/2)
y1=amplitude*s_p_data(1,i)*cos(2*pi*f*t); % inphase component
y2=amplitude*s_p_data(2,i)*sin(2*pi*f*t) ;% Quadrature
component
y_in=[y_in y1]; % inphase signal vector
y_qd=[y_qd y2]; %quadrature signal vector
y=[y y1+y2]; % modulated signal vector
end
Tx_sig=y; % transmitting signal after modulation
tt=T/(VAL1-1):T/(VAL1-1):(T*length(x))/2;

%Channel Noise%
Tx_sig_noise=awgn(Tx_sig,VAL2);

% XXXXXXXXXXXXXXXXXXXXXXXXXXXX QPSK demodulation


XXXXXXXXXXXXXXXXXXXXXXXXXX
Rx_data=[];
Rx_sig=Tx_sig_noise; % Received signal
for(i=1:1:length(x)/2)
%%XXXXXX inphase coherent dector XXXXXXX
Z_in=Rx_sig((i-1)*length(t)+1:i*length(t)).*cos(2*pi*f*t);
% above line indicat multiplication of received & inphase
carred signal

Z_in_intg=(trapz(t,Z_in))*(2/T);% integration using


trapizodial rull
if(Z_in_intg>0) % Decession Maker
Rx_in_data=1;
else
Rx_in_data=0;
end

%%XXXXXX Quadrature coherent dector XXXXXX


Z_qd=Rx_sig((i-1)*length(t)+1:i*length(t)).*sin(2*pi*f*t);
%above line indicat multiplication ofreceived & Quadphase
carred signal

Z_qd_intg=(trapz(t,Z_qd))*(2/T);%integration using
trapizodial rull
if (Z_qd_intg>0)% Decession Maker
Rx_qd_data=1;
else
Rx_qd_data=0;
end

Rx_data=[Rx_data Rx_in_data Rx_qd_data]; % Received


Data vector
end

%XXXXX Representation of binary information as digital signal


which is achived
%after QPSK
demodulationXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

bit=[];
for n=1:length(Rx_data);
if Rx_data(n)==1;
se=5*ones(1,VAL1);
else Rx_data(n)==0;
se=zeros(1,VAL1);
end
bit=[bit se];
end
t5=bp/VAL1:bp/VAL1:VAL1*length(Rx_data)*(bp/VAL1);

%Converting Information bit to Message%


Received_Message=bin2asc(Rx_data);
%>>>>>>>> end of program >>>>>>>>>>>>>>>>%

recieving = [recieving; Received_Message];

match = 0;
for i = 1:length(Transmitted_Message)

if Transmitted_Message(i) == Received_Message(i)
match = match+1;
else
match = match;
end

end
match;
if match == length(Transmitted_Message)
match_gate = [match_gate 1];
else
match_gate = [match_gate 0];
end

ratiod = 10^(VAL2/10);
snr = [snr real(round(ratiod))];

end

disp('Sending Message Recieving Message')


Send_Recv = [sending gap' recieving]

disp('Loop SNR_dB SNR_Ratio Match')


Info_loop = [loop_number' SNR_dB' snr' match_gate']

for i = 1:length(match_gate)
if (match_gate(i)==0 && match_gate(i+i)==1)
Threshold_SNR_dB = Info_loop(i+1,2);
break
end
end
Conclusion = sprintf('Threshold of SNR (dB): %.2f', Threshold_SNR_dB)
SNR_ratioo = 10^(Threshold_SNR_dB/10);
Conclusion = sprintf('Threshold of SNR (ratio): %12f', SNR_ratioo)

Output of the code:

You might also like