File Exchange

image thumbnail

Turbo Code

version 1.5 (14.2 KB) by

Encoding: RSC, Decoding: BCJR

4.07692
18 Ratings

67 Downloads

Updated

View License

Modulation: BPSK
Channel: AWGN
Encoder: G(D)=[1,(1+D+D^2)/(1+D^2)]

Comments and Ratings (95)

Shubhdeep sam

hello sir,this program is not running..pls help me

liluqi

liluqi (view profile)

Could you send me the document for this code?I really need it please.contact me(1656508931@qq.com)Thanks very much.

liluqi

liluqi (view profile)

liluqi

liluqi (view profile)

sara jojo

Could you please send me the source code with adaptation of QPSK modulation?
I need it please!
 contact with me (eng85sana@gmail.com)
thanks

reborn

reborn (view profile)

about this code, it may be not totally correct
Input_matrix=2*[0,1;0,1;0,1;0,1]-1; %First column represents input=0 and second column represents input=1
%Each row represents state 00,10,01 and 11 respectively
Parity_bit_matrix=2*[0,1;1,0;0,1;1,0]-1; %Parity bits corresponding to inputs of above matrix

the Parity bits is not only depend on the current input, if the transmit is not the same, the Parity bits may be different

reborn

reborn (view profile)

hi, Yogesh
 the code ignore the process the deinterleave?
and how the receiver know the interleave

Ib El

Ib El (view profile)

Hi Yogesh
Could you please send me the source code with adaptation of QPSK modulation?
I need it please!
brahime.elouatiki@gmail.com

Thanks in advance

choimin


hi Yogesh
Can u send me the source code with adaptation of QAM modulation?
choi90kk@gmail.com

Thanks,

metin altinoz

Hello yogesh, I run the turbo.m and I observed iterations over the theoritical bound. I mean, ı didn't obtained ber graph like to you shared. What is the problem. How can I correct this problem?

nur ashikin

what is the constrain length,K is used?
hope mr yogesh or anybody here can answer it.

lots of thanks.

nur ashikin

HI yogesh,
im final year student,can you help me to check my turbo code coding because i cannot the error..can you give me your email, so i can sent my codingfor to check..
really hope your respond and help.

Yogesh K Soniwal

Hi Soujanya and Ben

ALPHA(1,i), ALPHA(2,i), ALPHA(3,i), ALPHA(4,i), for a fixed 'i' are for stated 00, 10, 01 and 11 respectively.

Yogesh

@Ben Zhang
Can you explain me what was that manipulation&why we have to do that manipulation?

Ben Zhang

@soujanya the input to the RSC encoder is not the actual data bit, is the bit after some manipulation.

@Ben Zhang,

I've the same doubt as you posted on 28th OCT 15
& on 2n NOV 15 you said it is correct, could you explain how it is?

saad Hardan

Ben Zhang

Hi Yogesh,

Sorry I would like to take that back. The transition of ALPHA and BETA is correct. Thanks for your code!

Ben Zhang

Hi Yogesh,

I read your code very carefully and I do agree with someone's comment below that your transition of ALPHA and BETA have some problem.
For example, this line ALPHA(4,i)=((GAMMA(4,j)*ALPHA(4,i-1))+(GAMMA(2,j+1)*ALPHA(2,i-1)));
The first term is incorrect, GAMMA(4,j) means current input is 0, ALPHA(4,i-1) means previous state is 11, it wont go to current state 11. But your final result is correct, which confused me a lot.

Ben Zhang

Hi Yogesh,

Thanks for your code. I have a question. When I tried your code with SNR larger than 10dB, the decoded bits it give me is all zero. But when SNR is smaller than 10dB, it works fine. Whats happen here?

Ben

Yogesh K Soniwal

Hi Younes and Krishna

You can download source code from "Download Zip" link on top right corner of this page.

Thanks
Yogesh

Yogesh K Soniwal

Hi Donny

I have not written Turbo code for QPSK modulation. You can refer to

http://in.mathworks.com/matlabcentral/fileexchange/39847-qpsk-performance-comparison-for-wireline-and-wireless-channel/content/qpsk.m

for implementing Turbo code for QPSK modulation.

Thanks
Yogesh

Kok Ann Donny

hi Yogesh and Joy,

Can u send me the source code with adaptation of QPSK modulation?
teo_kok_ann@hotmail.com

Thanks,
Donny

younes aimer

hi yogesh,
can u send me the source code...
younesaimer@gmail.com
thanks,
Younes

western

hi yogesh,
can u send me the source code...

thanks,
krishna.

joy lobo

I think the iitk mail id might be defunct now...and yogeshsoniwal@gmail.com is not being recognised...please tell me as to how to send u the code

joy lobo

Hey Yogesh,I have sent the code to ysoniwal@iitk.ac.in.Please check

joy lobo

Yogesh,whats your email id?yogeshsoniwal@gmail.com is not getting accepted

bilo

bilo (view profile)

Hi Yogesh
Thank you for useful source code but can you , but sir i have question about your code :
- how i can adapt your code in 4-QAM case.
(for my modulator and demodulator please refer to this source code Matlab :
n = 3e4; % Number of bits to process
M=4; % Size of signal constellation
hMod = modem.qammod(M); % Create a 4-QAM modulator
hMod.InputType = 'Bit'; % Accept bits as inputs
hMod.SymbolOrder = 'Gray'; % Accept bits as inputs
hDemod = modem.qamdemod(hMod); % Create a 4-QAM based on the modulator
% Modulate data :
x = randi([0 1],n,1); % Random binary data stream
tx = modulate(hMod,x);
% at receiver side :
rx_demod = demodulate(hDemod,tx);

Yogesh K Soniwal

Hi Joy

Can you send me your code for QPSK.

Thanks
Yogesh

joy lobo

Hi Yogesh,
Following what u have done for bpsk,i have written the code for qpsk ...but the results are not as per expected...i have two questions:a)Can we do the decoding for the two bits in qpsk independently of each other,exactly identical to bpsk?That is the alpha beta calculations will be the same but only in the calculation of gamma,there will be two aprioris because the two bits are independent...?Or will the two bits interfere with each other?According to me,they wont because they lie on separate axes
b)After LLR computation,how will the decision be taken i.e.will the bit error rate be given by ber(k,iter)=sum(abs(decoded_bits1-SystematicBits1)+abs(decoded_bits2-SystematicBits2)) where SystematicBits indicate two different bit streams?
I would really appreciate some help as I am not getting the expected results...or if u have the code for this ,will u be so kind as to share it?
Thanks
J Lobo

Yogesh K Soniwal

Hi Ana

Please ping me on yogeshsoniwal@gmail.com. I'll send you the code.

Thanks
Yogesh

Ana Oliveira

Hi Yogesh,

Could you please share a code for RSC with rate 1/2?

Thanks
Ana

Yogesh K Soniwal

Hi Ana

Yes, the RSC has rate 1/3. As there is one information bit and the codeword is of length 3 (X, P0 and P1).

Thanks
Yogesh

Ana Oliveira

Hi,

Could you please tell me if the RSC used has rate 1/3?

Thanks
Ana

Yogesh K Soniwal

Hi Joydeep

For state transitions please refer to

http://home.iitk.ac.in/~ysoniwal/Term_Paper_Reports/EE624.pdf

For QPSK part read comments.

Thanks
Yogesh

Hi Yogesh,
Can you let me know how you got to know about how the states are occuring?i.e.how does transition occur between the states?Also,how will it change in case of Qpsk?Thanks in advance

Yogesh K Soniwal

Hi popeye,

If you want to write the code for QPSK modulation, you'll have to change it starting from information bit generation. As you have to send two bit streams.

Then you'll have to decode the modulated bits using BCJR decoder. The formula for BER will also change.

Please refer to

http://in.mathworks.com/matlabcentral/fileexchange/39847-qpsk-performance-comparison-for-wireline-and-wireless-channel/content/qpsk.m

Thanks
Yogesh

Yogesh K Soniwal

Dear Keyvan,

The alpha and beta values are not wrong. If you read the comment of these functions, it says." Each column is for states 00,10,01 and 11 RESPECTIVELY".

They are NOT in 00, 01, 10 and 11 order.

Thanks
Yogesh

popeye

popeye (view profile)

Hi Yogesh,

Your code is clear for me, but I have questions as follows:
1. I want to use a higher order modulation like QPSK or 16QAM. So, in the receiver, the received signal should be passed through demapper block first. Then, we get the values of LLR_demapper (soft demodulation), which becomes the input for the turbo decoder. My point here is, at the moment, the input of turbo decoder is not the original received signal, some parameters in your code should be changed right ? Like, channel reliability, etc. How we can do it ?

2. Just a comment. I do agree with the guy who ask you about using 1/sqrt(2*1/3*SNR) instead of 1/sqrt(2*SNR) as in your code.

Hope to receive your reply soon,
Cheers

Keyvan Shahin

Hi Dear Yogesh,
I am trying to generalize your code for a 16 state code, but I have a problem with your alpha and beta functions, I think they are wrong, but the result is right, and I'm confused a little. I would appreciate if you would help me with this:
first as I look at the trellis and the gamma(1:4, 1:2) and I think alpha and beta should be like this:
ALPHA(1,i)=((GAMMA(1,j)*ALPHA(1,i-1))+(GAMMA(3,j)*ALPHA(3,i-1)));
ALPHA(2,i)=((GAMMA(3,j+1)*ALPHA(3,i-1))+(GAMMA(1,j+1)*ALPHA(1,i-1)));
ALPHA(3,i)=((GAMMA(2,j)*ALPHA(2,i-1))+(GAMMA(4,j)*ALPHA(4,i-1)));
ALPHA(4,i)=((GAMMA(4,j+1)*ALPHA(4,i-1))+(GAMMA(2,j+1)*ALPHA(2,i-1)));

BETA(1,i)=(GAMMA(1,j)*BETA(1,i+1))+(GAMMA(1,j+1)*BETA(2,i+1));
BETA(2,i)=(GAMMA(2,j)*BETA(3,i+1))+(GAMMA(2,j+1)*BETA(4,i+1));
BETA(3,i)=(GAMMA(3,j+1)*BETA(2,i+1))+(GAMMA(3,j)*BETA(1,i+1));
BETA(4,i)=(GAMMA(4,j+1)*BETA(4,i+1))+(GAMMA(4,j)*BETA(3,i+1));

if you could help what am I doing wrong.
ty very much. and ty for your simple and well written code.

Yogesh K Soniwal

C0 is same as P0, and C1 is same as P1. Maybe the notation is a bit confusing.

Gamma

Gamma (view profile)

thanks a lot..
one small quastion,,in your code of encoder u r calculating in loop C0 and C1 and with this C0 and C1 you are calculating Po ans P1..its clear..but at which stage of Encoder diagram you r calculating co and c1?this is not so clear for me--i mean after feedback value and input or where ?
can u plz clear it..i will be thankful t u.

Gamma

Gamma (view profile)

thanks Yogesh..i habe read this paper..its good..but can u tell me from which BOOK you have used this formula...i mean Reference of Book or any paper..
and how u demodelate your singal,because R0,R1 R2 are demodulated...'?
thanks

Yogesh K Soniwal

Hi Muhammad

Please refer to

http://home.iitk.ac.in/~ysoniwal/Term_Paper_Reports/EE624.pdf

for formulae of alpha, beta and gamma

Kondakov

Gamma

Gamma (view profile)

Hi,Yogesh

i have seen ur code and also paper,i hava quastion how u demodelate your singal,because R0,R1 R2 are demodulated but which formula are u using?

and the formula for calculating gamma?where did u got this i mean can u share any reference file.thanks in advance.

Sanchis

Hi Yogesh,

your code is very well!! But there is a thing that I don't understand and it is: I don't understand as you encode P1 and P0. I have readed the description in page 2 and 3 of your paper, but I don't understand, Could you explain me it? And as you implements it in the code?

Thanks you.

Yogesh K Soniwal

Hi Long
I have not checked if there is any difference in the performance if we use extrinsic information.
If you want to use extrinsic information, just substract the intrinsic term given on page 4 of
http://home.iitk.ac.in/~ysoniwal/Term_Paper_Reports/EE624.pdf
from aposteriori information.

popeye

popeye (view profile)

Hi Yogesh,

As from your code, the information you exchanged between two decoders is the a-posteriori information not extrinsic information as in theory. Is there any difference in the performance ? If I want to use extrinsic information in this case, how I can ? Thanks.

Yogesh K Soniwal

Hi Tongyang
In BCJR decoder we exclude the intrinsic information and pass the aposteriori probability from one decoder to another for subsequent detection

tongyang

from your PDF report, you mentioned that only extrinsic information is exchanged between two BCJR decoders. However, in your MATLAB code, I think the exchanged information is the a-posteriori information. Is it correct? Thanks.

Yogesh K Soniwal

yes

mary

mary (view profile)

hi.. is the used interleaver a random permutation interleaver?
 

Filip

Filip (view profile)

Yogesh, you should divide the SNR by 3 because the SNR is defined with respect to the energy per information bit (Eb), and not per coded bit (Es). This code has a rate of 1/3, right? Therefore, you need to consider the code rate when you corrupt the signal by noise.
Eb/No=(1/rate)*Es/No = (1/rate)*(mu^2)/(2*sigma^2)

Yogesh K Soniwal

Hi Filip
I don't think there is any problem in scaling. Why would you divide the SNR in all 3 bits?

Filip

Filip (view profile)

One little correction ,should be 2*1/3*SNR, I forgot the factor 2.

Filip

Filip (view profile)

Hey Yogesh. Are you sure the SNR scaling is correct in the turbo.m file? You assume a certain SNR, but you apply the same value to R0, R1 and R2, which is incorrect because you have not considered the code rate. The correct thing would be the following: instead

R0=sqrt(SNR(k))*mod_code_bit0+randn(1,N);

you should have written

R0=sqrt(1/3*SNR(k))*mod_code_bit0+randn(1,N);

because your code rate is 1/3.
By doing as you did the corruption is very less and your output BER is smaller.

devina etwara

Hi Yogesh.. i have an something to ask. actually whenever i'm increasing the snr gap, that is i'm changing it to 0.2 interval.. i am getting peaks .. like the graphs is shooting up and then coming down.. i wanted to know that is normal behaviour of turbo codes... i am getting little confused and even getting stressed as i am using your code as my base start for my dissertation .. please do lemme know about it.. please i am hope to hear from you soon

wang jack

mary

mary (view profile)

hi yogesh,
let's suppose that i have value "A"
I want to multiply the encoded data by it and than add noise then dividing the result by the same value then decode the resulting data:
suppose my data is X , and nose is N;
I want to do the following

s=X.*A
then add noise ss=s+N
then the data that will be decoded=ss./A

can you do that to your code??

Yogesh K Soniwal

Hi Jang,
Please refer to page No. 5 for alpha and page No. 9 for (j+2) in this link
http://home.iitk.ac.in/~ysoniwal/Term_Paper_Reports/EE624.pdf

jang

jang (view profile)

I do not know how the alpha is defined.
 Also, j +2, why are you used?

Yogesh K Soniwal

Sravya,
Download all the codes in one directory then run turbo.m

sravya

sravya (view profile)

Error in turbo (line 43)
dlg = ProgressDialog();
 i got this error when i simulated it please help me in this.. thanq...

ANAND

ANAND (view profile)

hello sir...
am doing project in increasing energy efficiency using turbo code.... i calculated Eb value for BPSK modulation... have to substitute the Eb value in turbo code.... how can i do it....
plz give me your ans to my mail id:
edalanand@gmail.com

Yogesh K Soniwal

The interleaver used in this code is random (line no. 4 of turbo.m) .. replace your designed interleaver with this one.

mustafa

HELLO SIR
your work is really perfect and i am concerned with the interleaver how can i replace the existing interleaver by my designed interleaver?

vahid

vahid (view profile)

hi tank u for ur code.the decoder depends on the snr but in reallity we dont know the snr how can we implement this code ?

triet ho

why only has 3rd iteration? i saw picture has 4th iteration? can you update iteration higher? tks so much. can you send your updated code to my email: hobaominhtriet@gmail.com. tks you.

Yogesh K Soniwal

You can refer to code provided on this link for 16-QAM
http://www.dsplog.com/2007/12/09/symbol-error-rate-for-16-qam/

DUJIN KWON

If I want to modify your program by using 16qam modulation instead of BPSK can you help me with that?

Yogesh K Soniwal

no..performance for QPSK and BPSK will be different

mary

mary (view profile)

will the performance be better when using QPSK modulation?? or it will be the same as when using BPSK?

mary

mary (view profile)

Do you have a matlab code of it ? Can you do it for me please?

Yogesh K Soniwal

You have to transmit 2 bits for each symbol. And decode each of them individually. Refer to the QPSK simulation code.

mary

mary (view profile)

If I want to modify your program by using QPSK modulation instead of BPSK can you help me with that?

Yogesh K Soniwal

Yes, the modulation used is BPSK.

mary

mary (view profile)

another question i have >> the modulating you are using is BPSK right???

mary

mary (view profile)

mary

mary (view profile)

i mean can we make the first RSC encoder of rate 2/3 ?? so according to this the second encoder will also be of rate 2/3

Yogesh K Soniwal

no..we are using the same bits permuted for the second RSC encoder, so we can't make this code rate 2/3.

mary

mary (view profile)

So it means that to make it of rate 2/3 we should use two bits as an input to RSC encoders right? Is it possible with BCJR decoding?

Yogesh K Soniwal

There are two encoders. Information bits are coded using convolution code for the first encoder and their permutation is coded using convolution code for the second encoder, but only one bit is used for second encoder. So RSC encoder is rate 1/3.

mary

mary (view profile)

okay and what about the bit rate of the RSC encoders??

mary

mary (view profile)

okay thank you

Yogesh K Soniwal

Hi mary,
this is rate 1/3 code..

mary

mary (view profile)

what is the bit rate of this encoder please??

saikiran

Hi, In the code when we increase block length the performance of the code should be increased in ber wise. But it is not the case happening?

mary

mary (view profile)

or it is of 8 states?

mary

mary (view profile)

okay it ran thank you

well this code is of 4 states trellis could you make it of 8 states ??

Yogesh K Soniwal

You have not downloaded 'parity_bit' function which is used by turbo.m . That's why this error is coming. Download all the other functions (alpha_1, beta_1,gamma_1, parity_bit, lappr) and then run turbo.m

mary

mary (view profile)

hello
 when i ran it using matlab 2012 an error occured
"Undefined function 'parity_bit' for input arguments of type
'double'." what do i do?

Updates

1.5

Adding updated location of report

1.4

Submitted as a toolbox

1.3

Fixed Error in UI

1.2

Encoding not done iteratively, used convolution for encoding

1.1

Iterations increased for better performance

MATLAB Release
MATLAB 8.1 (R2013a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video