Sunteți pe pagina 1din 9

NATIONAL INSTITUTE OF TECHNOLOGY

CALICUT

DIGITAL COMMUNICATION LAB REPORT

Software implementation of Binary Phase Shift Keying.

Submitted by:

Ch.Uday B140817EC

G.Manoj B140346EC

J.Sudheer B140817EC

K.Vineel B140798EC

Christy B120885EC
1) Aim :

To simulate a DC system in the presence of noise that uses coherent BPSK


𝐸
with antipodal signalling and plot BER curves ( 𝑁𝑏 in dB vs PE) with 1024 BSK
0

symbols per frame.

1. Plot the original constellation diagram for the transmitted symbols


assuming no noise
2. Add AWGN with different variance values and plot the constellation
diagram
𝐸
3. Apply coherent detection and compute BER for 𝑁𝑏 in [0:14] dB in steps of 2 dB 4.
0
𝐸𝑏
Plot BER vs 𝑁 . Verify BER plot (simulations) with analytical computation of BER for
0
BPSK.

2) Theory :
Modulation is an important and necessary part of digital communication
systems which is performed for providing the signal immunity to noise and for
wireless transmission. Modulation is the process of varying one or more
properties of a periodic waveform, called the carrier signal, with a modulat-ing
signal that typically contains information to be transmitted. In digital
communication systems, there are three main forms of modulation.

 Amplitude Shift Keying


 Frequency Shift Keying
 Phase Shift Keying
Phase-shift keying (PSK) is a digital modulation scheme that conveys data
by changing (modulating) the phase of a reference signal (the carrier wave).
Phase Shift Keying can be classi ed into di erent types based on the number of
basis signals used as BPSK, QPSK, etc. In BPSK i.e Binary PSK, a single sinusoidal
signal is used as the basis signal and the bits are encoded as phase shifted
versions of the same sinusoidal signal. The basis signal for BPSK can be
2𝐸
represented as ¢ (t) = √ 𝑁 𝑏 cos(2πfc t)
0

The signals used for modulation are s0(t) = ¢ (t) and s1(t) = - ¢ (t). The Bit Error
Rate decreases with an increase in SNR. This is shown by the SNR curve.
3)Code
1)Baseband processing code:
close all;
clear all;
message=rand (1,1024)
message=2.*message-1
numsymb = numel(message) %Random message signal
for i=1:numsymb
if(message(i)>>0)
message(i)=1
else
message(i)=-1
end
end %signal rounded to range -1 to 1
binary=[]
vp=1
t=200
for i=1:numsymb
if(message(i)>>0)
binary=[binary ones(1,t/2).*vp]
else
binary=[binary ones(1,t/2).*(-vp)]
end
end
t=[2/t:2/t:numsymb]
snrdb=0:2:14
snr=10.^(snrdb/10) %snr values stored in an array
ber=zeros(1,numel(snr))
Eb=vp.^2
iter_max=2000;
for count =1:numel(snr)
avgerror=0
N_max=Eb/snr(count)
for iter=1:iter_max
error=0
noise=sqrt(N_max(2)*)randn(1,numsymb) %noise added to signal
received=message+noiise %Recieved signal
for i=1:numsymb
if(message(i)==1&&received(i)<0)||(message(i)== -1 &&received(i)>0)
error=error+1 %maximum likelihood decoding
end
end
error=error/numsymb
avgerror=avgerror+error
end
ber(count)=avgerror/iter_max
end
ber_theoretical=0.5.*erfc(sqrt(snr)) %theoretical error
semilog y(snrdb,ber_theoretical,'k=') %error curves
hold on
grid on
semilog y(snrdb,ber,'y*')
legend('theoretical','simulation')
axis([min(snrdb),max(snrdb,10.^(-5),10.^(-1)])
title('comparison of bit error rates-baseband')
x label ('snr inn db')
y label ('bit error rate')
hold off;
scatter plot (binary)

2)Passband processing code

clear all;
close all;
message = rand(1, 1024);
message = 2*message - 1;
numsymb = numel(message);
for i=1:numsymb
if message(i)>0
message(i)=1;
else
message(i)=-1;
end
end
binary=[];
vp=1;
T=200;
Rb = 1;
for i=1:numsymb
if(message(i)==1)
binary = [binary ones(1, T/2)*vp];
elseif(message(i)==-1)
binary = [binary ones(1, T/2)*(-vp)];
end
end
t = 1:1:1024;
t2 = 0.01:0.01:1024;
f = 5;
trans = message.*cos(2*pi*f*t); %modualted signal
toPlot = binary.*cos(2*pi*f*t2); %modualted signal to plot
cosSig = cos(2*pi*f*t2);
figure
hold on;
title('Comparison of Signals');
subplot(3,1,1);
plot(t2(1:500), cosSig(1:500), 'k');
title('Carrier signal');
xlabel('Time Axis');
ylabel('Amplitude');
subplot(3,1,2);
plot(t2(1:500), binary(1:500), 'b');
title('Message signal');
xlabel('Time Axis');
ylabel('Amplitude');
subplot(3,1,3);
plot(t2(1:500), toPlot(1:500), 'r');
title('BPSK Modulated signal');
xlabel('Time Axis');
ylabel('Amplitude');
hold off;
scatterplot(trans); %original constellation diagram
snrdb = 0:2:14;
snr = 10.^(snrdb/10);
ber = zeros(1, numel(snr));
Eb = vp^2;
iter_max=10;
f = 5;
y=[];
for count=1:numel(snr)
avgerror = 0;
N_max = Eb/snr(count);

for iter=1:iter_max
error=0;
noise = sqrt(N_max/2)*randn(1,numel(trans));
received = trans + noise;
demodulated = received.*cos(2*pi*f*t); %demodulated signal

for i=1:numsymb
if((message(i)==1 && demodulated(i)<0)||(message(i)==-
1&&demodulated(i)>0))
error = error+1;
end
end
error = error/numsymb;
avgerror = avgerror + error;
end
ber(count) = avgerror/iter_max;
end
scatterplot(demodulated); %modified scatter plot
ber_theoretical = 0.5*erfc(sqrt(snr));
figure;
semilogy(snrdb, ber_theoretical, 'k-');
hold on;
grid on;
semilogy(snrdb, ber, 'r*');
legend('Theoretical','Simulation');
axis([min(snrdb), max(snrdb) 10^(-5) 1]);
title('Comparison of Bit Error Rates - Bandpass modulated');
xlabel('SNR in dB');
ylabel('Bit Error Rate');
hold off;
figure;
subplot(2,1,1);
stem(message(1:10));
title('Original message');
xlabel('Time Axis');
ylabel('Amplitude');
subplot(2,1,2);
stem(demodulated(1:10));
title('Demodulated impulses');
xlabel('Time Axis');
ylabel('Amplitude');
Plots

Figure 1:constellation diagram of original modulated signal

Figure 2:BER of unmodulated signal


Figure 3:carrier, message and BPSK modulated signal

Figure 4:BER of modulated signal


Figure 5:constellation diagram of modulated signal after noise addition

4 Inferences

1. Before the addition of noise, it is observed that the modulated signal has
only two constellation points corresponding to the positive and negative
peak of the polar signal.

2. The Bit Error Rate is found to reduce with increase in SNR. The simulated
results are found to be in close agreement to the actual values.

3. The signal is BPSK modulated by multiplying it with a cosine signal of


appropriate frequency.

4. The demodulated signal is used to plot a constellation diagram and the


scatterplot is observed to produce numerous constellation points.

5. The BPSK modulated signal is found to deviate slightly from the


theoretical value.

S-ar putea să vă placă și