Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 11

INDEX

Sl. Page
Name of the Experiment Marks Sign
No. Date No.
1 Signal Sampling and reconstruction
2 Time Division Multiplexing
3 AM Modulator and Demodulator
4 FM Modulator and Demodulator
5 Pulse Code Modulation and Demodulation
6 Delta Modulation and Demodulation

7 Observation (simulation) of signal constellations of BPSK,


QPSK and QAM
8 Line coding schemes

9 FSK, PSK and DPSK schemes (Simulation)

Error control coding schemes - Linear Block Codes


10 (Simulation)

11 Communication link simulation

12 Equalization – Zero Forcing & LMS algorithms(simulation)

BEYOND THE SYLLABUS

13 Study of Pseudo random bit sequence generation


14 Study of Analog to digital and digital to analog converter
Signal constellation program for BPSK
BPSK have only two signal elements, one with a phase of 0°, and the other with a phase of 180°. BPSK
also uses only an in-phase carrier. However, we use a polar NRZ signal for modulation. It creates two types of
signal elements, one with amplitude (1) and the other with amplitude (-1). The MATLAB code and simulation
results are given below

MATLAB CODE
clc
clear all
close all
num_symbols=10000;
int_symbols=randi([1,2],1,num_symbols);
bpsk_symbols=zeros(size(int_symbols));
bpsk_symbols(int_symbols==1)= 1
bpsk_symbols(int_symbols==2)= -1
plot(real(bpsk_symbols),imag(bpsk_symbols),'ored','linewidth',3);
xlim([-2 2]);
ylim([-2 2]);
title('BPSK CONSTELLATION');
xlabel('real part');
ylabel('imaginary part');
line(xlim,[0 0],'color','k','linewidth',1)%xaxis
line([0 0],ylim,'color','k','linewidth',1)%yaxis
gridon

OUTPUT

BPSK CONSTELLATION
2

1.5

0.5
imaginary part

-0.5

-1

-1.5

-2
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
real part

Fig. Constellation diagram for BPSK in MATLAB.


Signal constellation program for QPSK

QPSK uses four points on the constellation diagram, equally spaced around a circle. With four phases,
QPSK can encode two bits per symbol. Constellation Diagram of QPSK also uses both an in-phase carrier and
quadrature. The developed MATLAB code for QPSK constellation diagram is shown below:

MATLAB CODE

clc
clear all
close all
num_symbols=10000;
int_symbols=randi([1,4],1,num_symbols);
A = 1/sqrt(2);
qpsk_symbols=zeros(size(int_symbols));
qpsk_symbols(int_symbols==1)= A+1i*A;
qpsk_symbols(int_symbols==2)= A-1i*A;
qpsk_symbols(int_symbols==3)= -A+1i*A;
qpsk_symbols(int_symbols==4)= -A-1i*A;
plot(real(qpsk_symbols),imag(qpsk_symbols),'ored','linewidth',3);
xlim([-2 2]);
ylim([-2 2]);
line(xlim,[0 0],'color','k','linewidth',1)%xaxis
line([0 0],ylim,'color','k','linewidth',1)%yaxis
hold on
ezplot('x^2+y^2=1')
grid on
title('QPSK CONSTELLATION');
xlabel('real part');
ylabel('imaginary part');

OUTPUT

QPSK CONSTELLATION
2

1.5

0.5
imaginary part

-0.5

-1

-1.5

-2
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
real part

Fig. Constellation diagram for QPSK in MATLAB


Signal constellation program for 16-QAM

Quadrature amplitude modulation, QAM, when used for digital transmission for radio communications
applications is able to carry higher data rates than ordinary amplitude modulated schemes and phase modulated
schemes. As with phase shift keying, etc, the number of points at which the signal can rest, i.e. the number of points on
the constellation is indicated in the modulation format description, e.g. 16QAM uses a 16 point constellation. When
using QAM, the constellation points are normally arranged in a square grid with equal vertical and horizontal spacing
and as a result the most common forms of QAM use a constellation with the number of points equal to a power of 2 i.e.
4, 16, 64 . . . .

MATLAB CODE

clc
clear all
close all
M=16;
x=randint(5000,log2(M));
x1=bi2de(x,'left-msb');
xmod=qammod(x1,M);
scatterplot(xmod);
title('signal space diagram of 16-QAM');
snr=10;
rx=awgn(xmod,snr);
scatterplot(rx);
title('signal space diagram of received 16-QAM under AWGN');

OUTPUT

signal space diagram of 16-QAM


3

1
Q u a d ra tu re

-1

-2

-3
-3 -2 -1 0 1 2 3
In-Phase

signal space diagram of received 16-QAM under AWGN


4

1
Quadrature

-1

-2

-3

-4
-4 -2 0 2 4
In-Phase
MATLAB Code FOR FSK (Frequency Shift Keying) BFSK in this case:

clc %for clearing the command window


close all %for closing all the window except command window
clear all %for deleting all the variables from the memory
fc1=input('Enter the freq of 1st Sine Wave carrier:');
fc2=input('Enter the freq of 2nd Sine Wave carrier:');
fp=input('Enter the freq of Periodic Binary pulse (Message):');
amp=input('Enter the amplitude (For Both Carrier & Binary Pulse Message):');
amp=amp/2;
t=0:0.001:1; % For setting the sampling interval
c1=amp.*sin(2*pi*fc1*t);% For Generating 1st Carrier Sine wave
c2=amp.*sin(2*pi*fc2*t);% For Generating 2nd Carrier Sine wave
subplot(4,1,1); %For Plotting The Carrier wave
plot(t,c1)
xlabel('Time')
ylabel('Amplitude')
title('Carrier 1 Wave')
subplot(4,1,2) %For Plotting The Carrier wave
plot(t,c2)
xlabel('Time')
ylabel('Amplitude')
title('Carrier 2 Wave')
m=amp.*square(2*pi*fp*t)+amp;%For Generating Square wave message
subplot(4,1,3) %For Plotting The Square Binary Pulse (Message)
plot(t,m)
xlabel('Time')
ylabel('Amplitude')
title('Binary Message Pulses')
for i=0:1000 %here we are generating the modulated wave
if m(i+1)==0
mm(i+1)=c2(i+1);
else
mm(i+1)=c1(i+1);
end
end
subplot(4,1,4) %For Plotting The Modulated wave
plot(t,mm)
xlabel('Time')
ylabel('Amplitude')
title('Modulated Wave')
OUTPUT

The following INPUTS GIVEN TO GENERATE FSK MODULATED WAVE:


Enter the freq of 1st Sine Wave carrier:10
Enter the freq of 2nd Sine Wave carrier:30
Enter the freq of Periodic Binary pulse (Message):5
Enter the amplitude (For Both Carrier & Binary Pulse Message):4

OUTPUT WAVEFORM
OUTPUT WAVEFORM FOR PSK

binary data bits


1
b(n)
0.5
0
1 2 3 4 5 6 7 8
n--->

carrier signal
2
0
c(t)

-2
7 7.2 7.4 7.6 7.8 8 8.2
t--->
BPSK signal
2
0
s(t)

-2
0 1 2 3 4 5 6 7 8 9
t--->

binary data bits


1
b(n)

0.5
0
1 2 3 4 5 6 7 8
n--->

carrier signal
2
0
c(t)

-2
7 7.2 7.4 7.6 7.8 8 8.2
t--->
BPSK signal
2
0
s(t)

-2
0 1 2 3 4 5 6 7 8 9
t--->
demodulated data
1
b(n)

0.5
0
1 2 3 4 5 6 7 8
n--->

MATLAB CODE for DPSK


clc
clear all
close all
B = [1 0 0 1 0 0 1 1];
B_not = ~B;
count = 0;
Dk=[];
for i=1:1:length(B);
if(B(i)==0)
count = count + 1;
if(count>1)
Dk(i) =0;
else
Dk(i) = 1;
end
else
if(B(i)==1)
Dk(i)=1;
count = 0;
end
end
end
Dk_not = ~Dk;
Result = [];
Result1 = [];
Result2 = [];
Result1 = Dk & B;
Result2 = Dk_not & B_not;
Result = xor(Result1,Result2);
Final = [];
for i= 1:1:length(Result+1)
Final(1)=1;
Final(i+1)= Result(i);
end
Main_Final = ~ Final;
fs=1000;
f = 1;
Signal = [];
time = [];
t=0:1/fs:1;
for i=1:1: length(Main_Final);
Signal =[ Signal (Main_Final(i)==0)*sin(2*pi*f*t)+...
(Main_Final(i)==1)*-cos(2*pi*f*t)];
time=[time t];
t=t+1;
end
plot(time,Signal,'red','LineWidth',2.5);
axis([0 time(end) -2 2]);
xlabel('Time(t)');
title(['Differential Phase Shift Keying [' num2str(Main_Final) ']']);
ylabel('Amplitude');
grid on
OUTPUT OF DPSK SCEME

Differential Phase Shift Keying [0 0 1 0 0 1 0 0 0]


2

1.5

Amplitude 0.5

-0.5

-1

-1.5

-2
0 1 2 3 4 5 6 7 8 9
Time(t)

MATLAB CODE for LMS algorithm


w=0;
L=512;
M=1024;
G=256;
l=[0:L-1];
fs=1000;
f0=80;
w(:,1)=[0:0];
mu=0.0125;
x1=sin(2*pi*f0*[0:L-1]/fs);
x2=sin(2*pi*f0*[0:L-1]/fs);
pp=1;
x6=0;
while pp<10
x3=(x1+x2)+0.09*randn;
x6=x6+x3;
pp=pp+1;
end
x6=x6/10;
subplot(3,1,1)
plot(x6)
grid
title('Signal')
xlabel('Time(Sec)')
ylabel('Amplitude(Volt)')
x=0.5*randn(G,L);
subplot(3,1,2)
plot(x,'b')
grid
title('Signal added with Noise')
xlabel('Time(Sec)')
ylabel('Amplitude(Volt)')
for j=1:G
for i=1:L
y(j,i)=w(:,i)'+[x3(i)*randn*0.09];
e(j,i)=x(j,i)-y(j,i);
w(:,i+1)=w(:,i)+2*0.025*e(j,i)+[x3(i)*randn*0.09];
end
EE(j,:)=(fft(e(j,:),M));
end
u=(sum(abs(EE).^2)/(G))/max((sum(abs(EE).^2)/(G)));
w=w(1:512);
subplot(3,1,3)
plot(w)
grid
title('LMS Output')
xlabel('Time(Sec)')
ylabel('Amplitude(Volt)')
sss=length(w);
xg=(sum((x3-w)))/(length(x3));
BER=abs(xg)
sn=max(u);
nn=max(x3);
SNR=nn/sn

OUTPUT

BER =
0.1653

SNR =

2.0036

Signal
Amplitude(Volt)

-2
0 100 200 300 400 500 600
Time(Sec)
Signal added with Noise
Amplitude(Volt)

-5
0 50 100 150 200 250 300
Time(Sec)
LMS Output
Amplitude(Volt)

-2
0 100 200 300 400 500 600
Time(Sec)

You might also like