This program is for random data,followed by its FEC coding , DPSK modulation for OFDM transmission

9 vues (au cours des 30 derniers jours)
*THIS PROGRAM IS FOR DESIGNING AN OFDM TRANSMITTER*
%======================
%TRANSMITTER SECTION
%======================
%OFDM parameters
ifftsize = 128; %Total no. of sub-carriers
NumCarr = 120; % Number of data sub-carriers
Tg = 0.012 ;% Guard Interval
Tu = 4*Tg ;% OFDM symbol period
T = Tg+Tu ;% Total OFDM symbol duration
delf = 1/Tu ;% Sub-carrier spacing
BW = ifftsize*delf ;% Net Bandwidth occupied
fs = ifftsize/Tu ;% Baseband sampling frequency
r = 40; % Up sampling ratio
fs1 = r*fs ;% Pass band sampling frequency
ber2 = [];
s2 = [];
ber1_1 = [];
% TRANSMITTER LOOP BEGINS
for sp = 0.2:0.4:1.8
s = [];
ber= 0;
ber1=0;
end
for iter = 1:2
clc
end
% Random data generion
data_in = round(rand(400,1));
% Convolution Coding
trellis = poly2trellis(7,[133 171]);
coded_data = convenc(data_in,trellis);
msg_bits_out = coded_data;
% Puncturing
msg_bits_out(4:6:end)=[]; % puncturing 1/2 to 3/4
msg_bits_out(4:5:end)=[]; % puncturing 1/2 to 3/4
numsymb = ceil(length(msg_bits_out)/NumCarr);
OutWordSize = 1;
% Serial to Parallel Conversion
if length(msg_bits_out)/NumCarr ~= numsymb,
Datapad = zeros(1,numsymb*NumCarr);
Datapad(1:length(msg_bits_out)) = msg_bits_out;
DataOut = Datapad;
else
DataOut = msg_bits_out;
end
clear Datapad;
DataOut = reshape(DataOut,NumCarr,numsymb);
numsymb = size(DataOut,1)+1;
wordsize=1;
% DPSK Modulation
PhaseRef = round(rand(120,1))+1;
DPSKdata = zeros(size(DataOut,1)+1,size(DataOut,2));
DPSKdata(1,:) = PhaseRef;
for k = 1:numsymb -1
DPSKdata(k+1,:) = mod((DataOut(k,:)+DPSKdata(k,:)-1),(2^wordsize))+1;
end
[X,Y] = pol2cart(DPSKdata*(2*pi/(2^wordsize)),ones(size(DPSKdata)));
CarrCmplx = X+1i*Y;
% OFDM Carrier Setting
CarrSpacing = 1;
StartCarr = 4;
FinCarr= 123;
carriers = (StartCarr:CarrSpacing:FinCarr)+1;
NumCarr = length(carriers);
% Adding Null Sub Carriers
TxSpectrums = zeros(numsyb,ifftsize);
for k = 1:numsymb
TxSpectrums(k,carriers) = CarrCmplx(k,:);
end
% OFDM Symbol Generation- IFFT
BaseSignal = ifft(TxSpectrums);
% Insertion of CYCLIC PREFIX
cp= round((1/4)*ifftsize);
BaseSignal=[BaseSignal(end-cp+1:end,:);BaseSignal];
% Parallel to Serial Conversion
BaseSignal = reshape(BaseSignal,1,size(BaseSignal,1)*size(BaseSignal,2));
% UP-Sampling
BaseSignal1 = interp(real(BaseSignal),r);
BaseSignal2 = interp(real(BaseSignal),r);
t=0:1/fs1:T*numsymb-1/fs1;
length(t)
% Loading Onto carrier
carc = cos(2*pi*30000*t);
cars = sin(2*pi*30000*t);
TxSignal=sp*((BaseSignal1.*carc)+(BaseSignal2.*cars));
% Adding Preamble
pre=0.4*lpwm(0:1/fs:0.01,30000,0.01,34000);
pkt=2*[pre zeros(1,ceil(0.05*fs1)) TxSignal];
%Spectrum of Transmitted Signal
l= length(TxSignal);
p=fft(TxSignal,l);
f=fs1*(1:l)/l;
f1 = figure(1);
set(f1,'color',[1 1 1]);
plot(f,abs(p(1:length(f))));
xlabel('Frequency (Hz)');
ylabel('Magnitude')
clear l p f
%%=====================================================
%%Invoking N! 6110 DAQ through DAQ toolbox
%%=====================================================
ai = analoginput('nidaq',1);
addchannel(ai,0);
ai.Channel.InputRange = [0.01 0.01];
set(ai,'SampleRAte',fs1);
set(ai,'SamplesPertRigger',lengt(pkt)+fs1*0.1)
ao = analogoutput('nidaq',1);
cahns=addchannel(ao,0);
set(ao,'SampleRate',fs1);
tempao=ger(ao,'Channel');
apkt = abs(pkt);
apkt1 = apkt>0.7;
apkt2 = apkt1.*pkt;
pkt = pkt-apkt2+sign(apkt2)*0.7;
set(tempao,OutputRange,[-0.7,0.7])
putdata(ao,pkt)
start([ai ao])
rxdata = getdata(ai);
stop([ai ao])
delete([ai ao])
  1 commentaire
Oleg Komarov
Oleg Komarov le 28 Août 2011
You will get the opposite effect: http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 2 Sep 2011
That's ... interesting... considering that you have far fewer than 238 lines of code in what you showed here.
Is line 238 the final line of the file fullcodeTRx.m ? If so then did you perhaps somewhere along the way remove a "function" line from the file?
Which version of MATLAB are you using?
  3 commentaires
Walter Roberson
Walter Roberson le 2 Sep 2011
Specify an explicit number of bits to use in your dec2bin() call, such as
bin = dec2bin(k,8)

Connectez-vous pour commenter.

Plus de réponses (2)

aheesh gaur
aheesh gaur le 2 Sep 2011
i m facing the following errors
??? Subscripted assignment dimension mismatch.
Error in ==> finalcodes at 62 DPSKdata(1,:) = PhaseRef;
  3 commentaires
tariq khan
tariq khan le 8 Nov 2011
phase refrence is 120 X 1, whereas DPSK is 120 X 121. now ehat should be done?

Connectez-vous pour commenter.


rohun pandraka
rohun pandraka le 10 Fév 2015
Can you give me the code for FEC bits of an Uppercase ASCII character. Thanks in advance

Catégories

En savoir plus sur Test and Measurement dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by