DSPRelated.com
Forums

cyclic code (7,4) BER simulation

Started by Unknown March 29, 2016
Hello, 

I'm new in this domain. 
I want some clarifications and help to realize my project. 
The tasks of my project are the following : 

1-We Consider a binary cyclic code of length n = 7, and generator polynomial     g (X) =X^3+X+1 
2-To Make simulations to measure the bit error rate BER ratio between the exchange of encoded information  with the power Eb with binary symbol of two sensors separated by a AWGN channel (AWGN = additive white Gaussian noise) with power spectral density. 
3-To Draw BER vs SNR (SNR = signal noise ratio) 
4-Find the theoretical expression of the BER vs SNR 
5-The same exercise with Rayleigh channel 

I'm currently searching all necessary documents and i try to understand the problem to solve it. 
Please, don't hesitate to help me with any clarifications to achieve this project in the right way and understand all the steps to conduct good project. 

Thanks In advance   
<kortas.manel@gmail.com> wrote:

>The tasks of my project are the following :
>1-We Consider a binary cyclic code of length n = 7, and generator >polynomial g (X) =X^3+X+1
Okay
>2-To Make simulations to measure the bit error rate BER ratio between >the exchange of encoded information with the power Eb with binary >symbol of two sensors separated by a AWGN channel (AWGN = additive white >Gaussian noise) with power spectral density.
For this you are going to have to specify a modulation mode, for example, BPSK. You are also going to have to implement a decoder, which in this case -- because the code is so short -- can just be a maximum liklyhood decoder implemented by exhaustive search. That is, for each received codeword, choose which of the 16 possible information bit patterns is most likely.
>3-To Draw BER vs SNR (SNR = signal noise ratio)
Okay
>4-Find the theoretical expression of the BER vs SNR
This is not exactly simple, unless you want to make some approximations.
>5-The same exercise with Rayleigh channel
You'll need parameters for the Rayleigh channel. Good luck. Steve
On 29.03.2016 23:05, kortas.manel@gmail.com wrote:
> Hello, > > I'm new in this domain. > I want some clarifications and help to realize my project. > The tasks of my project are the following : > > 1-We Consider a binary cyclic code of length n = 7, and generator polynomial g (X) =X^3+X+1 > 2-To Make simulations to measure the bit error rate BER ratio between the exchange of encoded information with the power Eb with binary symbol of two sensors separated by a AWGN channel (AWGN = additive white Gaussian noise) with power spectral density. > 3-To Draw BER vs SNR (SNR = signal noise ratio) > 4-Find the theoretical expression of the BER vs SNR > 5-The same exercise with Rayleigh channel > > I'm currently searching all necessary documents and i try to understand the problem to solve it. > Please, don't hesitate to help me with any clarifications to achieve this project in the right way and understand all the steps to conduct good project. > > Thanks In advance >
A good book to get some answers (like some theoretical bounds for BER vs SNR) is "Digital Communications" by Proakis and Salehi. Basically, you can decode a FEC code by employing either soft or hard decisions. With soft-decision decoding your goal is to find the minimum Euclidian distance to a codeword, while with hard-decision decoding you are minimizing the Hamming distance to a codeword. Soft-decision decoding (the option Steve suggested) outperforms hard-decision decoding, but is more computationally burdensome. Best of luck with a Hamming code project! Evgeny.
Evgeny Filatov  <filatov.ev@mipt.ru> wrote:

>Basically, you can decode a FEC code by employing either soft or hard >decisions.
Yes
>With soft-decision decoding your goal is to find the minimum >Euclidian distance to a codeword,
Not in the general case, but sometimes.
>while with hard-decision decoding you >are minimizing the Hamming distance to a codeword. Soft-decision >decoding (the option Steve suggested) outperforms hard-decision >decoding, but is more computationally burdensome.
I said to find the maximum likelyhood estimate. Actually, one can in this case (I know as I have simulated it for a (15,11) Hamming code) use the BCJR algorithm and obtain a lower BER than the Viterbi algorithm (one the order of 1/10 dB improvement). Steve
>Best of luck with a Hamming code project! > >Evgeny. >
On 31.03.2016 22:58, Steve Pope wrote:

(snip)

>> With soft-decision decoding your goal is to find the minimum >> Euclidian distance to a codeword, > > Not in the general case, but sometimes.
Let me guess -- soft-output Viterbi algorithm is a case when you are minimizing the probability of a burst error, rather than a bit error, so it doesn't minimize the Euclidian distance?
> >> while with hard-decision decoding you >> are minimizing the Hamming distance to a codeword. Soft-decision >> decoding (the option Steve suggested) outperforms hard-decision >> decoding, but is more computationally burdensome. > > I said to find the maximum likelyhood estimate. Actually, one > can in this case (I know as I have simulated it for a (15,11) > Hamming code) use the BCJR algorithm and obtain a lower BER > than the Viterbi algorithm (one the order of 1/10 dB improvement). > > Steve
Okey. Perhaps I've used a wrong term. But "minimum Euclidian distance" is just another way to say "maximum likelihood estimate" in this context, isn't it? Evgeny
Evgeny Filatov  <e.v.filatov@ieee.org> wrote:

>On 31.03.2016 22:58, Steve Pope wrote:
>>> With soft-decision decoding your goal is to find the minimum >>> Euclidian distance to a codeword,
>> Not in the general case, but sometimes.
>Let me guess -- soft-output Viterbi algorithm is a case when you are >minimizing the probability of a burst error, rather than a bit error, so >it doesn't minimize the Euclidian distance?
I'll describe this below.
>>> while with hard-decision decoding you >>> are minimizing the Hamming distance to a codeword. Soft-decision >>> decoding (the option Steve suggested) outperforms hard-decision >>> decoding, but is more computationally burdensome.
>> I said to find the maximum likelyhood estimate. Actually, one >> can in this case (I know as I have simulated it for a (15,11) >> Hamming code) use the BCJR algorithm and obtain a lower BER >> than the Viterbi algorithm (one the order of 1/10 dB improvement).
>Okey. Perhaps I've used a wrong term. But "minimum Euclidian distance" >is just another way to say "maximum likelihood estimate" in this >context, isn't it?
Only when things work out such that they are the same. Consider transmitting one bit of information modulated by amplitude shift keying as follows, then sent over an AWGN channel: If the bit is zero, the transmitted constellation point is equal to one. If the bit is one, then with 80% probability the transmitted constellation point is zero, otherwise it is two. I claim you cannot construct a Euclidean distance metric that gives you the right answer for the maximum-likelyhood estimate for the transmitted bit, and in fact you are going to need to know the SNR to get the right answer. The general case for most useful constellations is that Euclidean distances will give you the nearest-neighbor approximation, which might be exactly ML if the inequality you are trying to evaluate P(transmitted bit is a one) > P(transmitted bit is a zero) can be made equivalent to an inequality involving Euclidean distances. If one bit is being modulated onto two equiprobable constellation points then sent over an AWGN channel then the SNR drops out of the equation and this condition is met. In the OP's example four bits are being modulated onto 2^7 constellation points and the best estimate for each individual bit is obtainable by either the BCJR algorithm or brute force. A close approximation is to obtain the best (maximum likelyhood) estimate of the four-bit value (instead of a separate maximum- likelyhood esimates for each bit), which can be done using Euclidean distances and, if you like, the Viterbi algorithm but the BER will be very slightly worse. (Understanding why the BCJR and Viterbi results are different is fundamental, although maybe overkill for the OP's situation.) Steve
On 01.04.2016 0:09, Steve Pope wrote:
> Evgeny Filatov <e.v.filatov@ieee.org> wrote: > >> On 31.03.2016 22:58, Steve Pope wrote: > >>>> With soft-decision decoding your goal is to find the minimum >>>> Euclidian distance to a codeword, > >>> Not in the general case, but sometimes. > >> Let me guess -- soft-output Viterbi algorithm is a case when you are >> minimizing the probability of a burst error, rather than a bit error, so >> it doesn't minimize the Euclidian distance? > > I'll describe this below. > >>>> while with hard-decision decoding you >>>> are minimizing the Hamming distance to a codeword. Soft-decision >>>> decoding (the option Steve suggested) outperforms hard-decision >>>> decoding, but is more computationally burdensome. > >>> I said to find the maximum likelyhood estimate. Actually, one >>> can in this case (I know as I have simulated it for a (15,11) >>> Hamming code) use the BCJR algorithm and obtain a lower BER >>> than the Viterbi algorithm (one the order of 1/10 dB improvement). > >> Okey. Perhaps I've used a wrong term. But "minimum Euclidian distance" >> is just another way to say "maximum likelihood estimate" in this >> context, isn't it? > > Only when things work out such that they are the same. > > Consider transmitting one bit of information modulated by amplitude > shift keying as follows, then sent over an AWGN channel: > > If the bit is zero, the transmitted constellation point is equal to > one. > > If the bit is one, then with 80% probability the transmitted constellation > point is zero, otherwise it is two. > > I claim you cannot construct a Euclidean distance metric that gives > you the right answer for the maximum-likelyhood estimate for the > transmitted bit, and in fact you are going to need to know the SNR > to get the right answer.
I don't have any hopes to succeed with that. :) I've got your point. That's an important distinction, thanks for clarifying it!
> > The general case for most useful constellations is that Euclidean > distances will give you the nearest-neighbor approximation, which might > be exactly ML if the inequality you are trying to evaluate > > P(transmitted bit is a one) > P(transmitted bit is a zero) > > can be made equivalent to an inequality involving Euclidean distances. > If one bit is being modulated onto two equiprobable constellation > points then sent over an AWGN channel then the SNR drops out of the > equation and this condition is met. > > In the OP's example four bits are being modulated onto 2^7 > constellation points and the best estimate for each individual bit > is obtainable by either the BCJR algorithm or brute force. > > A close approximation is to obtain the best (maximum likelyhood) > estimate of the four-bit value (instead of a separate maximum- > likelyhood esimates for each bit), which can be done using > Euclidean distances and, if you like, the Viterbi algorithm > but the BER will be very slightly worse.
That makes me tempted to read the article on generalized Viterbi algorithm. Perhaps one (other rainy) day I will. Evgeny
> > (Understanding why the BCJR and Viterbi results are different > is fundamental, although maybe overkill for the OP's situation.) > > > Steve >
On 01.04.2016 0:09, Steve Pope wrote:

(snip)

> Consider transmitting one bit of information modulated by amplitude > shift keying as follows, then sent over an AWGN channel: > > If the bit is zero, the transmitted constellation point is equal to > one. > > If the bit is one, then with 80% probability the transmitted constellation > point is zero, otherwise it is two. >
Incidentally, was your construction of this example at least partially motivated by duobinary signals? Evgeny
Evgeny Filatov  <filatov.ev@mipt.ru> wrote:

>On 01.04.2016 0:09, Steve Pope wrote:
>> Consider transmitting one bit of information modulated by amplitude >> shift keying as follows, then sent over an AWGN channel: >> >> If the bit is zero, the transmitted constellation point is equal to >> one. >> >> If the bit is one, then with 80% probability the transmitted constellation >> point is zero, otherwise it is two.
>Incidentally, was your construction of this example at least partially >motivated by duobinary signals?
No, actually it was just the first example that occured to me of a signal for which Euclidean metrics do not work. Steve
Hello,
thank you for your answers: I implement this code to simulate the BER for a cyclic code through a AWGN channel:
clear all;
close all;
n=7;
k=4;
genpoly=cyclpoly(n,k)
berf=[];
Eb_N0_dB = [1:10];
for i=1:length(Eb_N0_dB)
            b=0;
            for j=1:100
        msg= randi([0,1],500*k,1);
        code=encode(msg,n,k,'cyclic/binary',genpoly);
        code_modulatedBPSK = 2*code-1;
     t=0:0.1:10;
        y=awgn(code_modulatedBPSK, Eb_N0_dB(i));
        y(find(y>0))=1;
        y(find(y<0))=0;   %seuillage , d&#4294967295;codage &#4294967295; entr&#4294967295;es dures 
                   %  yy = real(y)>0;

     h = cyclgen(n, genpoly) ;
     trt= syndtable(h) ;
msgop=decode(y,n,k,'cyclic/binary',genpoly,trt); % d&#4294967295;code en utilisant la table syndrome de d&#4294967295;codage trt
            [number,b1]=biterr(msgop,msg);
     b=b+b1;
 end
    berf(i)=b/100;
end	
            semilogy(Eb_N0_dB,berf);
                        
             axis([1 10 10^-5 0.5])
            grid on

title('performance analysis in AWGN for cyclic codes C(7,4)');
xlabel (' Eb/N0 (db)');
ylabel ('BER');
And  I implement this code to simulate the BER for a cyclic code through a Rayleigh channel:
clear all;
close all;
n=7;
k=4;
genpoly=cyclpoly(n,k)
berf=[];
Eb_N0_dB = [1:10];
for i=1:length(Eb_N0_dB)
                                               b=0;
                                               for j=1:100
                                               msg= randi([0,1],500*k,1);
                                               code=encode(msg,n,k,'cyclic/binary',genpoly);
                                               codee=code' ;
                                               code_modulatedBPSK = 2*codee-1;
              t=0:0.1:10;
                h = 1/sqrt(2)*[randn(1,500*n) + j*randn(1,500*n)]; % Rayleigh channel
 
        yy=awgn(h.*code_modulatedBPSK, Eb_N0_dB(i));
                % equalization
                 y = yy./h;

        y(find(y>0))=1;
        y(find(y<0))=0;   %seuillage , d&#4294967295;codage &#4294967295; entr&#4294967295;es dures 
                                                 %  yy = real(y)>0;
                                                  hh = cyclgen(n, genpoly) ;
                                                     trt= syndtable(hh) ;
                                 s=y' ;
        msgop=decode(s,n,k,'cyclic/binary',genpoly,trt); % d&#4294967295;code en utilisant la table syndrome de d&#4294967295;codage trt
        [number,b1]=biterr(msgop,msg);
     b=b+b1;
 end
    berf(i)=b/100;
end	
                                          semilogy(Eb_N0_dB,berf);                 
                                          axis([1 10 10^-5 0.5])
                                           grid on
title('performance analysis in Rayleigh for cyclic codes');
xlabel (' Eb/N0 (db)');
ylabel ('BER');

Please tell me if this is right or not.
I found an approximation of the theoretical expression of the BER as a function of SNR for the AWGN channel in this document http://easytp.cnam.fr/leruyet/Cours/book_ti_2010_2011.pdf page 91
but not for the rayleigh channel . please help me