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

*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 件のコメント

aheesh gaur
aheesh gaur 2011 年 9 月 2 日
i m using 7.9.0(R2009b)
I did neither of the two, there are only 122 line in the code and i have put comments on each part.
And no function was removed ,i wish to add instead of taking random numbers, i wish to take a string from user convert it into decimal then to binary and apply the same.
%this program converts the string value from user to ascII to binary value
clc;
k=0;
bin=0;
l=0;
u=input('enter the string for conversion==> ','s');
k=double(u);
%dec_nr=s;
%l=dec_nr;
display(k);
bin=dec2bin(k);
display(bin);
data_in = bin;
aheesh gaur
aheesh gaur 2011 年 9 月 2 日
thank you..:)
Specify an explicit number of bits to use in your dec2bin() call, such as
bin = dec2bin(k,8)

サインインしてコメントする。

その他の回答 (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 件のコメント

PhaseRef is going to be exactly 120 elements long (hard-coded, probably should be NumCarr instead of the literal 120), but DPSKdata(1,:) is going to be of length ceil(length(msg_bits_out)/NumCarr) (the value that used to be assigned to numsymb, but numsymb was assigned a different value right after it was used to size the DPSKdata array.)
Put a breakpoint at that line, and look at size(PhaseRef) and size(DPSKdata)
tariq khan
tariq khan 2011 年 11 月 8 日
phase refrence is 120 X 1, whereas DPSK is 120 X 121. now ehat should be done?
tariq khan
tariq khan 2011 年 11 月 8 日
sorry DPSK is 121 X 121.

サインインしてコメントする。

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

カテゴリ

ヘルプ センター および File Exchange で Uplink Channels についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by