Finalised Ad Communication Lab Manual 1
Finalised Ad Communication Lab Manual 1
Finalised Ad Communication Lab Manual 1
Of
VIIIth semester
Integrated M.Tech ICT
Prepared by
SYED GILANI PASHA
Assistant Professor ECE
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.
EXPERIMENT NO: 1
Measurement of BIT ERROR RATE (BER) using binary data
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.
0110001011
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:
MATLAB PROGRAM:-
-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
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:
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 -
PROCEDURE:
MATLAB PROGRAM:-
EXPERIMENT NO: 3
Determination of output of Convolutional Encoder for a given sequence
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:
EXPERIMENT NO: 4
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
MATLAB PROGRAM:-
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.
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
% 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.
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.
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
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
Modal Graphs
Result
The program for PSK modulation and demodulation has been simulated in MATLAB and
necessary graphs are plotted.
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.
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);
% 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.
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 ?.
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
MATLAB PROGRAM:-
Result
The Bit Error rate simulation of DPSK modulation was done using Matlab.
N = 10000
Modal Graphs
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
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.
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)
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;
Modal Graphs
Result
The program for QPSK modulation and demodulation has been simulated in MATLAB and
necessary graphs are plotted.
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.
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);
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
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
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
EXPERIMENT NO: 12
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
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.
MATLAB PROGRAM:-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Frequency Hopping Spread Spectrum
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc
clear
RESULT:
-1
200
150
100
50
0
0 500 1000 1500 2000 2500 3000
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.
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
Data Out
Serial to FFT Parallel to
Parallel Serial
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.
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 +++++
% ---------------------------------------------
% 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);
% 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));
% 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
2.5
transmitted data phase representation
1.5
0.5
0
0 10 20 30 40 50 60 70
data points
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
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
2.5
received data phase representation
1.5
0.5
0
0 10 20 30 40 50 60 70
data points
%==========================================================================
% 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"')
len_ofdm_data = rows_ifft_data*cols_ifft_data;
%--------------------------------------------------------------------------
% 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.
%--------------------------------------------------------------------------
% D: %%%%%%%%%%%%%%%%% +++++ CHANNEL +++++ %%%%%%%%%%%%%%%%%%%%%%%%
%--------------------------------------------------------------------------
% Create a complex multipath channel
channel = randn(1,block_size) + sqrt(-1)*randn(1,block_size);
%--------------------------------------------------------------------------
% E: %%%%%%%%%%%%%%%%%%+++++ RECEIVER +++++ %%%%%%%%%%%%%%%%%%%%%%%%%
%--------------------------------------------------------------------------
% 2. Add Noise
awgn_noise = awgn(zeros(1,length(after_channel)),0);
recvd_signal = awgn_noise+after_channel;
% 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');
RESULT
Transmitted Data "O"
3
2.5
2
Amplitude
1.5
0.5
0
0 10 20 30 40 50 60 70
Data Points
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
1.5
1
Amplitude
0.5
-0.5
-1
-1.5
-2
0 10 20 30 40 50 60 70 80
Time
2.5
2
Amplitude
1.5
0.5
0
0 10 20 30 40 50 60 70
Data Points
20
15
10
5
Quadrature
-5
-10
-15
-20
-20 -10 0 10 20
In-Phase