Professional Documents
Culture Documents
CS Simulation Manual
CS Simulation Manual
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
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
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
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
1
Q u a d ra tu re
-1
-2
-3
-3 -2 -1 0 1 2 3
In-Phase
1
Quadrature
-1
-2
-3
-4
-4 -2 0 2 4
In-Phase
MATLAB Code FOR FSK (Frequency Shift Keying) BFSK in this case:
OUTPUT WAVEFORM
OUTPUT WAVEFORM FOR PSK
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--->
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--->
1.5
Amplitude 0.5
-0.5
-1
-1.5
-2
0 1 2 3 4 5 6 7 8 9
Time(t)
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)