bpsk vs qpsk in an awgn channel

21
EDC 310: Practical 1 BPSK and QPSK through an AWGN channel Gavin Jaime Fouch´ e August 21, 2015

Upload: jaime-fouche

Post on 29-Jan-2016

365 views

Category:

Documents


10 download

DESCRIPTION

Comparison of BER for BPSK vs QPSK in an AWGN Channel.

TRANSCRIPT

Page 1: BPSK vs QPSK in an AWGN Channel

EDC 310: Practical 1

BPSK and QPSK through an AWGN channel

Gavin Jaime Fouche

August 21, 2015

Page 2: BPSK vs QPSK in an AWGN Channel

Contents

0.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20.2 Problem Definition and Methodology . . . . . . . . . . . . . . . . 3

0.2.1 Uniform random number generation . . . . . . . . . . . . 30.2.2 Gaussian random number generation . . . . . . . . . . . . 30.2.3 Modulation through an AWGN channel . . . . . . . . . . 30.2.4 BPSK with a phase offset . . . . . . . . . . . . . . . . . . 5

0.3 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60.3.1 Uniform random number generation . . . . . . . . . . . . 60.3.2 Gaussian random number generation . . . . . . . . . . . . 70.3.3 Modulation through an AWGN channel . . . . . . . . . . 80.3.4 BPSK with a phase offset . . . . . . . . . . . . . . . . . . 9

0.4 Discussion and Conclusion . . . . . . . . . . . . . . . . . . . . . . 9

1

Page 3: BPSK vs QPSK in an AWGN Channel

0.1 Introduction

The role of digital communications

As the amount of information at our fingertips increases and the demand forincreasingly rapid transfer rates grows greater - The common denominator of allinteraction in the digital sphere is encompassed by the concept of digital com-munication. Digital communication is defined as the physical transfer of dataover a communication channel. We are surrounded by digital communicationsevery minute of every day, from the mouse you use on your computer to themobile telephone in your pocket right now.

Figure 1: Example communication network showing Rx and Tx

Random number generation

Random number generators use algorithms and techniques to produce stringsof numbers that appear to be unrelated and as a result seem to be ”random”.Computational algorithms generally produce pseudo-random numbers becausetheir creation is not dependant on a truly random natural process such as at-mospheric noise.

Phase-shift Keying

Phase-shift keying is a scheme of digital modulation that deals with represen-tation of different data signals through the use of a phase-shift on the referencesignal of varying degrees. Two forms of PSK are explored in this practical -namely Binary phase shift keying (BPSK) and Quadrature Phase shift keying(QPSK). [1]

Using a phase shift allows a signal of fixed amplitude to represent multipledistinct values. These representations (or ”symbols”) can be expressed as afunction of their binary equivalents in a constellation map.

2

Page 4: BPSK vs QPSK in an AWGN Channel

0.2 Problem Definition and Methodology

0.2.1 Uniform random number generation

The probability distribution function of the uniform distribution can be de-scribed by [2]:

f(x) = 1b−a for a ≤ x ≤ b

f(x) = 0 elsewhere

The uniform distribution required in this practical has bounds a = 0 and b = 1This can be described by the plot.From the moment generating functions we can calculate the theoretical mean(µ) and variance (σ2) [2] can be described as:

µ =1

2(a+ b) =

1

2

σ2 =(b− a)2

12=

1

12= 0.083

To generate random numbers conforming to this uniform distribution, we willuse the Wichmann-Hill Algorithm.

0.2.2 Gaussian random number generation

The normal distribution can be described by a probability distribution functionof

f(x|µ, σ) = 1σ√2πe−

(x−µ)2

2σ2

∴ f(x|0, 1) = 1√2πe−

x2

2

Which by definition has mean of 0 and variance 1.[2]

0.2.3 Modulation through an AWGN channel

An Additive Gaussian Noise (AWGN) channel is a path channel described by:

rk = sk + nk

Where r is the received symbol, s is the sent symbol and n is a noise term. Itcan be deduced from the inequality present by the non-zero n term that thereceived signal will differ slightly by the sent signal s. The AWGN network willbe simulated as described in the flow-chart.

3

Page 5: BPSK vs QPSK in an AWGN Channel

Figure 2: Flow chart depicting the methodology behind simulating the AWGNchannel

4

Page 6: BPSK vs QPSK in an AWGN Channel

0.2.4 BPSK with a phase offset

This report will also explore the effects of a constant phase-shift applied to theBPSK coding and whether or not this has an effect even in an AWGN channelwith additive real and imaginary noise. If the bit error rate truly is a functionof orthogonality, there should be no apparent difference in BER plots.

Figure 3: Constellation maps of BPSK and offset BPSK

5

Page 7: BPSK vs QPSK in an AWGN Channel

0.3 Results

0.3.1 Uniform random number generation

The uniform number generation results proved consistent with the theoreticalapproximation. Slight subtleties visible are due to a finite number of sampleslimited to 1 million, with an increase in samples the inconsistencies tend to be-come less prevalent. Despite the differences, the mean still stays exceptionallyclose to the theoretical mean of 0.5 and theoretical variance of 0.0833. Calcu-lated values for the simulation can be seen in figure 3.

Figure 4: Plot of the uniform distribution generated from the Wichmann-HillAlgorithm for 1 million samples and the theoretical plot.

6

Page 8: BPSK vs QPSK in an AWGN Channel

0.3.2 Gaussian random number generation

Gaussian number generation proved to work well, with a mean difference fromthe theoretical value that was extremely small.

Figure 5: Results of the Marsaglia-Bray algorithm for 1 million samples and thetheoretical normal distribution

7

Page 9: BPSK vs QPSK in an AWGN Channel

0.3.3 Modulation through an AWGN channel

Figure 6: BER plot for BPSK on an AWGN channel vs. Theoretical

Figure 7: BER plot for QPSK on an AWGN channel vs. Theoretical

8

Page 10: BPSK vs QPSK in an AWGN Channel

0.3.4 BPSK with a phase offset

Figure 8: A plot showing offset BPSK vs regular BPSK bit error rates.

0.4 Discussion and Conclusion

Random number generation performed as expected with the limited samplecount, matching the theoretical graphs exceptionally well with very small devi-ation error.

Results for the BPSK/QPSK graphs showed that both phase-shift keying meth-ods shared the exact same BER plots. This is further illustrated in figure 9.

9

Page 11: BPSK vs QPSK in an AWGN Channel

Figure 9: Plot showing BER for BPSK vs QPSK

This is not initially intuitive, transmitting multiple bits at a time seems like itshould have a trade-off in fidelity. However, QPSK symbol mapping is simplya duo of BPSK signals that are perfectly orthogonal to each other - one BPSKsystem on the real axis and another on the imaginary axis. Due to their orthog-onality, they hence do not interfere. Analysis (in figure 8) shows that the BERplots for offset BPSK and regular BPSK do in-fact match each other perfectly.This is due to the fact that the bit error rate is a function of orthogonality, sinceboth offset and regular BPSK share the same 180 deg phase shift between theirassociated symbols.

It can be concluded that, BPSK and QPSK are digital modulation schemeswith a good fidelity when transmitting through an additive white Gaussiannoise channel provided that the SNR is of an acceptable degree. We can alsoconclude that signal fidelity is a function of orthogonality between symbols. Itcan be seen (by figure 9) that QPSK and BPSK both share the same BERplot. If the symbol rate (bandwidth) is the same for BPSK and QPSK, QPSKwill perform considerably worse with the same signal power. This performanceconsideration is alleviated by QPSK’s higher symbol rate so it appears to havethe same BER as BPSK. Therefore, QPSK achieves the same bit error rate atthe cost of added signal power required to transmit.

10

Page 12: BPSK vs QPSK in an AWGN Channel

Bibliography

[1] J. G. Proakis, M. Salehi, N. Zhou, and X. Li, Communication systems en-gineering, vol. 1. Prentice-hall Englewood Cliffs, 1994.

[2] D. Wackerly, W. Mendenhall, and R. Scheaffer, Mathematical statistics withapplications. Cengage Learning, 2007.

11

Page 13: BPSK vs QPSK in an AWGN Channel

Appendix A: MATLAB code

Question 1.m

close allclearclc

% sample size:sample size = 1000000; % no of numbers to generate.samples = zeros(1,sample size);

a = clock;

s1 = sum(a(1:6));s2 = floor(prod(a(4:6)));s3 = floor(prod(a(1:2)));

for i=1:sample size[ r , s1, s2, s3 ] = WichmannHill(s1,s2,s3);samples(i) = r;

end

[y,x] = hist(samples, 100);bar(x, y/sum(y)/(x(2)-x(1)));hold on;

% Create three distribution objects with different parameterspd1 = makedist('Uniform');

% Compute the pdfsx = -0.5:.01:1.5;pdf1 = pdf(pd1,x);

stairs(x,pdf1,'r','LineWidth',2);ylim([0 1.1]);hold off;

title(sprintf('Probability Distribution for the Wichmann-Hill algorithm\nMean : %f \nVariance: %f\nStandard Deviation: %f\n', mean(samples), var(samples), std(samples)));ylabel('Probability');xlabel('Values');

legend('Simulated Distribution', 'Theoretical Distribution');

fprintf('Mean : %f \nVariance: %f\nStandard Deviation: %f\n', mean(samples), var(samples), std(samples));

12

Page 14: BPSK vs QPSK in an AWGN Channel

Question 2.m

close allclearclc

% sample size:sample size = 10000000; % no of numbers to generate.samples = zeros(1,sample size);

for i=1:sample sizer1 = MarsagliaBray();samples(i) = r1;

end

[ y,x ] = hist(samples, sample size ./ 1000);bar(x, y/sum(y)/(x(2)-x(1)));hold on;

x = [-3:.1:3];norm = normpdf(x,0,1);plot(x,norm, 'r');

title(sprintf('Probability Distribution for the Marsaglia-Bray algorithm\nMean : %f \nVariance: %f\nStandard Deviation: %f\n', mean(samples), var(samples), std(samples)));ylabel('Probability');xlabel('Values');legend('Simulated Distribution', 'Theoretical Distribution');fprintf('Mean : %f \nVariance: %f\nStandard Deviation: %f\n', mean(samples), var(samples), std(samples));

13

Page 15: BPSK vs QPSK in an AWGN Channel

Question 3 BPSK.m

% question 3 new:

close all;clear all;clc;

% run loop for: minimum of n=100 bits have been run and min of 50 error% bits detected.

SNRdB = -4:1:8 ; % run from -4 to 8 dB.BERvalues = zeros(1,length(SNRdB));noRunsEach = 20;

% seeds:a = clock;s1 = sum(a(1:6));s2 = floor(prod(a(4:6)));s3 = floor(prod(a(1:2)));

for i=1:length(SNRdB)% for every dB of SNR we want to iterate through, we need to generate% and test bits through the AWGN channel until we get min of 50 errors% or min of 100 bits.

nErrorsAvg = 0;

for n=1:noRunsEach

nBits = 0; % start at zero.nErrors = 0; % no errors for this SNR.

while (nBits < 100000 && nErrors < 50000)

% just keep going.% generate a new bit:[ randWich , s1, s2, s3 ] = WichmannHill(s1,s2,s3);s = 2 * (randWich > 0.5) - 1; % transmitted symbol.r = s + (getSigma(SNRdB(i), 1) * MarsagliaBray());% now we know we received r.% does the logical binary interpretation of r match that of s ?

if ( ((s+1)/2) ~= (r > 0) )nErrors = nErrors + 1;

end

nBits = nBits + 1;

endnErrorsAvg = nErrorsAvg + nErrors;

end

14

Page 16: BPSK vs QPSK in an AWGN Channel

% at this point, we have a pretty good estimation of the number of% errors so:BERvalues(i) = (nErrorsAvg/ noRunsEach) / nBits;disp('Finished an SNR level');

end

BERideal=(1/2)*erfc(sqrt(10.ˆ(SNRdB/10))); % ideal BER.semilogy(SNRdB, BERvalues);title('A bit-error rate curve for BPSK on an AWGN channel');hold on;semilogy(SNRdB,BERideal, '.r');legend('Simulation', 'Theoretical');xlabel('SNR (in dB)');ylabel('BER');

15

Page 17: BPSK vs QPSK in an AWGN Channel

Question 3 QPSK.m

% question 3:%%%%%%%%% QPSK %%%%%%%%%

close all;clear all;clc;

% run loop for: minimum of n=100 bits have been run and min of 50 error% bits detected.

SNRdB = -4:1:8 ; % run from -4 to 8 dB.BERvalues = zeros(1,length(SNRdB));noRunsEach = 20;

% seeds:a = clock;s1 = sum(a(1:6));s2 = floor(prod(a(4:6)));s3 = floor(prod(a(1:2)));

tTime = 0;

for i=1:length(SNRdB)% for every dB of SNR we want to iterate through, we need to generate% and test bits through the AWGN channel until we get min of 50 errors% or min of 100 bits.tic;

nErrorsAvg = 0;

for n=1:noRunsEach

nBits = 0; % start at zero.nErrors = 0; % no errors for this SNR.

while (nBits < 100000 && nErrors < 50000)

% just keep going.% generate two symbol components (Quadrature and In-phase)[ randWich1 , s1, s2, s3 ] = WichmannHill(s1,s2,s3);[ randWich2 , s1, s2, s3 ] = WichmannHill(s1,s2,s3);% now map these double digits to their const maps:

sR = 2 * (randWich1 > 0.5) - 1;sI = 2 * (randWich2 > 0.5) - 1;

% add noise, NOTICE fbit changes.r = (sR + sI*1i) + (getSigma(SNRdB(i), 1) * MarsagliaBray());r = r + ((getSigma(SNRdB(i), 1) * MarsagliaBray())*1i); % add complex noise.

16

Page 18: BPSK vs QPSK in an AWGN Channel

% demodulate:dR = (sign(real(r))+1)/2; % sign function divides component by mag.dI = (sign(imag(r))+1)/2; % and convert to binary rep.

% dR and dI now hold the demodulated components of the sent% signal sR and sI after AWGN.% does the logical binary interpretation of r match that of s ?

if ( ((sR+1)/2) ~= dR )nErrors = nErrors + 1;

end

if ( ((sI+1)/2) ~= dI )nErrors = nErrors + 1;

end

nBits = nBits + 2;

endnErrorsAvg = nErrorsAvg + nErrors;

end

% at this point, we have a pretty good estimation of the number of% errors so:BERvalues(i) = (nErrorsAvg/ noRunsEach) / (nBits);disp('Finished an SNR level');tTime = (tTime + toc);tAvg = tTime./i; % record the time taken for this run, estimate further runs.fprintf('Estimated time to simulation completion: %d minutes.', round(tAvg*(length(SNRdB) - i)./60));

end

BERideal=(1/2)*erfc(sqrt(10.ˆ(SNRdB/10))); % ideal BER.semilogy(SNRdB, BERvalues);title('A bit-error rate curve for QPSK on an AWGN channel');hold on;semilogy(SNRdB,BERideal, '.r');legend('Simulation', 'Theoretical');xlabel('SNR (in dB)');ylabel('BER');

17

Page 19: BPSK vs QPSK in an AWGN Channel

WichmannHill.m

function [r , x, y, z] = WichmannHill(x,y,z)

x = 171 * mod(x, 177) - 2 * (x / 177);if ( x < 0 )

x = x + 30269;end

y = 172 * mod(y, 176) - 35 * (y /176);if (y < 0 )

y = y + 30307;end

z = 170 * mod(z, 178) - 63 * (z / 178);if ( z < 0 )

z = z+30323;end

temp = x/30269.0 + y/30307.0 + z/30323.0;

r = mod( temp , 1.0 );

end

MarsagliaBray.m

% marsaglia-brayfunction R1 = MarsagliaBray()

s = 1;while ( s >= 1 )

v1 = 2 * rand - 1;v2 = 2 * rand - 1;s = v1*v1 + v2*v2;

endL = sqrt(-2 * log(s) / s);R1 = v1 * L;

end

getSigma.m

function [ outputS ] = getSigma( SNR , fbit )% SNR in dB% fbit for BPSK (=1) or QPSK (=2)

outputS = 1 ./ sqrt(power(10, SNR./10) * 2 * fbit);

end

18

Page 20: BPSK vs QPSK in an AWGN Channel

ExtraBPSK.m

% BPSK with a pi/4 phase shift.:

close all;clear all;clc;

% run loop for: minimum of n=100 bits have been run and min of 50 error% bits detected.

SNRdB = -4:1:8 ; % run from -4 to 8 dB.BERvalues = zeros(1,length(SNRdB));noRunsEach = 20;

constS1 = (1./sqrt(2)) + (1i./sqrt(2));constS2 = (-1./sqrt(2)) + (-1i./sqrt(2));

% seeds:a = clock;s1 = sum(a(1:6));s2 = floor(prod(a(4:6)));s3 = floor(prod(a(1:2)));

for i=1:length(SNRdB)% for every dB of SNR we want to iterate through, we need to generate% and test bits through the AWGN channel until we get min of 50 errors% or min of 100 bits.

nErrorsAvg = 0;

for n=1:noRunsEach

nBits = 0; % start at zero.nErrors = 0; % no errors for this SNR.

while (nBits < 100000 && nErrors < 50000)

% just keep going.% generate a new bit:[ randWich , s1, s2, s3 ] = WichmannHill(s1,s2,s3);% round for bit representation.

if (randWich > 0.5)s = (1./sqrt(2)) + (1i./sqrt(2)); % if bit is 1 then map to top right

elses = (-1./sqrt(2)) + (-1i./sqrt(2)); %

end

r = s + (getSigma(SNRdB(i), 1) * MarsagliaBray());r = r + (getSigma(SNRdB(i), 1) * MarsagliaBray())*1i; % complex noise.% now we know we received r.% does the logical binary interpretation of r match that of s ?% now for the comparative logic:

19

Page 21: BPSK vs QPSK in an AWGN Channel

% if the delta value of S1 is smaller than delta of S2 we know% that it is S1.if ( abs( r - constS1 )ˆ2 < abs( r - constS2)ˆ2)

dR = (1./sqrt(2)) + (1i./sqrt(2)); % S1else

dR = (-1./sqrt(2)) + (-1i./sqrt(2)); % S2end

if (dR ~= s)nErrors = nErrors + 1;

end

nBits = nBits + 1;

endnErrorsAvg = nErrorsAvg + nErrors;

end

% at this point, we have a pretty good estimation of the number of% errors so:BERvalues(i) = (nErrorsAvg/ noRunsEach) / nBits;disp('Finished an SNR level');

end

BERideal=(1/2)*erfc(sqrt(10.ˆ(SNRdB/10))); % ideal BER.semilogy(SNRdB, BERvalues);title('A bit-error rate curve for 45 degree phase-offset BPSK on an AWGN channel');hold on;semilogy(SNRdB,BERideal, '.r');legend('Offset BPSK', 'Normal BPSK');xlabel('SNR (in dB)');ylabel('BER');

20