Finalised Ad Communication Lab Manual 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 58

LAB MANUAL

Of

ADVANCED COMMUNICATION LAB


For

VIIIth semester
Integrated M.Tech ICT

Prepared by
SYED GILANI PASHA
Assistant Professor ECE

Department of Electronics and Communication Engineering


SCHOOL OF ENGINEERING
Central University of Karnataka
Kadaganchi, Kalaburagi -585367
Lab Manual ADVANCED COMMUNICATION LAB

All Experiments to be simulated using MATLAB software

Sl No. Name of Experiments Using MATLAB

01 Measurement of Bit Error Rate (BER) using binary data

02 Verification of minimum distance of Hamming Code

03 Determination of output of Convolutional Encoder for a given sequence

04 Determination of output of Convolutional Decoder for a given sequence

05 Design of Amplitude Shifting Keying system

06 Design of Phase Shifting Keying system

07 Design of Frequency Shifting Keying system

08 DPSK Modulation and Demodulation techniques

09 QPSK Modulation and Demodulation techniques

10 Implementation of QPSK Modulation with Rayleigh Fading and AWGN channel

11 16-QAM Modulation and Demodulation techniques

12 Direct Sequence Spread Spectrum Technique

13 Simulation of Frequency Hopping (FH) Spread- Spectrum

14 OFDM modulation and demodulation

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 2


Lab Manual ADVANCED COMMUNICATION LAB

Introduction to MATLAB
MATLAB (the name stands for MATrix LABoratory) is an interactive system for solving
scientific and technical computing problems. The basic data elements are arrays in one or more
dimensions. The original purpose was to create a user interface that provides easy access to free
matrix software (EISPACK and LINPACK) that was developed in 19721973 in FORTRAN.
Over time MATLAB has evolved into a standard educational tool as well as a high-productivity
tool for industrial research and implementations. The MATLAB system now consists of a
desktop tool and workspace, a mathematical function library, a programming language, and an
extensive set of graphics facilities. MATLAB can be used directly in interactive mode by typing
commands one line at a time, or m-files (either scripts or functions) which contain code in the
MATLAB programming language can be run.

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 3


Lab Manual ADVANCED COMMUNICATION LAB

EXPERIMENT NO: 1
Measurement of BIT ERROR RATE (BER) using binary data

Aim: To measure Bit Error Rate (BER) of binary data


Apparatus: Personal Computer/laptop with i5 processor, MATLAB software
Theory: In digital transmission, the number of bit errors is the number of received bits of a data
stream over a communication channel that have been altered due to noise, interference, distortion
or bit synchronization errors. The bit error rate or bit error ratio (BER) is the number of bit errors
divided by the total number of transferred bits during a studied time interval. BER is a unitless
performance measure, often expressed as a percentage.

The bit error probability pe is the expectation value of the BER. The BER can be
considered as an approximate estimate of the bit error probability. This estimate is accurate for a
long time interval and a high number of bit errors.

As an example, assume this transmitted bit sequence:

0110001011

and the following received bit sequence:

0010101001

The number of bit errors (the underlined bits) is in this case 3. The BER is 3 incorrect bits
divided by 10 transferred bits, resulting in a BER of 0.3 or 30%.

Website: http://www.dsplog.com/
PROCEDURE:

1. Switch on the personal computer/laptop


2. Open mat lab software
3. Open new editor m-file
4. Write the program
5. Save it in the particular folder
6. Debug the program for verification
7. Click Run bottom
8. You can observe the output

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 4


Lab Manual ADVANCED COMMUNICATION LAB

MATLAB PROGRAM:-

clc; % Clears the command window


clear all; % Clears the work space
close all; % Clears the figure window
n=32; % Length of code word
k=15; % Length of messages
dmin=6; % Minimum distance
ebno=1:20;
ber_block=bercoding(ebno,'block','hard',n,k,dmin);
berfit(ebno,ber_block); % Plots BER points & fitted curve
xlabel('ebno(db)'); % Representing x axis
ylabel('bit error probability'); % Representing y axis
title('ber upper bound vs. ebno, with best curve fit'); % Representing title

Result: Bit Error Rate is measured using binary data.

ber upper bound vs ebno, with best curve fit


0
10

-10
10

-20
10
bit error probability

-30
10

-40
10

-50
10

Empirical BER
-60
10 Exp Fit

0 2 4 6 8 10 12 14 16 18 20
ebno(db)

EXPERIMENT NO: 2
Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 5
Lab Manual ADVANCED COMMUNICATION LAB

Verification of minimum distance of HAMMING Code


Aim: To find the minimum distance of Hamming code
Apparatus: Personal Computer/laptop with i5 processor, MATLAB software
Theory: The number of corresponding bits that differ between two code words is the Hamming
distance of those two code words. For example, the Hamming distance between the code words
1001 and 0101 is 2. The Hamming distance of two code words can be calculated as the number
of 1 bits in the bitwise exclusive-or of the two code words: 1001 xor 0101 = 1100.

A code is the set of all code words of a given length that are constructed by adding a
specified number of check digits in a specified way to a specified number of data bits. The
minimum Hamming distance of a code is the minimum of the Hamming distance between all
possible pairs of code words of that code. The following table indicates the Hamming distance
between all pairs of a simple 4-bit binary code:

The Hamming distances between code words of a simple 4-bit code.


In the below example shown the minimum Hamming distance between any two code words is
2, the Hamming distance of the code is 2.

0000 0011 0101 0110 1001 1010 1100 1111

0000 - 2 2 2 2 2 2 4

0011 2 - 2 2 2 2 4 2

0101 2 2 - 2 2 4 2 2

0110 2 2 2 - 4 2 2 2

1001 2 2 2 4 - 2 2 2

1010 2 2 4 2 2 - 2 2

1100 2 4 2 2 2 2 - 2

1111 4 2 2 2 2 2 2 -

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 6


Lab Manual ADVANCED COMMUNICATION LAB

PROCEDURE:

1. Switch on the personal computer


2. Open matlab software
3. Open new editor m file
4. Write the program
5. Save it in the particular folder
6. Debug the program for verification

MATLAB PROGRAM:-

clc; % Clears the command window


clear all; % Clears the work space
close all; % Clears the figure window
m=3;
n=2^m-1; % Code word length
k=4; % Message length
msg=[0 0 0 0; 0 0 0 1; 0 0 1 0;0 0 1 1;0 1 0 0;0 1 0 1;0 1 1 0;0 1 1 1];
code1=encode(msg,n,k,'hamming/binary'); % Encodes msg using hamming encoding
code2=num2str(code1); % Converts array A into a string
code=bin2dec(code2); % Interprets the binary string binstr & r
% Returns the equalent decimal number
number1=[]; % One decimal array of matrix
for i=1:8;
for j=i+1:8;
[number]=biterr(code(i),code(j),7); % Compares code(i) & code(j) element
number1=[number1 number];
end
end
minidistance=min(number1) % Returns the smallest elements

Result: Minimum distance of HAMMING code is verified


minidistance = 3

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 7


Lab Manual ADVANCED COMMUNICATION LAB

EXPERIMENT NO: 3
Determination of output of Convolutional Encoder for a given sequence

Aim: To Determine the output of convolutional encoder for a given sequence

Apparatus: Personal Computer/laptop with i5 processor, MATLAB software

Theory:
Convolutional codes are used extensively in numerous applications in order to achieve
reliable data transfer, including digital video, radio, mobile communication, and satellite
communication. To convolutionally encode data, start with k memory registers, each holding 1
input bit. Unless otherwise specified, all memory registers start with a value of 0. The encoder
has n modulo-2 adders, and n generator polynomials one for each adder. An input bit m1 is
fed into the leftmost register. Using the generator polynomials and the existing values in the
remaining registers, the encoder outputs n bits. Now bit shift all register values to the right and
wait for the next input bit. If there are no remaining input bits, the encoder continues output until
all registers have returned to the zero state.

PROCEDURE:

1. Switch on the personal computer


2. Open matlab software
3. Open new editor m file
4. Write the program
5. Save it in the particular folder
MATLAB PROGRAM:-

clc; % Clears the command window


clear all; % Clears the workspace
close all; % Clears the figure window
g=input('enter the generator polynomial coefficient') ; % Providing Input

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 8


Lab Manual ADVANCED COMMUNICATION LAB

[n,k]=size(g) % Calculates n and constrained


lengths
m=k-1 % Number of registers
state=zeros(1,m) % Set registers to zero
input1=input('enter the message bits') % Input the message bits
b=zeros(1,m) % Generate row matrix of length m
inputx=[input1,b] % Zero Padding
[trash,h]=size(inputx)
outputy=[]
for x=1:h
input=inputx(1,x)
for i=1:n
output(i)=g(i,1)*input
for j=2:k
z=g(i,j)*state(j-1)
output(i)=xor(output(i),z)
end
end
state=[input,state(1:m-1)]
outputy=[outputy,output] % New element added to sequence
end
outputy % Final encoder output

RESULT: Output of Convolutional encoder is determined for a given sequence

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 9


Lab Manual ADVANCED COMMUNICATION LAB

EXPERIMENT NO: 4

Determination of output of Convolutional Decoder for a given sequence

Aim: To determine output of convolutional Decoder for a given sequence

Apparatus: Personal Computer/laptop with i5 processor, MATLAB software

Theory: Several algorithms exist for decoding convolutional codes. For relatively small values
of k, the Viterbi algorithm is universally used as it provides maximum likelihood performance
and is highly parallelizable. Viterbi decoders are thus easy to implement in VLSI hardware and
in software on CPUs with SIMD instruction sets.

Longer constraint length codes are more practically decoded with any of several
sequential decoding algorithms, of which the Fano algorithm is the best known. Unlike Viterbi
decoding, sequential decoding is not maximum likelihood but its complexity increases only
slightly with constraint length, allowing the use of strong, long-constraint-length codes. Such
codes were used in the Pioneer program of the early 1970s to Jupiter and Saturn, but gave way to
shorter, Viterbi-decoded codes, usually concatenated with large Reed-Solomon error correction
codes that steepen the overall bit-error-rate curve and produce extremely low residual undetected
error rates. Both Viterbi and sequential decoding algorithms return hard decisions: the bits that
form the most likely codeword. An approximate confidence measure can be added to each bit by
use of the Soft output Viterbi algorithm.

PROCEDURE:
1. Switch on the personal computer
2. Open MATLAB software
3. Open new editor m file
4. Write the program
5. Save it in the particular folder
6. Debug the program for verification

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 10


Lab Manual ADVANCED COMMUNICATION LAB

MATLAB PROGRAM:-

clc; % Clears the command window


clear all; % Clears the workspace
close all; % Clears the figure window
tb=2;
% Length of positive integer scalar
t=poly2trellis([3],[7,5]); % Converting the convolution code
polynomials encoded_sequence=[1 1 0 0 1 1]
decoded= vitdec(encoded_sequence,t,tb,'trunc','hard'); % Decoding using Viterbi Algorithm

RESULT: The output of convolutional decoder is determined for a given sequence.

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 11


Lab Manual ADVANCED COMMUNICATION LAB

EXPERIMENT NO: 5
AMPLITUDE SHIFT KEYING

Aim: To generate and demodulate amplitude shift keyed (ASK) signal using MATLAB
Theory
Generation of ASK
Amplitude shift keying - ASK - is a modulation process, which imparts to a sinusoid two or more
discrete amplitude levels. These are related to the number of levels adopted by the digital
message. For a binary message sequence there are two levels, one of which is typically zero. The
data rate is a sub-multiple of the carrier frequency. Thus the modulated waveform consists of
bursts of a sinusoid. One of the disadvantages of ASK, compared with FSK and PSK, for
example, is that it has not got a constant envelope. This makes its processing (eg, power
amplification) more difficult, since linearity becomes an important factor. However, it does make
for ease of demodulation with an envelope detector.
Demodulation
ASK signal has a well defined envelope. Thus it is amenable to demodulation by an envelope
detector. Some sort of decision-making circuitry is necessary for detecting the message. The
signal is recovered by using a correlator and decision making circuitry is used to recover the
binary sequence.
Algorithm
Initialization commands
ASK modulation
1. Generate carrier signal.
2. Start FOR loop
3. Generate binary data, message signal(on-off form)
4. Generate ASK modulated signal.
5. Plot message signal and ASK modulated signal.
6. End FOR loop.
7. Plot the binary data and carrier.

ASK demodulation
1. Start FOR loop
2. Perform correlation of ASK signal with carrier to get decision variable
3. Make decision to get demodulated binary data. If x>0, choose 1 else choose 0
4. Plot the demodulated binary data.

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 12


Lab Manual ADVANCED COMMUNICATION LAB

MATLAB PROGRAM:-

%ASK Modulation
clc;
clear all;
close all;
%GENERATE CARRIER SIGNAL
Tb=1; fc=10;
t=0:Tb/100:1;
c=sqrt(2/Tb)*sin(2*pi*fc*t);
%generate message signal
N=8;
m=rand(1,N);
t1=0;t2=Tb
for i=1:N
t=[t1:.01:t2]
if m(i)>0.5
m(i)=1;
m_s=ones(1,length(t));
else
m(i)=0;
m_s=zeros(1,length(t));
end
message(i,:)=m_s;
%product of carrier and message
ask_sig(i,:)=c.*m_s;
t1=t1+(Tb+.01);
t2=t2+(Tb+.01);
%plot the message and ASK signal
subplot(5,1,2);axis([0 N -2 2]);plot(t,message(i,:),'r');
title('message signal');xlabel('t--->');ylabel('m(t)');grid on
hold on
subplot(5,1,4);plot(t,ask_sig(i,:));
title('ASK signal');xlabel('t--->');ylabel('s(t)');grid on
hold on
end
hold off
%Plot the carrier signal and input binary data
subplot(5,1,3);plot(t,c);
title('carrier signal');xlabel('t--->');ylabel('c(t)');grid on
subplot(5,1,1);stem(m);
title('binary data bits');xlabel('n--->');ylabel('b(n)');grid on

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 13


Lab Manual ADVANCED COMMUNICATION LAB

% ASK Demodulation
t1=0;t2=Tb
for i=1:N
t=[t1:Tb/100:t2]
%correlator
x=sum(c.*ask_sig(i,:));
%decision device
if x>0
demod(i)=1;
else
demod(i)=0;
end
t1=t1+(Tb+.01);
t2=t2+(Tb+.01);
end
%plot demodulated binary data bits
subplot(5,1,5);stem(demod);
title('ASK demodulated signal'); xlabel('n--->');ylabel('b(n)');grid on

Model Graphs

RESULT
The program for ASK modulation and demodulation has been simulated in MATLAB and
necessary graphs are plotted.

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 14


Lab Manual ADVANCED COMMUNICATION LAB

EXPERIMENT NO: 6
PHASE SHIFT KEYING

Aim: To generate and demodulate phase shift keyed (PSK) signal using MATLAB
Generation of PSK signal
PSK is a digital modulation scheme that conveys data by changing, or modulating, the phase of a
reference signal (the carrier wave). PSK uses a finite number of phases, each assigned a unique
pattern of binary digits. Usually, each phase encodes an equal number of bits. Each pattern of
bits forms the symbol that is represented by the particular phase. The demodulator, which is
designed specifically for the symbol-set used by the modulator, determines the phase of the
received signal and maps it back to the symbol it represents, thus recovering the original data.
In a coherent binary PSK system, the pair of signal S1(t) and S2 (t) used to represent binary
symbols 1 & 0 are defined by
S1 (t) = 2Eb/ Tb Cos 2fct
S2 (t) =2Eb/Tb (2fct+) = - 2Eb/Tb Cos 2fct where 0 t< Tb and
Eb = Transmitted signed energy for bit
The carrier frequency fc =n/Tb for some fixed integer n.
Antipodal Signal:
The pair of sinusoidal waves that differ only in a relative phase shift of 180 are called antipodal
signals.
BPSK Transmitter

The input binary symbols are represented in polar form with symbols 1 & 0 represented by
constant amplitude levels Eb & -Eb. This binary wave is multiplied by a sinusoidal carrier in a
product modulator. The result in a BSPK signal.

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 15


Lab Manual ADVANCED COMMUNICATION LAB

The received BPSK signal is applied to a correlator which is also supplied with a locally
generated reference signal c1 (t). The correlated o/p is compared with a threshold of zero volts. If
x> 0, the receiver decides in favour of symbol 1. If x< 0, it decides in favour of symbol 0.
Algorithm
Initialization commands
PSK modulation
1. Generate carrier signal.
2. Start FOR loop
3. Generate binary data, message signal in polar form
4. Generate PSK modulated signal.
5. Plot message signal and PSK modulated signal.
6. End FOR loop.
7. Plot the binary data and carrier.

PSK demodulation
1. Start FOR loop
Perform correlation of PSK signal with carrier to get decision variable
Make decision to get demodulated binary data. If x>0, choose 1 else choose 0
Plot the demodulated binary data.

MATLAB PROGRAM:-

% PSK modulation
clc;
clear all;
close all;
%GENERATE CARRIER SIGNAL
Tb=1;
t=0:Tb/100:Tb;
fc=2;
c=sqrt(2/Tb)*sin(2*pi*fc*t);
%generate message signal
N=8;
m=rand(1,N);
t1=0;t2=Tb
for i=1:N
t=[t1:.01:t2]
if m(i)>0.5
m(i)=1;
m_s=ones(1,length(t));
else
m(i)=0;
m_s=-1*ones(1,length(t));
end
message(i,:)=m_s;
%product of carrier and message signal

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 16


Lab Manual ADVANCED COMMUNICATION LAB

bpsk_sig(i,:)=c.*m_s;
%Plot the message and BPSK modulated signal
subplot(5,1,2);axis([0 N -2 2]);plot(t,message(i,:),'r');
title('message signal(POLAR form)');xlabel('t--->');ylabel('m(t)');
grid on; hold on;
subplot(5,1,4);plot(t,bpsk_sig(i,:));
title('BPSK signal');xlabel('t--->');ylabel('s(t)');
grid on; hold on;
t1=t1+1.01; t2=t2+1.01;
end
hold off
%plot the input binary data and carrier signal
subplot(5,1,1);stem(m);
title('binary data bits');xlabel('n--->');ylabel('b(n)');
grid on;
subplot(5,1,3);plot(t,c);
title('carrier signal');xlabel('t--->');ylabel('c(t)');
grid on;

% PSK Demodulation
t1=0;t2=Tb
for i=1:N
t=[t1:.01:t2]
%correlator
x=sum(c.*bpsk_sig(i,:));
%decision device
if x>0
demod(i)=1;
else
demod(i)=0;
end
t1=t1+1.01;
t2=t2+1.01;
end
%plot the demodulated data bits
subplot(5,1,5);stem(demod);
title('demodulated data');xlabel('n--->');ylabel('b(n)');
grid on

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 17


Lab Manual ADVANCED COMMUNICATION LAB

Modal Graphs

Result
The program for PSK modulation and demodulation has been simulated in MATLAB and
necessary graphs are plotted.

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 18


Lab Manual ADVANCED COMMUNICATION LAB

EXPERIMENT NO: 7
FREQUENCY SHIFT KEYING

Aim: To generate and demodulate frequency shift keyed (FSK) signal using MATLAB

Theory
Generation of FSK
Frequency-shift keying (FSK) is a frequency modulation scheme in which digital information is
transmitted through discrete frequency changes of a carrier wave. The simplest FSK is binary
FSK (BFSK). BFSK uses a pair of discrete frequencies to transmit binary (0s and 1s)
information. With this scheme, the "1" is called the mark frequency and the "0" is called the
space frequency.
In binary FSK system, symbol 1 & 0 are distinguished from each other by transmitting one of the
two sinusoidal waves that differ in frequency by a fixed amount.
Si (t) = 2E/Tb cos 2f1t 0 t Tb
0 elsewhere
Where i=1, 2 & Eb=Transmitted energy/bit
Transmitted freq= i = (nc+i)/Tb, and n = constant (integer), Tb = bit interval
Symbol 1 is represented by S1 (t)
Symbol 0 is represented by S0 (t)

BFSK Transmitter

The input binary sequence is represented in its ON-OFF form, with symbol 1 represented by
constant amplitude of Eb with & symbol 0 represented by zero volts. By using inverter in the
lower channel, we in effect make sure that when symbol 1is at the input, The two frequency f1&
f2 are chosen to be equal integer multiples of the bit rate 1/Tb.By summing the upper & lower
channel outputs, we get BFSK signal.

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 19


Lab Manual ADVANCED COMMUNICATION LAB

The receiver consists of two correlators with common inputs which are supplied with
locally generated coherent reference signals c1(t) and c2 (t).
The correlator outputs are then subtracted one from the other, and the resulting difference x
is compared with a threshold of zero volts. If x >0, the receiver decides in favour of symbol
1 and if x <0, the receiver decides in favour of symbol 0.
Algorithm
Initialization commands
FSK modulation
1. Generate two carriers signal.
2. Start FOR loop
3. Generate binary data, message signal and inverted message signal
4. Multiply carrier 1 with message signal and carrier 2 with inverted message signal
5. Perform addition to get the FSK modulated signal
6. Plot message signal and FSK modulated signal.
7. End FOR loop.
8. Plot the binary data and carriers.

FSK demodulation
1. Start FOR loop
2. Perform correlation of FSK modulated signal with carrier 1 and carrier 2 to get two decision
variables x1 and x2.
3. Make decisionon x = x1-x2 to get demodulated binary data. If x>0, choose 1 else choose
0.
4. Plot the demodulated binary data.

MATLAB PROGRAM:-

% FSK Modulation
clc;
clear all;
close all;
%GENERATE CARRIER SIGNAL
Tb=1; fc1=2;fc2=5;
t=0:(Tb/100):Tb;
c1=sqrt(2/Tb)*sin(2*pi*fc1*t);
c2=sqrt(2/Tb)*sin(2*pi*fc2*t);

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 20


Lab Manual ADVANCED COMMUNICATION LAB

%generate message signal


N=8;
m=rand(1,N);
t1=0;t2=Tb
for i=1:N
t=[t1:(Tb/100):t2]
if m(i)>0.5
m(i)=1;
m_s=ones(1,length(t));
invm_s=zeros(1,length(t));
else
m(i)=0;
m_s=zeros(1,length(t));
invm_s=ones(1,length(t));
end
message(i,:)=m_s;
%Multiplier
fsk_sig1(i,:)=c1.*m_s;
fsk_sig2(i,:)=c2.*invm_s;
fsk=fsk_sig1+fsk_sig2;
%plotting the message signal and the modulated signal
subplot(3,2,2);axis([0 N -2 2]);plot(t,message(i,:),'r');
title('message signal');xlabel('t---->');ylabel('m(t)');grid on;hold on;
subplot(3,2,5);plot(t,fsk(i,:));
title('FSK signal');xlabel('t---->');ylabel('s(t)');grid on;hold on;
t1=t1+(Tb+.01); t2=t2+(Tb+.01);
end
hold off
%Plotting binary data bits and carrier signal
subplot(3,2,1);stem(m);
title('binary data');xlabel('n---->'); ylabel('b(n)');grid on;
subplot(3,2,3);plot(t,c1);
title('carrier signal-1');xlabel('t---->');ylabel('c1(t)');grid on;
subplot(3,2,4);plot(t,c2);
title('carrier signal-2');xlabel('t---->');ylabel('c2(t)');grid on;

% FSK Demodulation
t1=0;t2=Tb
for i=1:N
t=[t1:(Tb/100):t2]
%correlator
x1=sum(c1.*fsk_sig1(i,:));
x2=sum(c2.*fsk_sig2(i,:));
x=x1-x2;
%decision device
if x>0
demod(i)=1;
Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 21
Lab Manual ADVANCED COMMUNICATION LAB

else
demod(i)=0;
end
t1=t1+(Tb+.01);
t2=t2+(Tb+.01);
end
%Plotting the demodulated data bits
subplot(3,2,6);stem(demod);
title(' demodulated data');xlabel('n---->');ylabel('b(n)'); grid on;

Modal Graphs

Result
The program for FSK modulation and demodulation has been simulated in MATLAB and
necessary graphs are plotted.

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 22


Lab Manual ADVANCED COMMUNICATION LAB

EXPERIMENT NO: 8
BER Simulation of DPSK modulation

Aim: To simulate bit error rate performance of DPSK modulation using Matlab.

Theory: DPSK involves 2 basic operations at the transmitter, differential encoding of the i/p
binary wave and phase shift keying, hence the name DPSK. To send symbol 0 we phase advance
the current signal waveform by 1800 and to send symbol 1 we leave the phase of the current
signal unchanged.
In the differential encoding at the transmitter input starts with an arbitrary first bit serving as
reference and thereafter the sequence is generated using
dk-1' previous value of differentially encoded digit.
bk' i/p binary digit at time kTb.
dk-1 ,bk' logical inversion.

Assuming reference bit added to {dk} is a'1'. {dk} is thus generated and used to phase shift key a
carrier with phase angles 0 and ?.

BER -Bit Error Rate


In digital transmission, the number of bit errors is the number of received bits of a data stream
over a communication channel that have been altered due to noise, interference, distortion or bit
synchronization errors.The bit error rate or bit error ratio (BER) is the number of bit errors
divided by the total number of transferred bits during a studied time interval. BER is a unitless
performance measure, often expressed as a percentage.In a communication system, the receiver
side BER may be affected by transmission channel noise, interference, distortion, bit
synchronization problems, attenuation, wireless multipath fading, etc.
The BER may be analyzed using stochastic computer simulations. If a simple transmission
channel model and data source model is assumed, the BER may also be calculated using Binary
symmetric channel (used in analysis of decoding error probability in case of non-bursty bit errors
on the transmission channel) and Additive white gaussian noise (AWGN) channel without
fading.

Algorithm
Initialization commands
1. Generate the input data randomly
2. Implement differential encoding
3. Do BPSK modulation
4. Add AWGN noise
5. Calculate the no of bits in error
6. Plot the BER graph

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 23


Lab Manual ADVANCED COMMUNICATION LAB

MATLAB PROGRAM:-

N = 10^4 % number of bits or symbols


rand('state',100); % initializing the rand() function
randn('state',200);% initializing the randn() function
ip = rand(1,N)>0.5;% generating 0,1 with equal probability
ipD = mod(filter(1,[1 -1],ip),2); % %differential encoding y[n]=y[n-1]+x[n]
s = 2*ipD-1; % BPSK modulation 0 -> -1; 1 -> 0
n = 1/sqrt(2)*[randn(1,N) + j*randn(1,N)]; % white gaussian noise, 0dB variance
Eb_N0_dB = [-3:10]; % multiple Eb/N0 values
for ii = 1:length(Eb_N0_dB)
y = s + 10^(-Eb_N0_dB(ii)/20)*n; % additive white gaussian noise
ipDHat_coh = real(y) > 0; % coherent demodulation
ipHat_coh = mod(filter([1 -1],1,ipDHat_coh),2); %differential decoding
nErr_dbpsk_coh(ii) = size(find([ip - ipHat_coh]),2); % counting the number of errors
end
simBer_dbpsk_coh = nErr_dbpsk_coh/N;
theoryBer_dbpsk_coh=erfc(sqrt(10.^(Eb_N0_dB/10))).*(1 - .5*erfc(sqrt(10.^(Eb_N0_dB/10))));
close all
figure
semilogy(Eb_N0_dB,theoryBer_dbpsk_coh,'b.-');
hold on
semilogy(Eb_N0_dB,simBer_dbpsk_coh,'mx-');
axis([-2 10 10^-6 0.5])
grid on
legend('theory', 'simulation');
xlabel('Eb/No, dB')
ylabel('Bit Error Rate')
title('Bit error probability curve for coherent demodulation of DBPSK')

Result
The Bit Error rate simulation of DPSK modulation was done using Matlab.

N = 10000

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 24


Lab Manual ADVANCED COMMUNICATION LAB

Modal Graphs

Bit error probability curve for coherent demodulation of DBPSK

theory
-1
10 simulation

-2
10
Bit Error Rate

-3
10

-4
10

-5
10

-6
10
-2 0 2 4 6 8 10
Eb/No, dB

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 25


Lab Manual ADVANCED COMMUNICATION LAB

EXPERIMENT NO: 9
QUADRATURE PHASE SHIFT KEYING

Aim: To generate and demodulate quadrature phase shifted (QPSK) signal using MATLAB

Theory
Generation of Quadrature phase shift keyed (QPSK) signal
QPSK is also known as quaternary PSK, quadriphase PSK, 4-PSK, or 4-QAM. It is a phase
modulation technique that transmits two bits in four modulation states.
Phase of the carrier takes on one of four equally spaced values such as /4, 3/4, 5/4
and7/4.
Si(t) = 2E/T cos {2 ct + (2i 1) /4} , 0 t T
0 , elsewhere
Where i = 1,2,3,4, & E= Tx signal energy per symbol
T= symbol duration
Each of the possible value of phase corresponds to a pair of bits called dibits.
Thus the gray encoded set of dibits: 10,00,01,11
Si (t) = 2E/Tcos [(2i 1)/4] cos (2fct) - 2E/Tsin [(2i 1) /4)] sin (2fct) ,0 t Tb
0 , else where
There are two orthononormal basis functions
c1 (t) = 2/T cos 2ct, 0 t Tb
c2 (t) = 2/T sin 2ct, 0 t Tb
There are four message points

The I/p binary sequence b(t) is represented in polar from with symbols 1 & 0 represented as
+E/2 and -E/2. This binary wave is demutiplexed into two separate binary waves consisting of
odd & even numbered I/P bits denoted by b1 (t) & b2 (t). b1 (t) & b2(t) are used to modulate a
pair of quadrature carrier. The result is two PSK waves .These two binary PSK waves are added
to produce the desired QPSK signal.

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 26


Lab Manual ADVANCED COMMUNICATION LAB

QPSK receiver consists of a pair of correlators with common I/P & supplied with locally
generated signal c1 (t) & c2 (t). The correlator output, x1, & x2 are each compared with a
threshold of zero volts.If x1 > 0, decision is made in favour of symbol 1 for upper channel and
if x1 > 0, decision is made in favour of symbol 0. Parallely if x2 >0, decision is made in favour
of symbol 1 for lower channel & if x2 <0, decision is made in favour of symbol 0. These two
channels are combined in a multiplexer to get the original binary output.

Algorithm
Initialization commands
QPSK modulation
1. Generate quadrature carriers.
2. Start FOR loop
3. Generate binary data, message signal(bipolar form)

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 27


Lab Manual ADVANCED COMMUNICATION LAB

4. Multiply carrier 1 with odd bits of message signal and carrier 2 with even bits of message
signal
5. Perform addition of odd and even modulated signals to get the QPSK modulated signal
6. Plot QPSK modulated signal.
7. End FOR loop.
8. Plot the binary data and carriers.

QPSK demodulation
1. Start FOR loop
2. Perform correlation of QPSK modulated signal with quadrature carriers to get two decision
variables x1 and x2.
3. Make decision on x1 and x2 and multiplex to get demodulated binary data.
If x1>0and x2>0, choose 11. If x1>0and x2<0, choose 10. If x1<0and x2>0, choose
01. If x1<0and x2<0, choose 00.
End FOR loop
Plot demodulated data

MATLAB PROGRAM:-

% QPSK Modulation
clc;
clear all;
close all;
%GENERATE QUADRATURE CARRIER SIGNAL
Tb=1;t=0:(Tb/100):Tb;fc=1;
c1=sqrt(2/Tb)*cos(2*pi*fc*t);
c2=sqrt(2/Tb)*sin(2*pi*fc*t);
%generate message signal
N=8;m=rand(1,N);
t1=0;t2=Tb
for i=1:2:(N-1)
t=[t1:(Tb/100):t2]
if m(i)>0.5
m(i)=1;
m_s=ones(1,length(t));
else
m(i)=0;
m_s=-1*ones(1,length(t));
end
%odd bits modulated signal
odd_sig(i,:)=c1.*m_s;
if m(i+1)>0.5

m(i+1)=1;
m_s=ones(1,length(t));
else
m(i+1)=0;
Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 28
Lab Manual ADVANCED COMMUNICATION LAB

m_s=-1*ones(1,length(t));
end
%even bits modulated signal
even_sig(i,:)=c2.*m_s;
%qpsk signal
qpsk=odd_sig+even_sig;
%Plot the QPSK modulated signal
subplot(3,2,4);plot(t,qpsk(i,:));
title('QPSK signal');xlabel('t---->');ylabel('s(t)');grid on; hold on;
t1=t1+(Tb+.01); t2=t2+(Tb+.01);
end
hold off
%Plot the binary data bits and carrier signal
subplot(3,2,1);stem(m);
title('binary data bits');xlabel('n---->');ylabel('b(n)');grid on;
subplot(3,2,2);plot(t,c1);
title('carrier signal-1');xlabel('t---->');ylabel('c1(t)');grid on;
subplot(3,2,3);plot(t,c2);
title('carrier signal-2');xlabel('t---->');ylabel('c2(t)');grid on;

% QPSK Demodulation
t1=0;t2=Tb
for i=1:N-1
t=[t1:(Tb/100):t2]
%correlator
x1=sum(c1.*qpsk(i,:));
x2=sum(c2.*qpsk(i,:));
%decision device
if (x1>0&&x2>0)
demod(i)=1;
demod(i+1)=1;
elseif (x1>0&&x2<0)
demod(i)=1;
demod(i+1)=0;
elseif (x1<0&&x2<0)
demod(i)=0;
demod(i+1)=0;
elseif (x1<0&&x2>0)
demod(i)=0;
demod(i+1)=1;
end
t1=t1+(Tb+.01); t2=t2+(Tb+.01);
end
subplot(3,2,5);stem(demod);
title('qpsk demodulated bits');xlabel('n---->');ylabel('b(n)');grid on;

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 29


Lab Manual ADVANCED COMMUNICATION LAB

Modal Graphs

Result
The program for QPSK modulation and demodulation has been simulated in MATLAB and
necessary graphs are plotted.

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 30


Lab Manual ADVANCED COMMUNICATION LAB

EXPERIMENT NO: 10
Implementation of QPSK Modulation with Rayleigh Fading and AWGN channel
AIM:-
To plot the wave forms for QPSK signal subjected to rayleigh AWGN using MATLAB.
THEORY:-
Quadrature Phase Shift Keying (QPSK) is the digital modulation technique.Quadrature Phase
Shift Keying (QPSK) is a form of Phase Shift Keying in which two bits are modulated at once,
selecting one of four possible carrier phase shifts (0, /2, , and 3/2). QPSK perform by
changing the phase of the In-phase (I) carrier from 0 to 180 and the Quadrature-phase (Q)
carrier between 90 and 270. This is used to indicate the four states of a 2-bit binary code. Each
state of these carriers is referred to as a Symbol.

Rayleigh fading is a statistical model for the effect of a propagation environment on a radio
signal, such as that used by wireless devices. Rayleigh fading models assume that the magnitude
of a signal that has passed through such a transmission medium (also called a communications
channel) will vary randomly, or fade, according to a Rayleigh distribution the radial component
of the sum of two uncorrelated Gaussian random variables.
Additive white Gaussian noise (AWGN) is a channel model in which the only impairment to
communication is a linear addition of wideband or white noise with a constant spectral density
(expressed as watts per hertz of bandwidth) and a Gaussian distribution of amplitude.

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 31


Lab Manual ADVANCED COMMUNICATION LAB

MATLAB PROGRAM:-
clear all;
close all;
format long;
bit_count = 10000;
Eb_No = -3: 1: 30;
SNR = Eb_No + 10*log10(2);
for aa = 1: 1: length(SNR)
T_Errors = 0;
T_bits = 0;
while T_Errors < 100
uncoded_bits = round(rand(1,bit_count));
B1 = uncoded_bits(1:2:end);
B2 = uncoded_bits(2:2:end);
qpsk_sig = ((B1==0).*(B2==0)*(exp(i*pi/4))+(B1==0).*(B2==1)...
*(exp(3*i*pi/4))+(B1==1).*(B2==1)*(exp(5*i*pi/4))...
+(B1==1).*(B2==0)*(exp(7*i*pi/4)));
ray = sqrt(0.5*((randn(1,length(qpsk_sig))).^2+(randn(1,length(qpsk_sig))).^2));
rx = qpsk_sig.*ray;
N0 = 1/10^(SNR(aa)/10);
rx = rx + sqrt(N0/2)*(randn(1,length(qpsk_sig))+i*randn(1,length(qpsk_sig)));
rx = rx./ray;
B4 = (real(rx)<0);
B3 = (imag(rx)<0);
uncoded_bits_rx = zeros(1,2*length(rx));
uncoded_bits_rx(1:2:end) = B3;
uncoded_bits_rx(2:2:end) = B4;
diff = uncoded_bits - uncoded_bits_rx;
T_Errors = T_Errors + sum(abs(diff));
T_bits = T_bits + length(uncoded_bits);
end
figure; clf;
plot(real(rx),imag(rx),'o'); % Scatter Plot
title(['constellation of received symbols for SNR = ', num2str(SNR(aa))]);
xlabel('Inphase Component'); ylabel('Quadrature Component');
BER(aa) = T_Errors / T_bits;
disp(sprintf('bit error probability = %f',BER(aa)));
end
figure(1);
semilogy(SNR,BER,'or');
hold on;
xlabel('SNR (dB)');
ylabel('BER');
title('SNR Vs BER plot for QPSK Modualtion in Rayleigh Channel');
figure(1);

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 32


Lab Manual ADVANCED COMMUNICATION LAB

EbN0Lin = 10.^(Eb_No/10);
theoryBerRay = 0.5.*(1-sqrt(EbN0Lin./(EbN0Lin+1)));
semilogy(SNR,theoryBerRay);
grid on;
figure(1);
theoryBerAWGN = 0.5*erfc(sqrt(10.^(Eb_No/10)));
semilogy(SNR,theoryBerAWGN,'g-+');
grid on;
legend('Simulated', 'Theoretical Raylegh', 'Theroretical AWGN');
axis([SNR(1,1) SNR(end-3) 0.00001 1]);

OBSERVATION:-
Output data:-
bit error probability = 0.211700
bit error probability = 0.197600
bit error probability = 0.169700
bit error probability = 0.151700
bit error probability = 0.119500
bit error probability = 0.107600
bit error probability = 0.091600
bit error probability = 0.077700
bit error probability = 0.063000
bit error probability = 0.055400
bit error probability = 0.044400
bit error probability = 0.036600
bit error probability = 0.030600
bit error probability = 0.023700
bit error probability = 0.020300
bit error probability = 0.017300
bit error probability = 0.011000
bit error probability = 0.009650
bit error probability = 0.007350
bit error probability = 0.006700
bit error probability = 0.005167
bit error probability = 0.004233
bit error probability = 0.003767
bit error probability = 0.002400
bit error probability = 0.001983
bit error probability = 0.001529
bit error probability = 0.001122
bit error probability = 0.001055
bit error probability = 0.000777
bit error probability = 0.000644
bit error probability = 0.000452
bit error probability = 0.000446
bit error probability = 0.000306

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 33


Lab Manual ADVANCED COMMUNICATION LAB

bit error probability = 0.000289

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 34


Lab Manual ADVANCED COMMUNICATION LAB

EXPERIMENT NO: 11
16-QAM Modulation and Demodulation techniques with BER
AIM:--
To plot the wave foorms for 166-QAM signnal with BERR using MAATLAB.
THEOORY:-
Quadratconveysamplituschemeusually or quadand the keying digital PSK msince thmodulabe
achieture amplitus two analoudes of twoe or amplitudsinusoids, drature comresulting w(ASK),
or (QAM case,modulators ahe amplitudation schemeeved with Qude modulaog messageo carrier
wde modulatiare out of pmponents waveform is in the analo, a finite nuare often dede of the
me for digitalQAM. ation (QAMe signals, orwaves, usingion (AM) anphase with hence the na
combinatog case) of pumber of atesigned usinmodulated cl telecommuM) is both ar two digitag
the amplnalog modueach other name of thetion of bothphase modut least two ng the QAMarrier
signaunication syan analog anal bit streamitude-shift ulation scheby 90 and e scheme. Th phase-
shiftulation (PMphases andM principleal is constanystems. Spend a digitalms, by chakeying
(ASeme. are thus caThe modulaft keying (PSM) and amplid at least twe, but are nnt. QAM
isectral efficiel modulatioanging (modSK) digitalThe two caalled quadraated waves aSK) and
amitude moduwo amplitudnot considers used exteencies of 6 bon scheme. dulating) thl
modulatioarrier waveature carrierare summedmplitude-shiulation. In thdes are usedred as
QAMensively as bits/s/Hz caIt he on s, rs d, ft he d. M a an
The bitt error ratee or bit erroor ratio (BEER) is the nnumber of biit errors divvided by thee
total
numberr of transferrred bits durring a studieed time interval. BER iis a unit lesss performannce
measure e,
often ex xpressed as a percentagge.
TIME DDOMAIN FOR AN 8 QAM SIGGNAL

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 35


Lab Manual ADVANCED COMMUNICATION LAB

MATLAB PROGRAM:-
clear all;
close all;
format long;
bit_count = 4*1000;
Eb_No = -6: 1: 10;
SNR = Eb_No + 10*log10(4);
for aa = 1: 1: length(SNR)
T_Errors = 0;
T_bits = 0;
while T_Errors < 100
uncoded_bits = round(rand(1,bit_count));
B = reshape(uncoded_bits,4,length(uncoded_bits)/4);
B1 = B(1,:);
B2 = B(2,:);
B3 = B(3,:);
B4 = B(4,:);
a = sqrt(1/10);
tx = a*(-2*(B3-0.5).*(3-2*B4)-j*2*(B1-0.5).*(3-2*B2));
N0 = 1/10^(SNR(aa)/10)
rx = tx + sqrt(N0/2)*(randn(1,length(tx))+i*randn(1,length(tx)));
a = 1/sqrt(10);
B5 = imag(rx)<0;
B6 = (imag(rx)<2*a) & (imag(rx)>-2*a);
B7 = real(rx)<0;
B8 = (real(rx)<2*a) & (real(rx)>-2*a);
temp = [B5;B6;B7;B8];
B_hat = reshape(temp,1,4*length(temp));
diff = uncoded_bits - B_hat ;
T_Errors = T_Errors + sum(abs(diff));
T_bits = T_bits + length(uncoded_bits);
end
BER(aa) = T_Errors / T_bits;
disp(sprintf('bit error probability = %f',BER(aa)));
figure;
grid on;
plot(rx,'x');
xlabel('Inphase Component');
ylabel('Quadrature Component');
Title('Constellation of Transmitted Symbols');
end
figure(1);
semilogy(SNR,BER,'or');
hold on;
grid on
title('BER Vs SNR Curve for QAM-16 Modulation Scheme in AWGN');
Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 36
Lab Manual ADVANCED COMMUNICATION LAB

xlabel('SNR (dB)'); ylabel('BER')


figure(1);
theoryBer = (1/4)*3/2*erfc(sqrt(4*0.1*(10.^(Eb_No/10))));
semilogy(SNR,theoryBer);
legend('Simulated','Theoretical');
OBSERVATION:-
Output data:-
bit error probability = 0.248750
bit error probability = 0.240000
bit error probability = 0.211250
bit error probability = 0.175750
bit error probability = 0.161250
bit error probability = 0.139250
bit error probability = 0.115750
bit error probability = 0.094250
bit error probability = 0.077000
bit error probability = 0.054500
bit error probability = 0.044250
bit error probability = 0.025000
bit error probability = 0.017375
bit error probability = 0.009500
bit error probability = 0.005100
bit error probability = 0.001821

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 37


Lab Manual ADVANCED COMMUNICATION LAB

EXPERIMENT NO: 12

Direct Sequence Spread Spectrum Technique


Aim: To verify direct sequence spread spectrum technique

Apparatus: Personal Computer/laptop with i5 processor, Matlab software

Theory: Direct-sequence spread spectrum has been adopted for many current and future
communication systems, and it is also used widely for military communication networks and
systems. One of the motivations for employing direct-sequence spread spectrum is its ability to
combat fading due to multipath propagation.
Different spread-spectrum techniques are available, but all have one idea in common: the
key (also called the code or sequence) attached to the communication channel. The manner of
inserting this code defines precisely the spread-spectrum technique. The term "spread spectrum"
refers to the expansion of signal bandwidth. The formal definition of spread spectrum is more
precise: an RF communications system in which the baseband signal bandwidth is intentionally
spread over a larger bandwidth by injecting a higher frequency signal (Figure 1).

Figure 1
As a direct consequence, energy used in transmitting the signal is spread over a wider
bandwidth, and appears as noise. The ratio (in dB) between the spread baseband and the original
signal is called processing gain. Typical spread-spectrum processing gains run from 10dB to
60dB.To apply a spread-spectrum technique, simply inject the corresponding spread-spectrum
code somewhere in the transmitting chain before the antenna (receiver). (That injection is called
the spreading operation.) The effect is to diffuse the information in a larger bandwidth.
Conversely, you can remove the spread-spectrum code (called a despreading operation) at a point
Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 38
Lab Manual ADVANCED COMMUNICATION LAB

in the receive chain before data retrieval. A despreading operation reconstitutes the information
into its original bandwidth. Obviously, the same code must be known in advance at both ends of
the transmission channel. (In some circumstances, the code should be known only by those two
parties.)
PROCEDURE:
1. Switch on the personal computer
2. Open matlab software
3. Open new editor m file
4. Write the program
5. Save it in the particular folder
6. Debug the program for verification

MATLAB PROGRAM:-
clc; % Clears the command window
clear all; % Clears the workspace
close all; % Clears the figure window
% Generating the bit pattern with each bit 6 samples long
b=round(rand(1,20)); % Round the nearest uniformly
%distributed pseudo random numbers
pattern=[]; % Construct pattern generator object
for k=1:20
if b(1,k)==0
sig=zeros(1,6) % Create array of all zeros
else
sig=ones(1,6) % Creates array of all ones
end
pattern=[pattern sig];
end
plot(pattern);
axis([-1 130 -0.5 1.5]);
title('\bit\if original bit sequence');
% Generating the pseudorandom bit pattern for spreading

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 39


Lab Manual ADVANCED COMMUNICATION LAB

spread_sig=round(rand(1,120)); % Round the nearest uniformly


%distributed pseudorandom numbers
figure,
plot(spread_sig); % Plot spread signal
axis([-1 130 -0.5 1.5]);
title('\bit\if pseudorandom bit sequence');
% Add title to current axis
% XOR ing the pattern with spread signal
hopped_sig=xor(pattern,spread_sig); % Perform the logical exclusive or
%operation
% Modulating the Hopped signal
dsss_sig=[]; t=[0:100]; fc=0.1;
c1=cos(2*pi*fc); % Creates the cosine signal1
c2=cos(2*pi*fc*t+pi); % Creates the cosine signal2
for k=1:120
if hopped_sig(1,k)==0; % If the hopped signal is zero then
%perform the signal1
dsss_sig=[dsss_sig c1]
else
dsss_sig=[dsss_sig c2] % If the hopped signal is zero then
%perform the signal2
end
end
figure,
plot(dsss_sig); axis([-1 212 -1.5 1.5]);
figure,
plot(abs(fft(dsss_sig))); % Plotting the fft of dsss signal
title('absolute value of dsss'); % Plots absolute value if the discrete
% sequence spread spectrum signal

Result: Direct Sequence Spread Spectrum Technique is Verified

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 40


Lab Manual ADVANCED COMMUNICATION LAB

EXPERIMENT NO: 13
Simulation of Frequency Hopping (FH) Spread- Spectrum
Frequency Hopping Spread Spectrum (FHSS) modulation techniques are found to be simple and
inexpensive as compared to Direct Sequence Spread Spectrum (DSSS) in terms of code
synchronization. Besides hardware implementation, FHSS has been popularly used as an anti-
jamming technique since World War II. The anti-jamming capability is determined by the type
of the hopping used in the System. In a slow-FHSS technique, several bits for symbols) are
transmitted over single carrier frequency. This results into poor anti-jamming capability,
however, utilizing lesser bandwidth and easy code synchronization. On the other hand, a good
anti-jamming is achieved in fast-FHSS modulation technique, wherein each message bit (or
symbol) is transmitted over several carrier frequencies. However, it takes a great deal of
spectrum and involves complex circuitry to attain code synchronization in case of fast-FHSS. In
Intermediate FHSS (IFHSS) technique, the hopping rate of the carrier is approximately equal to
message bit rate. IFHSS offers moderate anti-jamming capability and utilizes a moderate
bandwidth compared to slow and fast FHSS systems.

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 41


Lab Manual ADVANCED COMMUNICATION LAB

Frequency Hopping Spread Spectrum System (Transmitter):

Frequency Hopping Spread Spectrum System (Receiver):

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 42


Lab Manual ADVANCED COMMUNICATION LAB

MATLAB PROGRAM:-

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Frequency Hopping Spread Spectrum
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc
clear

% Generation of bit pattern


s=round(rand(1,25)); % Generating 20 bits
signal=[];
carrier=[];
t=[0:2*pi/119:2*pi]; % Creating 60 samples for one cosine
for k=1:25
if s(1,k)==0
sig=-ones(1,120); % 120 minus ones for bit 0
else
sig=ones(1,120); % 120 ones for bit 1
end
c=cos(t);
carrier=[carrier c];
signal=[signal sig];
end
subplot(4,1,1);
plot(signal);
axis([-100 3100 -1.5 1.5]);
title('\bf\it Original Bit Sequence');

% BPSK Modulation of the signal


bpsk_sig=signal.*carrier; % Modulating the signal
subplot(4,1,2);
plot(bpsk_sig)
axis([-100 3100 -1.5 1.5]);
title('\bf\it BPSK Modulated Signal');

% Preparation of 6 new carrier frequencies


t1=[0:2*pi/9:2*pi];
t2=[0:2*pi/19:2*pi];
t3=[0:2*pi/29:2*pi];
t4=[0:2*pi/39:2*pi];
t5=[0:2*pi/59:2*pi];
t6=[0:2*pi/119:2*pi];
c1=cos(t1);
c1=[c1 c1 c1 c1 c1 c1 c1 c1 c1 c1 c1 c1];
c2=cos(t2);
c2=[c2 c2 c2 c2 c2 c2];
c3=cos(t3);
c3=[c3 c3 c3 c3];
c4=cos(t4);
c4=[c4 c4 c4];
c5=cos(t5);
c5=[c5 c5];
c6=cos(t6);

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 43


Lab Manual ADVANCED COMMUNICATION LAB

% Random frequency hopps to form a spread signal


spread_signal=[];
for n=1:25
c=randint(1,1,[1 6]);
switch(c)
case(1)
spread_signal=[spread_signal c1];
case(2)
spread_signal=[spread_signal c2];
case(3)
spread_signal=[spread_signal c3];
case(4)
spread_signal=[spread_signal c4];
case(5)
spread_signal=[spread_signal c5];
case(6)
spread_signal=[spread_signal c6];
end
end
subplot(4,1,3)
plot([1:3000],spread_signal);
axis([-100 3100 -1.5 1.5]);
title('\bf\it Spread Signal with 6 frequencies');

% Spreading BPSK Signal into wider band with total of 12 frequencies


freq_hopped_sig=bpsk_sig.*spread_signal;
subplot(4,1,4)
plot([1:3000],freq_hopped_sig);
axis([-100 3100 -1.5 1.5]);
title('\bf\it Frequency Hopped Spread Spectrum Signal');

% Expressing the FFTs


figure,subplot(2,1,1)
plot([1:3000],freq_hopped_sig);
axis([-100 3100 -1.5 1.5]);
title('\bf\it Frequency Hopped Spread Spectrum signal and its FFT');
subplot(2,1,2);
plot([1:3000],abs(fft(freq_hopped_sig)));

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 44


Lab Manual ADVANCED COMMUNICATION LAB

RESULT:

Frequency Hopped Spread Spectrum signal and its FFT

-1

0 500 1000 1500 2000 2500 3000

200

150

100

50

0
0 500 1000 1500 2000 2500 3000

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 45


Lab Manual ADVANCED COMMUNICATION LAB

EXPERIMENT NO: 14
OFDM modulation and demodulation
Multi carrier modulation as the name suggests is a modulation technique in which multiple
number of carriers are used for modulating the information signals (data bits), as against a single
carrier used in the most common single carrier modulation schemes such as BPSK and QPSK
etc. Thus multi carrier modulation can be defined as the principle of transmitting data by
dividing the stream into several parallel bit streams, each of which has a much lower bit rate, and
by using these sub streams to modulate several carriers. The most popular of the MCM scheme is
the well known Orthogonal Frequency Division Modulation also known as OFDM in brief.
Orthogonal frequency division multiplexing/modulation (OFDM) uses multiple orthogonal
carriers to send bits in parallel, thereby reducing the signaling rate. OFDM has developed into a
popular scheme for wideband digital communication, whether wireless or over copper wires,
used in applications such as digital television and audio broadcasting, wireless networking and
broadband internet access. FDM is especially suitable for high-speed communication due to its
resistance to ISI.

Fig.1 OFDM block diagram

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 46


Lab Manual ADVANCED COMMUNICATION LAB

Principles of OFDM

The orthagonal subcarriers of OFDM are obtained by using IFFT. Figure 2 shows a
simple OFDM model. The IFFT modulates data parallelly and serial to parallel converter
precedes IIFT computation. In order to transmit the parallelly computed carriers are
transmitted serially using parallel to serial conveter. At the reiver the inverse process is
used to recover the transmitted data. The details of the desicription of the transmitter and
receiver, as used for the simulation are described in this Section.
1) Serial to Parallel Converter: The serial to parallel converter converts serial input data
stream to parallel data stream (sets). Each set of data contains one symbol, Si, for each
subcarrier.

Data In
Serial to Parallel to
Parallel IFFT Serial
Converter Converter

Channel

Clipping Multipath Noise

Data Out
Serial to FFT Parallel to
Parallel Serial

Fig.2 OFDM Basic Model

2) IFFT: The Inverse Fast Fourier Transform converts frequency domain data set into
samples of a time domain waveform with orthogonal frequency components.
3) Parallel to Serial Converter: The parallel to serial converter creates the OFDM signal
by sequentially outputting the time domain samples.

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 47


Lab Manual ADVANCED COMMUNICATION LAB

4) Channel Simulation Blocks: The channel simulation blocks are used to determine the
effects of noise, multipath, and clipping on transmitted signal (OFDM signal).
5) Noise Block: Simple noise can be simulated if random data to the OFDM signal is
added.
6) Multichannel Block: To study the effect of multipath on OFDM signal multipath
simulation is done by adding attenuated and delayed copies of the transmitted signal to
the original. This simulates the problem in wireless communication when the signal
propagates on many paths.
7) Clipping Block: To study the effect of clipping on transmitted signal. Clipping stage
simulates the problem of amplifier saturation. This addresses a plausible practical
implementation problem in OFDM where the peak to average power ratio is high.
8) Serial to parallel converter: The OFDM data are split from a serial stream into parallel
sets so the inverse of IIFT i.e. FFT can be applied.

9) FFT: The Fast Fourier Transform (FFT) converts the time domain samples back into a
frequency domain representation. The magnitudes of the frequency components
correspond to the original data.
10) Parallel to Serial Converter: The parallel to serial block converts this parallel data into
a serial stream to recover the original input data.

MATLAB PROGRAM:-

%==========================================================================
% 1) The mfile investigates the generation, transmission and reception of
% the OFDM signal without channel noise or HPA effect
%==========================================================================
clear all
clc
close
% ---------------
% A: Setting Parameters
% ---------------
M = 4; % QPSK signal constellation
no_of_data_points = 64; % have 64 data points
block_size = 8; % size of each ofdm block
cp_len = ceil(0.1*block_size); % length of cyclic prefix
no_of_ifft_points = block_size; % 8 points for the FFT/IFFT
no_of_fft_points = block_size;
% ---------------------------------------------
% B: % +++++ TRANSMITTER +++++

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 48


Lab Manual ADVANCED COMMUNICATION LAB

% ---------------------------------------------
% 1. Generate 1 x 64 vector of data points phase representations
data_source = randsrc(1, no_of_data_points, 0:M-1);
figure(1)
stem(data_source); grid on; xlabel('data points'); ylabel('transmitted data
phase representation')
title('Transmitted Data "O"')
% 2. Perform QPSK modulation
qpsk_modulated_data = pskmod(data_source, M);
scatterplot(qpsk_modulated_data);title('qpsk modulated transmitted data')
% 3. Do IFFT on each block
% Make the serial stream a matrix where each column represents a pre-OFDM
% block (w/o cyclic prefixing)
% First: Find out the number of colums that will exist after reshaping
num_cols=length(qpsk_modulated_data)/block_size;
data_matrix = reshape(qpsk_modulated_data, block_size, num_cols);

% Second: Create empty matix to put the IFFT'd data


cp_start = block_size-cp_len;
cp_end = block_size;

% Third: Operate columnwise & do CP


for i=1:num_cols,
ifft_data_matrix(:,i) = ifft((data_matrix(:,i)),no_of_ifft_points);
% Compute and append Cyclic Prefix
for j=1:cp_len,
actual_cp(j,i) = ifft_data_matrix(j+cp_start,i);
end
% Append the CP to the existing block to create the actual OFDM block
ifft_data(:,i) = vertcat(actual_cp(:,i),ifft_data_matrix(:,i));
end

% 4. Convert to serial stream for transmission


[rows_ifft_data cols_ifft_data]=size(ifft_data);
len_ofdm_data = rows_ifft_data*cols_ifft_data;

% Actual OFDM signal to be transmitted


ofdm_signal = reshape(ifft_data, 1, len_ofdm_data);
figure(3)
plot(real(ofdm_signal)); xlabel('Time'); ylabel('Amplitude');
title('OFDM Signal');grid on;
% ------------------------------------------
% E: % +++++ RECEIVER +++++
% ------------------------------------------

% 1. Pass the ofdm signal through the channel


recvd_signal = ofdm_signal;

% 4. Convert Data back to "parallel" form to perform FFT


recvd_signal_matrix = reshape(recvd_signal,rows_ifft_data, cols_ifft_data);

% 5. Remove CP
recvd_signal_matrix(1:cp_len,:)=[];

% 6. Perform FFT

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 49


Lab Manual ADVANCED COMMUNICATION LAB

for i=1:cols_ifft_data,
% FFT
fft_data_matrix(:,i) = fft(recvd_signal_matrix(:,i),no_of_fft_points);
end
% 7. Convert to serial stream
recvd_serial_data = reshape(fft_data_matrix, 1,(block_size*num_cols));
% 8. Demodulate the data
qpsk_demodulated_data = pskdemod(recvd_serial_data,M);
scatterplot(qpsk_modulated_data);title('qpsk modulated received data')
figure(5)
stem(qpsk_demodulated_data,'rx');
grid on;xlabel('data points');ylabel('received data phase
representation');title('Received Data "X"')

RESULT

Transmitted Data "O"


3

2.5
transmitted data phase representation

1.5

0.5

0
0 10 20 30 40 50 60 70
data points

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 50


Lab Manual ADVANCED COMMUNICATION LAB

qpsk modulated transmitted data


1

0.8

0.6

0.4

0.2
Quadrature

-0.2

-0.4

-0.6

-0.8

-1
-1 -0.5 0 0.5 1
In-Phase

OFDM Signal
0.5

0.4

0.3

0.2

0.1
Amplitude

-0.1

-0.2

-0.3

-0.4

-0.5
0 10 20 30 40 50 60 70 80
Time

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 51


Lab Manual ADVANCED COMMUNICATION LAB

qpsk modulated received data

0.8

0.6

0.4

0.2
Quadrature

-0.2

-0.4

-0.6

-0.8

-1
-1 -0.5 0 0.5 1
In-Phase

Received Data "X"


3

2.5
received data phase representation

1.5

0.5

0
0 10 20 30 40 50 60 70
data points

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 52


Lab Manual ADVANCED COMMUNICATION LAB

%==========================================================================
% 2) The mfile investigates the effects of high power amplifier and the
% channel noise on the ofdm signals.
%==========================================================================
clear all
clc
close all
%--------------------------------------------------------------------------
% A: Setting Parameters
%--------------------------------------------------------------------------
M = 4; % QPSK signal constellation
no_of_data_points = 64; % have 64 data points
block_size = 8; % size of each ofdm block
cp_len = ceil(0.1*block_size); % length of cyclic prefix
no_of_ifft_points = block_size; % 8 points for the FFT/IFFT
no_of_fft_points = block_size;
% -------------------------------------------------------------------------
% B: %%%%%%%%%%%%%%%%+++++ TRANSMITTER +++++ %%%%%%%%%%%%%%%%%%%%%%%%%%%
% -------------------------------------------------------------------------
%%%% 1.Generate 1 x 64 vector of random data points
data_source = randsrc(1, no_of_data_points, 0:M-1);
figure(1)
stem(data_source); grid on; xlabel('Data Points'); ylabel('Amplitude')
title('Transmitted Data "O"')

%%%% 2.Perform QPSK modulation


qpsk_modulated_data = pskmod(data_source, M);
scatterplot(qpsk_modulated_data);title('MODULATED TRANSMITTED DATA');

%%%% 3.Do IFFT on each block


% Make the serial stream a matrix where each column represents a pre-OFDM
% block (w/o cyclic prefixing)
% First: Find out the number of colums that will exist after reshaping
num_cols=length(qpsk_modulated_data)/block_size;
data_matrix = reshape(qpsk_modulated_data, block_size, num_cols);

% Second: Create empty matix to put the IFFT'd data


cp_start = block_size-cp_len;
cp_end = block_size;

% Third: Operate columnwise & do CP


for i=1:num_cols,
ifft_data_matrix(:,i) = ifft((data_matrix(:,i)),no_of_ifft_points);
% Compute and append Cyclic Prefix
for j=1:cp_len,
actual_cp(j,i) = ifft_data_matrix(j+cp_start,i);
end
% Append the CP to the existing block to create the actual OFDM block
ifft_data(:,i) = vertcat(actual_cp(:,i),ifft_data_matrix(:,i));
end

%%%% 4. Convert to serial stream for transmission


[rows_ifft_data cols_ifft_data]=size(ifft_data);

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 53


Lab Manual ADVANCED COMMUNICATION LAB

len_ofdm_data = rows_ifft_data*cols_ifft_data;

% Actual OFDM signal to be transmitted


ofdm_signal = reshape(ifft_data, 1, len_ofdm_data);
figure(3)
plot(real(ofdm_signal)); xlabel('Time'); ylabel('Amplitude');
title('OFDM Signal');grid on;

%--------------------------------------------------------------------------
% C: %%%%%%%%%%%%%%%%%% +++++ HPA +++++ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%--------------------------------------------------------------------------
%To show the effect of the PA simply we will add random complex noise
%when the power exceeds the avg. value, otherwise it add nothing.

% 1. Generate random complex noise


noise = randn(1,len_ofdm_data) + sqrt(-1)*randn(1,len_ofdm_data);

% 2. Transmitted OFDM signal after passing through HPA


avg=0.4;
for i=1:length(ofdm_signal)
if ofdm_signal(i) > avg
ofdm_signal(i) = ofdm_signal(i)+noise(i);
end
if ofdm_signal(i) < -avg
ofdm_signal(i) = ofdm_signal(i)+noise(i);
end
end
figure(4)
plot(real(ofdm_signal)); xlabel('Time'); ylabel('Amplitude');
title('OFDM Signal after HPA');grid on;

%--------------------------------------------------------------------------
% D: %%%%%%%%%%%%%%%%% +++++ CHANNEL +++++ %%%%%%%%%%%%%%%%%%%%%%%%
%--------------------------------------------------------------------------
% Create a complex multipath channel
channel = randn(1,block_size) + sqrt(-1)*randn(1,block_size);

%--------------------------------------------------------------------------
% E: %%%%%%%%%%%%%%%%%%+++++ RECEIVER +++++ %%%%%%%%%%%%%%%%%%%%%%%%%
%--------------------------------------------------------------------------

% 1. Pass the ofdm signal through the channel


after_channel = filter(channel, 1, ofdm_signal);

% 2. Add Noise
awgn_noise = awgn(zeros(1,length(after_channel)),0);

% 3. Add noise to signal...

recvd_signal = awgn_noise+after_channel;

% 4. Convert Data back to "parallel" form to perform FFT


recvd_signal_matrix = reshape(recvd_signal,rows_ifft_data, cols_ifft_data);

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 54


Lab Manual ADVANCED COMMUNICATION LAB

% 5. Remove CP
recvd_signal_matrix(1:cp_len,:)=[];

% 6. Perform FFT
for i=1:cols_ifft_data,
% FFT
fft_data_matrix(:,i) = fft(recvd_signal_matrix(:,i),no_of_fft_points);
end
% 7. Convert to serial stream
recvd_serial_data = reshape(fft_data_matrix, 1,(block_size*num_cols));
scatterplot(recvd_serial_data);title('MODULATED RECEIVED DATA');

% 8. Demodulate the data


qpsk_demodulated_data = pskdemod(recvd_serial_data,M);
scatterplot(recvd_serial_data);title('MODULATED RECEIVED DATA');
figure(5)
stem(qpsk_demodulated_data,'rx');
grid on;xlabel('Data Points');ylabel('Amplitude');title('Received Data "X"');

RESULT
Transmitted Data "O"
3

2.5

2
Amplitude

1.5

0.5

0
0 10 20 30 40 50 60 70
Data Points

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 55


Lab Manual ADVANCED COMMUNICATION LAB

MODULATED TRANSMITTED DATA


1

0.8

0.6

0.4

0.2
Quadrature

-0.2

-0.4

-0.6

-0.8

-1
-1 -0.5 0 0.5 1
In-Phase

OFDM Signal
0.8

0.6

0.4

0.2
Amplitude

-0.2

-0.4

-0.6

-0.8
0 10 20 30 40 50 60 70 80
Time

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 56


Lab Manual ADVANCED COMMUNICATION LAB

OFDM Signal after HPA


2.5

1.5

1
Amplitude

0.5

-0.5

-1

-1.5

-2
0 10 20 30 40 50 60 70 80
Time

Received Data "X"


3

2.5

2
Amplitude

1.5

0.5

0
0 10 20 30 40 50 60 70
Data Points

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 57


Lab Manual ADVANCED COMMUNICATION LAB

MODULATED RECEIVED DATA

20

15

10

5
Quadrature

-5

-10

-15

-20

-20 -10 0 10 20
In-Phase

Dept of ECE |School of Engineering | Central University of Karnataka, Gulbarga 58

You might also like