BPSK signal generation and demodulation - MATLAB

3
Page 1 of 3 Digital Communication MATLAB Assignment Name: Pavan Kumar P N USN: 1MS08EC067 Question: Write a Matlab code for BPSK signal generation and demodulation. Add AWGN noise to the ASK modulated signal and measure probability of error. Plot E b /N 0 Vs BER curve and eye diagram. Brief Explanation of Algorithm: 1. The number of bits considered for the BPSK is taken. (While working on the algorithm, I saw that, for the Eye Diagram to appear properly, it is better to go with many symbols). 1000 codes were taken for my simulation. 2. A random array of bits containing ones and zeros is generated for the input bits. The probability of generation of ones and zeros is kept equal (0.5) 3. First, a BPSK signal is to be generated at the transmitter. Here, the input symbols are coded as -1 for 0 and as +1 for 1. 4. Then, a 0dB White Gaussian noise is generated, according to Gaussian probability distribution function. Random values are used to generate the AWGN. 5. The signal has to be passed through this channel and then it has to be demodulated. 6. But, since, to plot the BER versus Eb/No curve to be plotted, we need to give different values of Eb/No, which will be multiplied with the White Gaussian Noise, and will then be added to the input function. 7. The noise added is called additive white Gaussian noise because, the noise is ‘added to the signal’, ‘has a flat power spectral density’ and follows Gaussian distribution. 8. In the demodulation process, the threshold is taken as ‘0’, which forms the decision boundary. Hence, if the received signal is greater than 0, then it is assumed that signal s1 was transmitted and if received signal is less than zero, it is assumed that signal s2 was transmitted. 9. Hence, to find out the Bit Error Probability, we can demodulate the signal and find out the difference between the input signal and the demodulated signal. 10. This is repeated for all values of SNR, and the out put signal and the Bit Error Rate is estimated for each signal. This is the practical method of estimation of BER. 11. Also, the Bit Error Probablility is estimated using the formula Pe=(1/2)erfc(sqrt(Eb/2No)). This is the theoretical method of estimation of BER. 12. Then, we can obtain the BER vs Eb/No curve, by using the semilog plot, and hence semilogy command is used to obtain the same. 13. The eye pattern is not very distinctive for signals with low values of Eb/No, hence, the Eye Pattern is plotted only for signals with high values of Eb/No, that is Eb/No=10.

description

Matlab code for BPSK signal generation and demodulation. Add AWGN noise to the ASK modulated signal and measure probability of error. Plot Eb/N0 Vs BER curve and eye diagram.

Transcript of BPSK signal generation and demodulation - MATLAB

Page 1: BPSK signal generation and demodulation - MATLAB

Page 1 of 3

Digital Communication MATLAB Assignment

Name: Pavan Kumar P N

USN: 1MS08EC067

Question: Write a Matlab code for BPSK signal generation and demodulation. Add AWGN noise

to the ASK modulated signal and measure probability of error. Plot Eb/N0 Vs BER curve and eye

diagram.

Brief Explanation of Algorithm:

1. The number of bits considered for the BPSK is taken. (While working on the algorithm, I saw that,

for the Eye Diagram to appear properly, it is better to go with many symbols). 1000 codes were

taken for my simulation.

2. A random array of bits containing ones and zeros is generated for the input bits. The probability of

generation of ones and zeros is kept equal (0.5)

3. First, a BPSK signal is to be generated at the transmitter. Here, the input symbols are coded as -1

for 0 and as +1 for 1.

4. Then, a 0dB White Gaussian noise is generated, according to Gaussian probability distribution

function. Random values are used to generate the AWGN.

5. The signal has to be passed through this channel and then it has to be demodulated.

6. But, since, to plot the BER versus Eb/No curve to be plotted, we need to give different values of

Eb/No, which will be multiplied with the White Gaussian Noise, and will then be added to the input

function.

7. The noise added is called additive white Gaussian noise because, the noise is ‘added to the signal’,

‘has a flat power spectral density’ and follows Gaussian distribution.

8. In the demodulation process, the threshold is taken as ‘0’, which forms the decision boundary.

Hence, if the received signal is greater than 0, then it is assumed that signal s1 was transmitted and

if received signal is less than zero, it is assumed that signal s2 was transmitted.

9. Hence, to find out the Bit Error Probability, we can demodulate the signal and find out the

difference between the input signal and the demodulated signal.

10. This is repeated for all values of SNR, and the out put signal and the Bit Error Rate is estimated for

each signal. This is the practical method of estimation of BER.

11. Also, the Bit Error Probablility is estimated using the formula Pe=(1/2)erfc(sqrt(Eb/2No)). This is the

theoretical method of estimation of BER.

12. Then, we can obtain the BER vs Eb/No curve, by using the semilog plot, and hence semilogy

command is used to obtain the same.

13. The eye pattern is not very distinctive for signals with low values of Eb/No, hence, the Eye Pattern

is plotted only for signals with high values of Eb/No, that is Eb/No=10.

Page 2: BPSK signal generation and demodulation - MATLAB

Page 2 of 3

Outputs:

-5 0 5 1010

-6

10-5

10-4

10-3

10-2

10-1

100

Eb/No in dB

Bit E

rror

Rate

Eb/No vs BER Curve

The above figure shows the Eb/No bs Bit Error Rate curve, on a semilog scale.

-0.5 0 0.5-2

-1

0

1

2

Time

Am

plit

ude

Eye Diagram for In-Phase Signal

-0.5 0 0.5-2

-1

0

1

2

Time

Am

plit

ude

Eye Diagram for Quadrature Signal

Page 3: BPSK signal generation and demodulation - MATLAB

Page 3 of 3

The above figure show the Eye Diagram for the BPSK Signal after addition of Additive White

Gaussian Noise, and with Eb/No of 10dB.

MATLAB Code:

clc clear all close all N = 1000 % Number of bits rand('state',100); % initializing rand function randn('state',200); % initializing randn function

% Transmitter ip = rand(1,N)>0.5; % generating input bits 0,1 s = 2*ip-1; % BPSK modulation 0 -> -1; 1 -> 1

n = 1/sqrt(2)*[randn(1,N) + j*randn(1,N)]; % White gaussian noise, 0dB variance Eb_N0_dB= [-5:10]; % multiple Eb/N0 values

for ii = 1:length(Eb_N0_dB) % Noise addition y = s + 10^(-Eb_N0_dB(ii)/20)*n; % Additive White Gaussian Noise

% Receiver - decision decoding ipHat = real(y)>0;

% Counting the errors nErr(ii) = size(find([ip- ipHat]),2); end

simBer = nErr/N; % BER by counting errors manually theoryBer = 0.5*erfc(sqrt(10.^(Eb_N0_dB/10))); % BER by using formula

% Plot for Eb/No vs BER close all figure semilogy(Eb_N0_dB,theoryBer); grid on xlabel('Eb/No in dB'); ylabel('Bit Error Rate'); title('Eb/No vs BER Curve');

% Eye Diagram for Signal with Highest Value of Eb/No eyediagram(y,2);