2

I want to display a signal waveform passed through AWGN channel,so I followed these block diagrams and referenced this website then finished this program.

enter image description here enter image description here

(http://drmoazzam.com/matlab-code-bpsk-modulation-and-demodulation-with-explanation/)

I sent a bit stream 1 and 0, just two bits. Set symbol energy per bit Es=1, Bit rate Ts=1 and carrier frequency fc=2. I coded the bit stream to biplolar non-return-to-zero form, then modulated it to BPSK signal.

When the signal was received, used coherent detection to demodulate it. To verify my program ( It seems to be right from displaying the waveform. After modulating 1 and 0, the phase of two waveform shifted by 180º each other,as follow image. ), I calculated the BER. The BER varies with SNR. However, I set SNR=1dB, the BER is still 0 (SNR=1,finalber=0). It doesn't make sense. I don't know why result is that. Who can help me to check? Thanks

enter image description here

clc;
clear all;
% BPSK trapz

for kk=1:1000
bitstream=[1 0 ];
%% modulate: BPSK
Es=1;% symbol energy per bit
Ts=1; %Bit rate is assumed to be 1 bit/s;
fc=2; % carrier frequency
d=0.01; % sampled interval
tc=[0:d:0.99];
n=1;
symbolbits=1; % how many bits in a symbol, BPSK=1,QPSK=2
NRZ=2*bitstream-1; % non-return-to-zero line code,bit 1 ->1 , bit 0 ->-1
for i=1:symbolbits:length(bitstream)
    s(1,(n-1)*length(tc)+1:n*length(tc))=NRZ(i)*sqrt(2/Ts)*cos(2*pi*fc*tc);
    n=n+1;
end

%% through AWGN channnel
SNR=20; % SNR in dB
snr=10^(SNR/10);
E=sum(abs(s).^2)/length(s); %signal energy
N0=E/snr; % noise spectral density
noise=sqrt(N0)*(randn(1,length(s))); % s is real value signal
received=s+noise;
%% coherent detection
for i=1:length(received)/length(tc)
    Qr(1,(i-1)*length(tc)+1:i*length(tc))=received((i-1)*length(tc)+1:i*length(tc)).*(sqrt(2/Ts)*cos(2*pi*fc*tc));
end
m=1;
y=[];
time=[0:d:1.99];
for i=1:2
 y(1,i)=trapz(time((i-1)*100+1:i*100),Qr((i-1)*100+1:i*100));
end
detected=y;
for i=1:length(detected)
    if detected(i)>0
        demod(i)=1;
    else
        demod(i)=0;
    end
end
ber(1,kk)=sum(demod~=bitstream)/length(bitstream);
end
finalber=sum(ber)/1000;

figure(1)
time=[0:d:1.99];
subplot(3,1,1); plot(time,s); title('transmitted BPSK signal')
subplot(3,1,2); plot(time,received); title('received BPSK signal')
subplot(3,1,3); plot(time,Qr)
Cris Luengo
  • 55,762
  • 10
  • 62
  • 120
Ryan
  • 21
  • 2
  • I have set a loop to calculate BER repeatedly, which cannot compensate for lack of bits? I just have tried it again when number of bits are 1000, but BER is still wrong. – Ryan Dec 19 '18 at 14:22

0 Answers0