sa269
Newbie level 4
bit error ratio in c program
I am doing a project in convolutional coding and i have to write a program about modulation with AWGN channel or noise, doesnt mater. I have this program which doesn't give me good BER. i am confused and dont know how to di it. after i finish this i have to apply convolutional coding and observe the change in BER. here is the program: (the program is a bit of mess like my state of mind)
% this program build communication system with bpsk modulation, adds noise,
% and find the BER for it.
x=rand(64,1);%64 symbols
data=round(x)'; %64 1s and 0s
l = 64; %length of modulation steps
BER=[]; %define bit error rate
e=0;% number of errors is defined at 0
% bpsk modulation gives -1 for 0s bits and 1s for 1s bits
for b = 1 : l
if data(b) == 0
temp1(b) = -1;
else temp1(b) = 1;
end
end
% AWGN channel noise and SNR loop
for snr=0:0.1:6.3 %100 steps
e=0;
% AWGN channel
temp2 = awgn(temp1, snr);
% demodulation
for c= 1 : l
if temp2(c) <= 0
data_dec(c) = 0 ; %recovers the -1 back to 0 as in the original data before modulation
else data_dec(c) = 1;
end
end
% BER caculation
for m= 1:l
if (data(m) ~=data_dec(m)),%compare the demodulated with the original signal. if error adds 1.
e = e + 1;
end
end
BER = [BER e/l];
end
anyone knows how to do it? i apprecaiteyour help. thanks in advanve.
I am doing a project in convolutional coding and i have to write a program about modulation with AWGN channel or noise, doesnt mater. I have this program which doesn't give me good BER. i am confused and dont know how to di it. after i finish this i have to apply convolutional coding and observe the change in BER. here is the program: (the program is a bit of mess like my state of mind)
% this program build communication system with bpsk modulation, adds noise,
% and find the BER for it.
x=rand(64,1);%64 symbols
data=round(x)'; %64 1s and 0s
l = 64; %length of modulation steps
BER=[]; %define bit error rate
e=0;% number of errors is defined at 0
% bpsk modulation gives -1 for 0s bits and 1s for 1s bits
for b = 1 : l
if data(b) == 0
temp1(b) = -1;
else temp1(b) = 1;
end
end
% AWGN channel noise and SNR loop
for snr=0:0.1:6.3 %100 steps
e=0;
% AWGN channel
temp2 = awgn(temp1, snr);
% demodulation
for c= 1 : l
if temp2(c) <= 0
data_dec(c) = 0 ; %recovers the -1 back to 0 as in the original data before modulation
else data_dec(c) = 1;
end
end
% BER caculation
for m= 1:l
if (data(m) ~=data_dec(m)),%compare the demodulated with the original signal. if error adds 1.
e = e + 1;
end
end
BER = [BER e/l];
end
anyone knows how to do it? i apprecaiteyour help. thanks in advanve.