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

10 次查看(过去 30 天)
*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 个评论
Oleg Komarov
Oleg Komarov 2011-8-28
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

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2011-9-2
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 个评论

请先登录,再进行评论。

更多回答(2 个)

aheesh gaur
aheesh gaur 2011-9-2
i m facing the following errors
??? Subscripted assignment dimension mismatch.
Error in ==> finalcodes at 62 DPSKdata(1,:) = PhaseRef;
  3 个评论

请先登录,再进行评论。


rohun pandraka
rohun pandraka 2015-2-10
Can you give me the code for FEC bits of an Uppercase ASCII character. Thanks in advance

类别

Help CenterFile Exchange 中查找有关 Test and Measurement 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by