deep8006
Newbie level 1
Hi everbody,
I am working on my course project in developing MSK transmitter and receiver. I have modulator and demodulator working perfectly. Problem comes when i tried to add white gaussian noise in the channel. The receiver output is still the same it has no effect of addition of white noise. As a result bit error rate is zero with changing values of Eb/N0. I think i might be doing something wrong in adding noise to the channel.
Please suggest me some ways of adding white gaussian noise. I have also attached the code i am using for MSK:
clc;
clear all;
N = 100; % number of bits or symbols
fsHz = 10; % sampling period
T = 4; % symbol duration
fc = 1;
Eb_N0_dB = [0:10]; % multiple Eb/N0 values
ct = cos(pi*[-T:.1:N*T-.1]/(2*T));
st = sin(pi*[-T:.1:N*T-.1]/(2*T));
cart = cos(2*pi*fc*[-T:.1:N*T-.1]);
sart = sin(2*pi*fc*[-T:.1:N*T-.1]);
for ii = 1:length(Eb_N0_dB)
% MSK Transmitter
rand('seed',999);
ipBit = rand(1,N)>0.5; % generating 0,1 with equal probability
ipMod = 2*ipBit - 1; % BPSK modulation 0 -> -1, 1 -> 1
ai = kron(ipMod(1:2:end),ones(1,2*T)); % even bits
aq = kron(ipMod(2:2:end),ones(1,2*T)); % odd bits
ai = [ai zeros(1,T)]; % padding with zero to make the matrix dimension match
aq = [zeros(1,T) aq ]; % adding delay of T for Q-arm
n=1;
l= size(ai);
c=4;
k=4;
m=1;
j=1;
for i = -T:.1:N*T-.1
if i<(2*n-1)*T
air(j) = ai(k);
j=j+1;
else
k=(2*m+1)*c;
n=n+1;
air(j) = ai(k);
j=j+1;
m=m+1;
end
end
n=0;
c=4;
k=4;
m=1;
j=1;
for i = -T:.1:N*T-.1
if i<(2*n)*T
aqr(j) = aq(k);
j=j+1;
else
k=(2*m+1)*c;
n=n+1;
aqr(j) = aq(k);
j=j+1;
m=m+1;
end
end
x1t = air.*ct.*cart+aqr.*st.*sart;
% % Addition of white gaussian Noise
k = 16;
snr = ((1/fsHz)/T)*[Eb_N0_dB(ii)+10*log10(k)]
yt = awgn(x1t, snr);
%% MSK receiver
% multiplying with cosine and sine waveforms
AII = yt.*ct.*cart;
AQQ = yt.*st.*sart;
CII = AII;
CQQ = AQQ;
h=1;
g=1;
d=1;
k=0;
count1=0;
for i = 1N*T)*fsHz
if(h <2*T*fsHz)
count1 = count1+CII(i);
h=h+1;
else
xE(d)=count1;
d=d+1;
count1 = 0;
h=1;
end
end
count2=0;
d=1;
for i = T*fsHzN*T+T)*fsHz
if(g <2*T*fsHz)
count2 = count2+CQQ(i);
g=g+1;
else
xO(d)=count2;
d=d+1;
count2 = 0;
g=1;
end
end
bHat = zeros(1,N);
bHat(1:2:end) = xE(1:N/2) > 0 ; % even bits
bHat(2:2:end) = xO(1:N/2) > 0 ; % odd bits
% counting the errors
nErr(ii) = size(find([ipBit - bHat]),2);
end
simBer = nErr/N; % simulated ber
theoryBer = 0.5*erfc(sqrt(10.^(Eb_N0_dB/10))); % theoretical ber
close all
% plot(kron(xt,ones(1,fsHz)));
% axis([0 N*fsHz -1 1]);grid on
figure
semilogy(Eb_N0_dB,theoryBer,'bs-','LineWidth',2);
hold on
semilogy(Eb_N0_dB,simBer,'mx-','LineWidth',2);
axis([0 10 10^-5 0.5])
grid on
legend('theory - bpsk', 'simulation - msk');
xlabel('Eb/No, dB');
ylabel('Bit Error Rate');
title('Bit error probability curve for MSK modulation');
% plot(xt);
% axis([0 N*fs -1 1]);grid on
I really appreciate your kind help.
Thanks a lot!!
I am working on my course project in developing MSK transmitter and receiver. I have modulator and demodulator working perfectly. Problem comes when i tried to add white gaussian noise in the channel. The receiver output is still the same it has no effect of addition of white noise. As a result bit error rate is zero with changing values of Eb/N0. I think i might be doing something wrong in adding noise to the channel.
Please suggest me some ways of adding white gaussian noise. I have also attached the code i am using for MSK:
clc;
clear all;
N = 100; % number of bits or symbols
fsHz = 10; % sampling period
T = 4; % symbol duration
fc = 1;
Eb_N0_dB = [0:10]; % multiple Eb/N0 values
ct = cos(pi*[-T:.1:N*T-.1]/(2*T));
st = sin(pi*[-T:.1:N*T-.1]/(2*T));
cart = cos(2*pi*fc*[-T:.1:N*T-.1]);
sart = sin(2*pi*fc*[-T:.1:N*T-.1]);
for ii = 1:length(Eb_N0_dB)
% MSK Transmitter
rand('seed',999);
ipBit = rand(1,N)>0.5; % generating 0,1 with equal probability
ipMod = 2*ipBit - 1; % BPSK modulation 0 -> -1, 1 -> 1
ai = kron(ipMod(1:2:end),ones(1,2*T)); % even bits
aq = kron(ipMod(2:2:end),ones(1,2*T)); % odd bits
ai = [ai zeros(1,T)]; % padding with zero to make the matrix dimension match
aq = [zeros(1,T) aq ]; % adding delay of T for Q-arm
n=1;
l= size(ai);
c=4;
k=4;
m=1;
j=1;
for i = -T:.1:N*T-.1
if i<(2*n-1)*T
air(j) = ai(k);
j=j+1;
else
k=(2*m+1)*c;
n=n+1;
air(j) = ai(k);
j=j+1;
m=m+1;
end
end
n=0;
c=4;
k=4;
m=1;
j=1;
for i = -T:.1:N*T-.1
if i<(2*n)*T
aqr(j) = aq(k);
j=j+1;
else
k=(2*m+1)*c;
n=n+1;
aqr(j) = aq(k);
j=j+1;
m=m+1;
end
end
x1t = air.*ct.*cart+aqr.*st.*sart;
% % Addition of white gaussian Noise
k = 16;
snr = ((1/fsHz)/T)*[Eb_N0_dB(ii)+10*log10(k)]
yt = awgn(x1t, snr);
%% MSK receiver
% multiplying with cosine and sine waveforms
AII = yt.*ct.*cart;
AQQ = yt.*st.*sart;
CII = AII;
CQQ = AQQ;
h=1;
g=1;
d=1;
k=0;
count1=0;
for i = 1N*T)*fsHz
if(h <2*T*fsHz)
count1 = count1+CII(i);
h=h+1;
else
xE(d)=count1;
d=d+1;
count1 = 0;
h=1;
end
end
count2=0;
d=1;
for i = T*fsHzN*T+T)*fsHz
if(g <2*T*fsHz)
count2 = count2+CQQ(i);
g=g+1;
else
xO(d)=count2;
d=d+1;
count2 = 0;
g=1;
end
end
bHat = zeros(1,N);
bHat(1:2:end) = xE(1:N/2) > 0 ; % even bits
bHat(2:2:end) = xO(1:N/2) > 0 ; % odd bits
% counting the errors
nErr(ii) = size(find([ipBit - bHat]),2);
end
simBer = nErr/N; % simulated ber
theoryBer = 0.5*erfc(sqrt(10.^(Eb_N0_dB/10))); % theoretical ber
close all
% plot(kron(xt,ones(1,fsHz)));
% axis([0 N*fsHz -1 1]);grid on
figure
semilogy(Eb_N0_dB,theoryBer,'bs-','LineWidth',2);
hold on
semilogy(Eb_N0_dB,simBer,'mx-','LineWidth',2);
axis([0 10 10^-5 0.5])
grid on
legend('theory - bpsk', 'simulation - msk');
xlabel('Eb/No, dB');
ylabel('Bit Error Rate');
title('Bit error probability curve for MSK modulation');
% plot(xt);
% axis([0 N*fs -1 1]);grid on
I really appreciate your kind help.
Thanks a lot!!