From: Bogdan Mikhailets on
Guys, I need to solve the problem with BER calculation. I made a
coherent correlation type detector in MATLAB for a BPSK signal, but
when I demodulate the noised signal BER is much worse than it sould
be in theory for coherent detection. I add noise using awgn()
function setting the desired SNR[dB]. I assume
Eb/No[dB]=SNR[dB]+10log(Tbit/Tsample) So why is it? My M-files are
attached. I used 500 bits to simulate and SNR=-12dB which equals
according to the equation Eb/No=8dB. Theoretically the result shoul
have been around 1e-4 and I get BER=4e-2. Plz help!!!
From: Idin Motedayen-Aval on
Bogdan Mikhailets wrote:
> Guys, I need to solve the problem with BER calculation. I made a
> coherent correlation type detector in MATLAB for a BPSK signal, but
> when I demodulate the noised signal BER is much worse than it sould
> be in theory for coherent detection. I add noise using awgn()
> function setting the desired SNR[dB]. I assume
> Eb/No[dB]=SNR[dB]+10log(Tbit/Tsample) So why is it? My M-files are
> attached. I used 500 bits to simulate and SNR=-12dB which equals
> according to the equation Eb/No=8dB. Theoretically the result shoul
> have been around 1e-4 and I get BER=4e-2. Plz help!!!

Hi Bogdan,
I don't see your code, so I don't know how complex a system you're
simulating. A couple of things jump out at me:
- 500 bits is a very small number of bits for simulating a BER of 1e-4;
you should use at least about 1e6 bits.
- I'm confused by getting from SNR of -12dB to Eb/No of 8dB. What is
your over-sampling rate? From your formula, we would have Tbit/Tsample
= 100. Is that really the over-sampling rate?

You also have to realize that the AWGN function behaves differently for
real and complex inputs (the documentation describes how, but
essentially your Eb/No will be off by 3dB if you use real signals).
It's something to look out for.

HTH,
Idin Motedayen-Aval
The MathWorks
From: Bogdan Mikhailets on
To Idin Motedayen-Aval: My code is in 3 small m-files that
are started in the order:
1. BPSK modulation
2. noise addition
3. BPSK detection
here they are
1.
%bpskmodulation
N=1000;%number of bits
a=sign(rand(1,N)-0.5);%generating random sequence of bits
T=1;%bit interval
t=0:0.01*T:N*T-0.01*T;%time
f=3;% carrier frequency
scar=sin(2*pi*f*t);% not modulated carrier
for k=1:size(a,2)
for j=(k-1)*100+1:k*100
s(j)=a(k).*scar(j); %bpsk signal
end;
end;
sorig=s;% save bpsk signal for future purpose of noise addition

2.
%noise addition
bpsksig=sorig;
SNRset=-12;% SNR in dB
s=awgn(bpsksig,SNRset);% adding noise to signal

%resulting Eb/No[dB]=10log(Tsymbol/Tsample)+SNR[dB]
%in my case Tsymbol=T,Tsample=0.01*T; so Eb/No[dB]=20+SNR[dB]
%figure(1); plot(s(1:500));grid

3.
%correlation detection
tt=0:0.01*T:T-0.01*T;

sinerom(1,:)=sin(2*pi*f*tt);%signal copy of sine representing '1'
sinerom(2,:)=-sin(2*pi*f*tt);%signal copy of sine representing '-1'
with inverted phase
for k=1:size(a,2)
for i=1:2
for jj=1:100
cosintegral(k,i,jj)=s((k-1)*100+jj).*sinerom(i,jj); %
here correlation-type detector
end; % is realized ; first
multiplying the received signal
%with signal copies in the 2
branches of
%correlator
end;
end;
j=0;
for k=1:size(a,2)
for i=1:2
cossum(k,i)=sum(cosintegral(k,i,:)); % here is integration
or just sum of th samples
end;
maxcossum(k)=max(cossum(k,:)); % here max value of the
correlator branches is determined
end;
for k=1:size(a,2)
for i=1:2
if cossum(k,i)==maxcossum(k)
indexcossum(k)=i; %here the number of
the branch where maximum
% is achieved (1 or 2)
end;
end;
end;
atrsec=[1 -1];
for k=1:size(a,2)
adetsec(k)=atrsec(indexcossum(k)); % the 1st branch means '1'
has been transmitted
end; % the 2nd branch means '-1'
has been transmitted

for j=1:size(a,2)
res(j)=adetsec(j)-a(j);
end;
max(res)
min(res)
kjk=0;
for j=1:size(a,2)
if res(j)==0
kjk=kjk+1;
end;
end;
errornum=size(a,2)-kjk %number of errors
format short e;
bercalc=errornum/size(a,2) %BER
format;

Idin Motedayen-Aval wrote:
>
>
> Bogdan Mikhailets wrote:
>> Guys, I need to solve the problem with BER calculation. I made
a
>> coherent correlation type detector in MATLAB for a BPSK signal,
> but
>> when I demodulate the noised signal BER is much worse than it
> sould
>> be in theory for coherent detection. I add noise using awgn()
>> function setting the desired SNR[dB]. I assume
>> Eb/No[dB]=SNR[dB]+10log(Tbit/Tsample) So why is it? My M-files
> are
>> attached. I used 500 bits to simulate and SNR=-12dB which
equals
>> according to the equation Eb/No=8dB. Theoretically the result
> shoul
>> have been around 1e-4 and I get BER=4e-2. Plz help!!!
>
> Hi Bogdan,
> I don't see your code, so I don't know how complex a system you're
> simulating. A couple of things jump out at me:
> - 500 bits is a very small number of bits for simulating a BER of
> 1e-4;
> you should use at least about 1e6 bits.
> - I'm confused by getting from SNR of -12dB to Eb/No of 8dB. What
> is
> your over-sampling rate? From your formula, we would have
> Tbit/Tsample
> = 100. Is that really the over-sampling rate?
>
> You also have to realize that the AWGN function behaves differently
> for
> real and complex inputs (the documentation describes how, but
> essentially your Eb/No will be off by 3dB if you use real signals).
>
> It's something to look out for.
>
> HTH,
> Idin Motedayen-Aval
> The MathWorks
>