DSPRelated.com
Forums

the benifit of convolution code

Started by minnows December 5, 2008
Hi,all
    i write a m file to watch the benifit of convolution coding. 3 cases
are compare:
1. no coding
2. CC coding, no puncture
3. CC coding, 4/6 puncture

Strangely, the BER of case 3 is worse than case 1. Below is my matlab
code. what's wrong?


% ber=SNRveri(snr,code,repeat,punc)
% input    snr           SNR
%          code
%              0:        encoding
%              1:        no coding
%          repeat        repeat time
%          punc          puncture rate
%              0:        no puncture
%              1:        4/6 puncture
% output    
%          ber           BER
% example
%          ber=SNRveri(13,0,1000,1)
%
%

function ber=SNRveri(snr,code,repeat,punc)

% reset error bit number and total Tx bit number
errnum=0;
txnum=0;
for ii=1:repeat
    %disp(ii);
    switch code
        case 0
            switch punc
                case 0
                    % produce original binary array
                    bitdata=randint(256*4*1/2-6,1);
                    % coding
                    tailIn=[bitdata; zeros(6,1)];
                    trel = poly2trellis(7,[171 133]);
                    EncdBtVec=convenc(tailIn,trel);
                case 1
                    % produce original binary array
                    bitdata=randint(256*4*3/4-6,1);
                    % coding
                    tailIn=[bitdata; zeros(6,1)];
                    punctpat=[1 1 0 1 0 1];
                    trel = poly2trellis(7,[171 133]);
                    EncdBtVec=convenc(tailIn,trel,punctpat);
            end
        case 1
            %no coding
            bitdata=randint(256*4,1);
            EncdBtVec=bitdata;
    end
   
    %modulation using matlab function
    h= modem.qammod(16);
    h.inputtype = 'bit';
    SymVec=modulate(h,EncdBtVec);
    
    sam_time=SymVec;
    ch_sig=awgn(sam_time,snr,'measured');
    sym_fre=ch_sig;

    %demodulate using matlab function
    rh=modem.qamdemod(16);
    rh.outputtype = 'bit';
    DemodBtVec=demodulate(rh,sym_fre);

    switch code
        case 0
            switch punc
                case 0
                    % decode
                    trel = poly2trellis(7,[171 133]);
                    tblen = 7; % Traceback length
                    tailBtVec =
vitdec(DemodBtVec,trel,tblen,'term','hard'); %Hard input decoder
                    DecdBtVec=tailBtVec(1:length(tailBtVec)-6);  %remove
tail bits
                    BitVecRx=DecdBtVec;
                case 1
                    % decode
                    punctpat=[1 1 0 1 0 1];
                    trel = poly2trellis(7,[171 133]);
                    tblen = 6; % Traceback length
                    tailBtVec =
vitdec(DemodBtVec,trel,tblen,'term','hard',punctpat); %Hard input decoder
                    DecdBtVec=tailBtVec(1:length(tailBtVec)-6);  %remove
tail bits
                    BitVecRx=DecdBtVec;
            end
        case 1
            BitVecRx=DemodBtVec;
    end
    % calculate error bit number and correct bit number for current run
    err=0;
    crt=0;
    for jj=1:length(bitdata)
        if (bitdata(jj)==BitVecRx(jj))
            crt=crt+1;
        else
            err=err+1;
        end
    end
    % add up error bit number and total transmitted bit number
    errnum=errnum+err;
    txnum=txnum+(err+crt);
end
ber=errnum/txnum;
disp(ber);

minnows wrote:

> Hi,all > i write a m file to watch the benifit of convolution coding. 3 cases > are compare: > 1. no coding > 2. CC coding, no puncture > 3. CC coding, 4/6 puncture > > Strangely, the BER of case 3 is worse than case 1. Below is my matlab > code. what's wrong?
As the Eb/No decreases, the coding gain decreases, too. For any code, there is a critical SNR value where the coding gain == 1. If the SNR is below this value, the code only makes the things worse compared to the uncoded case. The weaker is the code, the higher is the critical SNR. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
On Fri, 05 Dec 2008 09:10:23 -0600, Vladimir Vassilevsky wrote:

> minnows wrote: > >> Hi,all >> i write a m file to watch the benifit of convolution coding. 3 >> cases >> are compare: >> 1. no coding >> 2. CC coding, no puncture >> 3. CC coding, 4/6 puncture >> >> Strangely, the BER of case 3 is worse than case 1. Below is my matlab >> code. what's wrong? > > As the Eb/No decreases, the coding gain decreases, too. For any code, > there is a critical SNR value where the coding gain == 1. If the SNR is > below this value, the code only makes the things worse compared to the > uncoded case. The weaker is the code, the higher is the critical SNR. >
Moreover when the decoded BER gets bad, it gets _really_ bad. You should plot your BER vs. Eb/No for a variety of Eb/No (or plot decoded BER vs. input BER) -- you'll see this effect right off. -- Tim Wescott Control systems and communications consulting http://www.wescottdesign.com Need to learn how to apply control theory in your embedded system? "Applied Control Theory for Embedded Systems" by Tim Wescott Elsevier/Newnes, http://www.wescottdesign.com/actfes/actfes.html
On Fri, 05 Dec 2008 09:10:23 -0600, Vladimir Vassilevsky wrote:

> minnows wrote: > >> Hi,all >> i write a m file to watch the benifit of convolution coding. 3 >> cases >> are compare: >> 1. no coding >> 2. CC coding, no puncture >> 3. CC coding, 4/6 puncture >> >> Strangely, the BER of case 3 is worse than case 1. Below is my matlab >> code. what's wrong? > > As the Eb/No decreases, the coding gain decreases, too. For any code, > there is a critical SNR value where the coding gain == 1. If the SNR is > below this value, the code only makes the things worse compared to the > uncoded case. The weaker is the code, the higher is the critical SNR. >
This reminds me of an epiphanette* I had about FM radio, specifically that it has an input SNR to output SNR curve that is very reminiscent of an error correcting code. This makes sense because FM uses redundant information (TX bandwidth higher than signal bandwidth) in a not- immediately-obvious manner. It's interesting that it has the same "when things go to hell they go to hell fast" character of digital FEC. * An epiphanette happens when you suddenly see the true nature of a small and insignificant thing. -- Tim Wescott Control systems and communications consulting http://www.wescottdesign.com Need to learn how to apply control theory in your embedded system? "Applied Control Theory for Embedded Systems" by Tim Wescott Elsevier/Newnes, http://www.wescottdesign.com/actfes/actfes.html
Tim Wescott wrote:
> On Fri, 05 Dec 2008 09:10:23 -0600, Vladimir Vassilevsky wrote: > >> minnows wrote: >> >>> Hi,all >>> i write a m file to watch the benifit of convolution coding. 3 >>> cases >>> are compare: >>> 1. no coding >>> 2. CC coding, no puncture >>> 3. CC coding, 4/6 puncture >>> >>> Strangely, the BER of case 3 is worse than case 1. Below is my matlab >>> code. what's wrong? >> As the Eb/No decreases, the coding gain decreases, too. For any code, >> there is a critical SNR value where the coding gain == 1. If the SNR is >> below this value, the code only makes the things worse compared to the >> uncoded case. The weaker is the code, the higher is the critical SNR. >> > This reminds me of an epiphanette* I had about FM radio, specifically > that it has an input SNR to output SNR curve that is very reminiscent of > an error correcting code. This makes sense because FM uses redundant > information (TX bandwidth higher than signal bandwidth) in a not- > immediately-obvious manner. It's interesting that it has the same "when > things go to hell they go to hell fast" character of digital FEC.
With me, it was the other way round. When firdt reading up on coding, my reaction was, "Gee! Just like FM."
> * An epiphanette happens when you suddenly see the true nature of a small > and insignificant thing.
Thanks for augmenting my vocabulary! Jerry -- Engineering is the art of making what you want from things you can get. ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
> > >minnows wrote: > >> Hi,all >> i write a m file to watch the benifit of convolution coding. 3
cases
>> are compare: >> 1. no coding >> 2. CC coding, no puncture >> 3. CC coding, 4/6 puncture >> >> Strangely, the BER of case 3 is worse than case 1. Below is my matlab >> code. what's wrong? > >As the Eb/No decreases, the coding gain decreases, too. For any code, >there is a critical SNR value where the coding gain == 1. If the SNR is >below this value, the code only makes the things worse compared to the >uncoded case. The weaker is the code, the higher is the critical SNR. > > >Vladimir Vassilevsky >DSP and Mixed Signal Design Consultant >http://www.abvolt.com >
i think there must be something wrong in my matlab code. as you can see, the BER of case 2 is lower than case 1. but puncture make things worse. set SNR=20dB and run my code for each case, i get: 1. BERveri(20,1,1000,0) no coding case: BER=4.88e-6 2. BERveri(20,0,1000,0) cc coding case: BER=0 3. BERveri(20,0,1000,1) cc coding and puncture case: BER=2e-5 the CC with puncture won't bring any benifits even in very high SNR. And this happens under any SNR value from very low to very high. so, there must be something wrong with my code.
> > This reminds me of an epiphanette* I had about FM radio, specifically > > that it has an input SNR to output SNR curve that is very reminiscent of > > an error correcting code. �This makes sense because FM uses redundant > > information (TX bandwidth higher than signal bandwidth) in a not- > > immediately-obvious manner. �It's interesting that it has the same "when > > things go to hell they go to hell fast" character of digital FEC. > >
With me, it was the other way round. When firdt reading up on coding, my
> reaction was, "Gee! Just like FM." > > >
YES EXACTLY ME TOO!!! Mark