Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Understanding the Pilot isertion in ofdm matlab Code

Status
Not open for further replies.

kamranali406

Newbie level 5
Joined
Jul 15, 2012
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,342
some one please help me to understand the pilot insertion potion in this code

{
Code:
% Pilot insertion

lendata=length(y);
pilt=3+3j;
nofpits=4;

k=1;

for i=(1:13:52)
    
    pilt_data1(i)=pilt;

    for j=(i+1:i+12);
        pilt_data1(j)=y(k);
        k=k+1;
    end
end

pilt_data1=pilt_data1';   % size of pilt_data =52
pilt_data(1:52)=pilt_data1(1:52);    % upsizing to 64
pilt_data(13:64)=pilt_data1(1:52);   % upsizing to 64

for i=1:52
    
    pilt_data(i+6)=pilt_data1(i);
    
end
}





complete Code is This,,,,



Code:
% OFDM Code
% Author: Ihsan Ullah, 
%         Ms-55 Electrical,
%         College of EME, 
%         NUST Pakistan
% No.of Carriers: 64
% coding used: Convolutional coding
% Single frame size: 96 bits
% Total no. of Frames: 100
% Modulation: 16-QAM
% No. of Pilots: 4
% Cylic Extension: 25%(16)

close all
clear all
clc


%%
% Generating and coding data
t_data=randint(9600,1)';
x=1;
si=1; %for BER rows
%%
for d=1:100;
data=t_data(x:x+95);
x=x+96;
k=3;
n=6;
s1=size(data,2);  % Size of input matrix
j=s1/k;

%%
% Convolutionally encoding data 
constlen=7;
codegen = [171 133];    % Polynomial
trellis = poly2trellis(constlen, codegen);
codedata = convenc(data, trellis);



%%
%Interleaving coded data

s2=size(codedata,2);
j=s2/4;
matrix=reshape(codedata,j,4);

intlvddata = matintrlv(matrix',2,2)'; % Interleave.
intlvddata=intlvddata';


%%
% Binary to decimal conversion

dec=bi2de(intlvddata','left-msb');


%%
%16-QAM Modulation

M=16;
y = qammod(dec,M);
% scatterplot(y);


%%
% Pilot insertion

lendata=length(y);
pilt=3+3j;
nofpits=4;

k=1;

for i=(1:13:52)
    
    pilt_data1(i)=pilt;

    for j=(i+1:i+12);
        pilt_data1(j)=y(k);
        k=k+1;
    end
end

pilt_data1=pilt_data1';   % size of pilt_data =52
pilt_data(1:52)=pilt_data1(1:52);    % upsizing to 64
pilt_data(13:64)=pilt_data1(1:52);   % upsizing to 64

for i=1:52
    
    pilt_data(i+6)=pilt_data1(i);
    
end


%%
% IFFT

ifft_sig=ifft(pilt_data',64);


%%
% Adding Cyclic Extension

cext_data=zeros(80,1);
cext_data(1:16)=ifft_sig(49:64);
for i=1:64
    
    cext_data(i+16)=ifft_sig(i);
    
end


%%
% Channel

 % SNR

 o=1;
for snr=0:2:50

ofdm_sig=awgn(cext_data,snr,'measured'); % Adding white Gaussian Noise
% figure;
% index=1:80;
% plot(index,cext_data,'b',index,ofdm_sig,'r'); %plot both signals
% legend('Original Signal to be Transmitted','Signal with AWGN');


%%
%                   RECEIVER
%%
%Removing Cyclic Extension

for i=1:64
    
    rxed_sig(i)=ofdm_sig(i+16);
    
end


%%
% FFT

ff_sig=fft(rxed_sig,64);

%%
% Pilot Synch%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


for i=1:52
    
    synched_sig1(i)=ff_sig(i+6);
    
end

k=1;

for i=(1:13:52)
        
    for j=(i+1:i+12);
        synched_sig(k)=synched_sig1(j);
        k=k+1;
    end
end

% scatterplot(synched_sig)


%%
% Demodulation
dem_data= qamdemod(synched_sig,16);


%% 
% Decimal to binary conversion

bin=de2bi(dem_data','left-msb');
bin=bin';


%%
% De-Interleaving


deintlvddata = matdeintrlv(bin,2,2); % De-Interleave
deintlvddata=deintlvddata';
deintlvddata=deintlvddata(:)';




%%
%Decoding data
n=6;
k=3;
decodedata =vitdec(deintlvddata,trellis,5,'trunc','hard');  % decoding datausing veterbi decoder
rxed_data=decodedata;

%%
% Calculating BER
rxed_data=rxed_data(:)';
errors=0;


c=xor(data,rxed_data);
errors=nnz(c);

% for i=1:length(data)
%     
%        
%     if rxed_data(i)~=data(i);
%         errors=errors+1;     
%      
%     end
% end


BER(si,o)=errors/length(data);
o=o+1;

 end % SNR loop ends here
 si=si+1;
end % main data loop

%%
% Time averaging for optimum results

for col=1:25;        %%%change if SNR loop Changed
    ber(1,col)=0;  
for row=1:100;
  
    
        ber(1,col)=ber(1,col)+BER(row,col);
    end
end
ber=ber./100; 

%%
figure
i=0:2:48;
semilogy(i,ber);
title('BER vs SNR');
ylabel('BER');
xlabel('SNR (dB)');
grid on

please do reply
 

Re: Somone Please help me in Understanding the Pilot isertion in ofdm matlab Code

Pilot is needed for syncronization purposes.
It means a transmittion of definite signal on definite frequencies so as to help a receiver to find them quickly.

The code

for i=(1:13:52)

pilt_data1(i)=pilt;

for j=(i+1:i+12);
pilt_data1(j)=y(k);
k=k+1;
end
end

inserts the definite sample pilt=3+3j; in positions 1, 14, 27, 40 betwwen samples y(k) of user data wich have to be transmitted
 
Re: Somone Please help me in Understanding the Pilot isertion in ofdm matlab Code

Pilot is needed for syncronization purposes.
It means a transmittion of definite signal on definite frequencies so as to help a receiver to find them quickly.

The code

for i=(1:13:52)

pilt_data1(i)=pilt;

for j=(i+1:i+12);
pilt_data1(j)=y(k);
k=k+1;
end
end

inserts the definite sample pilt=3+3j; in positions 1, 14, 27, 40 betwwen samples y(k) of user data wich have to be transmitted



Thanks Dear,,It was help Full,,,
but i had a question,,Why this Code has, i.e the piolot incertion code, incert the first and last 6 numbers as repeated ...

This code out put has usable data from 7 to 58,,,first and last 6 are repeated,,,My question is why this 1st and last 6 bits are repeated.is this also a part of pilot incertion.???
48 was sub carriers + 4 pilots,,,,where the remaining 12 bits came from ???
as it is supsizing of data of 64...

the portion of code is this..




pilt_data1=pilt_data1'; % size of pilt_data =52
pilt_data(1:52)=pilt_data1(1:52); % upsizing to 64
pilt_data(13:64)=pilt_data1(1:52); % upsizing to 64

for i=1:52

pilt_data(i+6)=pilt_data1(i);

end
 

Re: Somone Please help me in Understanding the Pilot isertion in ofdm matlab Code

The appended replica (12 samples) of a part of signal is a guard interval. Its a time margin between consecutive channel symbols for protection from multipath.

You asked nothing about it in your 1st post. Reread it. If you dont ask how could anyone know what you want to ask
 
Re: Somone Please help me in Understanding the Pilot isertion in ofdm matlab Code

You asked nothing about it in your 1st post. Reread it. If you dont ask how could anyone know what you want to ask

When i went through the code,,on ur suggested ground ,,I receive this hurdle,,,in the start when i was posting,i din have any idea about it,,,so i din asked,,

U have said these 12 bits of pilot are the guard band for protection from multi Path ,,,,,there is cyclic Prefix too,,after the ifft block,,in which the coder has putted 16 bits in the starting,,, and its too used for multipath,,then whats the differnce?
 

Re: Somone Please help me in Understanding the Pilot isertion in ofdm matlab Code

The time these extra samples take is called a guard interval, the samples are called cyclic prefix. They take a part of data vector and repeat it as a prefix because this provides a continuous spectrum.

Time margin between consecutive channel symbols is needed so as the delayed (due to multipath) versions of channel symbol would not alias the next symbol.
 
Re: Somone Please help me in Understanding the Pilot isertion in ofdm matlab Code

It means cyclic prefix and pilot insertion are inter related???
i still din get the idea u are talking about,,,please eleborate the insertion of pilot relative to cyclic prefix,,,Since in both the processes we put some know bits
 

Re: Somone Please help me in Understanding the Pilot isertion in ofdm matlab Code

No, cyclic prefix related to appending 6 replica samples in front of and behind 52 samples of user data+pilots, and related to guard interval
 
Re: Somone Please help me in Understanding the Pilot isertion in ofdm matlab Code

Now i m Clear,,dear :)

i was confused by this block,,,
% Adding Cyclic Extension

and what is this block basically is for,,,??

Or We can Say That,,,cyclic prefix is to avoid Inter symbol interference ,,in time domain,,and cyclic extension is for inter carrier interference ....
 

Re: Somone Please help me in Understanding the Pilot isertion in ofdm matlab Code

It was helpful in understanding. Now how to remove these pilots at receiver,
just do the inverse?
 

Re: Somone Please help me in Understanding the Pilot isertion in ofdm matlab Code

Hi Mityan,

for 64-QAM, what are the value I need to change at Pilot Insertion section. I have tried several value, but it is not working.
 

Re: Somone Please help me in Understanding the Pilot isertion in ofdm matlab Code

for 64-QAM, what are the value I need to change at Pilot Insertion section. I have tried several value, but it is not working.
Hello.
I have probably not run that code on my PC, that was long ago and I don't remember.
64QAM differs from 16QAM only in number of magnitude/phase manipulation levels, so nothing may be changed for pilot section I guess.
And I can't imagine what is not working in your script.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top