Các thông số mô phỏng

Một phần của tài liệu tổng quan về hệ thống mimo-ofdm mô hình stbc-ofdm (Trang 72 - 95)

5.2.1. Hệ thống OFDM.

Số khung mô phỏng : 110

Số sóng mang con : 16

Điều chế : 4QAM; tuỳ chọn

Chiều dài FFT : 512

Kích thước CP : 128

Băng thông hệ thống : 5MHz

SNR : 0; 3; 6; 9; 12; 15

5.2.2. Hệ thống MIMO-OFDM.

Mô hình mô phỏng: Space time block code OFDM; 2 anten phát và 2 anten nhận.

Số khung mô phỏng : 110

Số sóng mang con : 16

Điều chế : 4QAM; tuỳ chọn

Chiều dài FFT : 512

Số kí tự trên một khung : 6

 Kích thước CP : 128

Băng thông hệ thống : 5MHz

SNR : 0; 3; 6; 9; 12; 15

5.2.3. Thông số kênh truyền.

Đáp ứng tần số kênh (hij): được tạo ra ngẫu nhiên

Nhiễu cộng ngẫu nhiên.

Tần số Doppler fd (Hz) : 0; 10; 20; 30 ; tuỳ chọn

5.3. Lưu đồ và sơ đồ thuật toán của chương trình mô phỏng.5.3.1. Truyền tín hiệu. 5.3.1. Truyền tín hiệu. 5.3.2. Kênh truyền. Tín hiệu gốc Mã hoá Trellis convolution Ghép xen Điều chế

Mã hoá khối không gian-thời gian.

Thực hiện IFFT, biến đồi tín hiệu từ miền tần số sang miền thời gian.

Tín hiệu đã điều chế được truyền đi.

Tín hiệu từ anten phát Tạo tác động của hiện tượng Doppler và trải trễ

Tạo tác động của nhiễu cộng ngẫu nhiên Anten nhận

5.3.3. Nhận tín hiệu. Anten nhận Anten nhận Thực hiện FFT Kết hợp tín hiệu Giải điều chế Giải ghép xen Giải mã trellis convolution Tính BER của hệ thống OFDM

và STBC-MIMO-OFDM Vẽ giản đồ BER theo SNR của

cả hai hệ thống. (adsbygoogle = window.adsbygoogle || []).push({});

So sánh và đánh giá chất lượng các hệ thống

5.3.4. Thuật toán tính BER.k<=SNR(end) k<=SNR(end) end False True true

False s’(i)= =s(i)

leng=length(s);berr=0;i=0;

i <= leng

Tín hiệu thu được sau khi đã xử lí s’(i)

Tín hiệu gốc ban đầu s(i)

i=i+1 berr=berr+1; BER(k)=berr/leng; False k = SNR(begin) k=k+step; begin

5.4. Kết quả mô phỏng và đánh giá.

Giao diện chính của chương trình

a) Trường hợp kênh truyền chưa có tác động của trải trễ và rayleigh fading

b) Trường hợp có tác động của trải trễ và Fading Rayleigh

Trường hợp :

fd =10Hz trms = 1us

fd=20Hz trms = 1us

Trường hợp:

fd=30Hz trms = 1us

 Truyền tín hiệu ở cùng BER thì kỹ thuật MIMO-OFDM sử dụng SNR thấp hơn OFDM. Từ đó có thể chứng minh cho nhận định, sử dụng kỹ thuật MIMO-OFDM chúng ta dùng công suất phát thấp hơn mà chất lượng lại cao hơn.

 Khi nhiễu môi trường tăng, thì yêu cầu SNR tăng, hay phải tăng công suất phát.

 SNR càng cao thì BER càng nhỏ. Như vậy khi phát với công suất lớn thì chất lưọng tín hiệu tốt nhưng yêu cầu tiêu thụ năng lượng tăng nên giá thành tăng. Vì vậy càng ngày, người ta càng hướng đến sử dụng các công nghệ trong thông tin di động mà có thể truyền tín hiệu đáng tin cậy với mức công suất phát nhỏ.

5.5. Kết luận chương.

Phần mô phỏng còn hạn chế là chưa thực hiện ước lượng kênh, mà xem như phần ước lượng là hoàn hảo. Tuy nhiên với mục đích đánh giá chất lượng hệ thống thì mô hình trên là chấp nhận được vì ta cũng xem phần ước lượng kênh của hệ thống OFDM là hoàn hảo. Hệ thống sử dụng kỹ thuật OFDM cũng là một trong những hệ thống chất lượng cao; đang và sẽ được áp dụng trong các thế hệ mạng di động mới như 3G và 4G.

Với kết quả nhận được, là trong hệ thống thông tin di động, kỹ thuật này cho BER nhỏ với SNR thấp. Nó còn tốt hơn cả kỹ thuật OFDM. Điều này chứng tỏ kỹ thuật này còn được nghiên cứu và áp dụng trong tương lai cho các thế hệ mạng di động sau này. Mà bước đầu, MIMO-OFDM đã được ứng dụng vào tiêu chuẩn 802.11n trong WIFI, nó đã tạo ra sự mở rộng băng thông và cải thiện chất lượng tín hiệu một cách đáng kể so với các tiêu chuẩn khác trước đây.

KẾT LUẬN VÀ HƯỚNG PHÁT TRIỂN ĐỀ TÀI.

Đề tài “ Kỹ thuật MIMO_OFDM” đã trình bày một cách tổng quan về công nghệ MIMO_OFDM. Thông qua hệ thống STBC_OFDM 2x2, cũng đã giới thiệu một cách chi tiết về công nghệ MIMO_OFDM đơn giản. Trong đề tài còn trình bày về kỹ thuật OFDM, MIMO, ước lượng kênh.

Hiện nay, công nghệ MIMO_OFDM đã được ứng dụng vào chuẩn IEEE 802.11n trong hệ thống WIFI và IEEE 802.16 trong hệ thống WIMAX. Mặc dù bước đầu còn trong giai đoạn ứng dụng thử nghiệm với qui mô nhỏ nhưng nó đã mang lại những bước tiến vượt bậc trong lĩnh vực thông tin di động, như sự mở rộng băng thông, nâng cao chất lượng tín hiệu trao đổi. Mạng WIFI sử dụng 802.11n đã trao đổi được các dữ liệu dung lượng lớn như âm thanh, hình ảnh mà các mạng WIFI trước đó không thực hiện được.

Đề tài đã giới thiệu công nghệ STBC_OFDM, công nghệ này cho sự cải thiện đáng kể về chất lượng tín hiệu. Phát triển đề tài này, có thể nghiên cứu thêm các hệ thống MIMO_OFDM với số anten phát và thu lớn hơn; như hệ thống 3x4, 4x4, 8x8,…Nhưng số anten tăng cũng nảy sinh vấn đề cần giải quyết đó là: sự phức tạp trong bộ thu tín hiệu, làm cho các phép tính có độ khó cao, thiết bị thì cồng kềnh, giá thành cao. Tuy nhiên gần đây, với các phát minh bộ xử lí tín hiệu số giá rẻ, các bộ xử lí đa năng, các thuật toán xử lí tín hiệu mới, điều này sẽ giúp thiết bị MIMO_OFDM gọn gàng hơn và sẽ được đưa vào áp dụng rộng rãi trong thực tế. Với những ưu điểm về mặt kỹ thuật và sự hỗ trợ của các phát minh mới, công nghệ MIMO_OFDM sẽ là một trong những công nghệ hàng đầu sẽ được áp dụng trong hệ thống thông tin di động thế hệ mới như NGN, 4G.

TÀI LIỆU THAM KHẢO.

[1] TS.Phan Hồng Phương, KS.Lâm Chi Thương, “Kỹ thuật phân tập anten trong cải thiện dung lượng hệ thống MIMO”.

[2] Phạm Hồng Liên, Đăng Ngọc Khoa, Trần Thanh Phương, “Matlab và ứng dụng trong Viễn Thông”, Nhà xuất bản Đại Học quốc gia thành phố Hồ Chí Minh-2006. [3] Ths Nguyễn Anh Tuấn, “Phương pháp mã hóa không gian thời gian trong các hệ thống MIMO và một số hướng nghiên cứu”, bài báo trình tại hội nghị khoa học lần thứ VI. (adsbygoogle = window.adsbygoogle || []).push({});

[4] ThS.Lê Văn Ninh, TS.Nguyễn Viết Kính, “Đồng bộ tần số trong miền tần số cho OFDM”, bài báo khoa học.

[5] Ths.Nguyễn Ngọc Tiến, “Một số vấn đề kỹ thuật trong hệ thống OFDM”, Tạp chí bưu chính Viễn Thông và Công nghệ thông tin, 29/09/2003.

[6] Brank Vucetic, Jinhong Yuan, John Wily& Son, “Space Time Coding”, 2003. [7] Lisa Meilhac, Alian Chiodini, Clement Boudesocque, Crislin Lele, Anil Gercekei, “MIMO-OFDM modem for WLAN”- Newlogic Technology S.A.R.L, 07- 2004 .

[8] John R.Barry, “Broadband MIMO OFDM wireless communications”, 2004

[9] Vahid Tarokh, Hamid Jafarkhani, and A. R. Calderbank. "Space–time block codes from orthogonal designs". IEEE Transactions on Information Theory : 744– 765, July 1999.

[10] Vahid Tarokh, A.Robert Calderbank, “Space-Time Block Coding for Wireless Communications”. IEEE journal on selected areas in communication, March 1999

PHỤ LỤC.

CHƯƠNG TRÌNH MATLAB THỰC HIỆN MÔ PHỎNG. 1) Chương trình chính

function varargout = MIMO_OFDM(varargin) % MIMO_OFDM M-file for MIMO_OFDM.fig gui_Singleton = 1;

gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ...

'gui_OpeningFcn', @MIMO_OFDM_OpeningFcn, ... 'gui_OutputFcn', @MIMO_OFDM_OutputFcn, ... 'gui_LayoutFcn', [] , ...

'gui_Callback', []); if nargin == 0 % LAUNCH GUI

fig = openfig(mfilename,'reuse'); % Use system color scheme for figure:

set(fig,'Color',get(0,'defaultUicontrolBackgroundColor'));

% Generate a structure of handles to pass to callbacks, and store it. handles = guihandles(fig); guidata(fig, handles); if nargout > 0 varargout{1} = fig; end elseif ischar(varargin{1}) try if (nargout) [varargout{1:nargout}] = feval(varargin{:}); else

feval(varargin{:}); % FEVAL switchyard end

catch

disp(lasterr); end

end

% End initialization code - DO NOT EDIT

% --- Executes just before MIMO_OFDM is made visible. % --- Executes on button press in start.

function varargout = start_Callback(hObject, eventdata, handles) Nfram1=str2double(get(handles.frames,'String'))

fft1=str2double(get(handles.fft_size,'String'))

Nsub1=str2double(get(handles.Nsubcarriers,'String')) Dopler_freq1=str2double(get(handles.fd,'String')) SNR1=eval(get(handles.snr,'String'))

M_qam1=str2double(get(handles.M,'String')); M1 = M_qam1(get(handles.M,'Value'),1) Delay1=str2double(get(handles.t_rms,'String')); t_rms1=Delay1(get(handles.t_rms,'Value'),1); %***************************************************************** ** %state=1:OFDM ; state=2:STBC_OFDM 2x2 state1=1; state2=2;

fd = Dopler_freq1;%fd1;%20; % Doppler frequency in Hz t_rms = 1;%t_rms1;%1; % Delay spread in mu s

subN = Nsub1;%16; % No. of sub-carriers in each sub-channel F_LA = 1; % Link Adaptation Resolusion, useless here.

Nframe = Nfram1;%110; % Total No. of frames to be simulated cdrt = 1/2; % Coding rate

M = M1; % M-QAM

misnr = SNR1(1); % minimum simulated SNR in dB stp = SNR1(2); % SNR simulation step (adsbygoogle = window.adsbygoogle || []).push({});

mxsnr = SNR1(end); % maximum simulated SNR in dB

chnums = 1000; % No. of channel realizations, should be larger than the total simulated symbols (frames * 6)

sampling_rate = 1.08; % over-sampling rate, 1.08 for wimax?, and 1.536 for 3gpp flg_offset = 0; % no Carrier-frequency offset

flg_csi_err = 0; % no Channel state information error N = fft1%512; % FFT size & total No. of sub-carriers cp_l = 128; % CP length

BW = 5e6; % system bandwidth, 5MHz Nsymbol = 6; % 6 symbols within each frame dirname1 = 'yynew1'; % where the result is stored dirname2 = 'yynew2'; % where the result is stored allow_load_oldres = 1; % allow to load previous result Root_path = '.'; % where the path starts

addpath('../comm_funcs');

DELAY=0; % no feedback delay

stbc = 1; % useful only for alamouti (MISO)

T_Symbol = (N+cp_l)/(BW*sampling_rate); % OFDM symbol duration

sys = {'SISO','MRC1x2','Alt2x1','EGC1x2','AS2x1','ALT2x2','AS2x2'}; % supported MIMO schemes

T_n=[1,2]; %Transmitter diversity branches [SIMO,MRC,MISO,EGC,MISO-AS] R_n=[1,2]; %Receiver diversity branches [SIMO,MRC,MISO,EGC,MISO-AS] T_div1=T_n(state1); %Specify transmitter diversity branches

R_div1=R_n(state1); %specify receiver diversity branches T_div2=T_n(state2);

R_div2=R_n(state2); [ch1,ch2] = channelgenerator2(t_rms,fd,sampling_rate,N,cp_l,BW,chnums + F_LA * Nsymbol + DELAY,T_div1*R_div1,T_div2*R_div2); %%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%% filename = ['f',num2str(fd),'_t',num2str(t_rms),'_N',num2str(subN),'_L',num2str(F_LA),... '_M',num2str(M),'F',num2str(round(10*cdrt)),'_E',num2str(flg_csi_err),... 'c',num2str(flg_offset),'D',num2str(DELAY),'.mat']; dirname1 = [Root_path,'/',dirname1]; filepath1 = [dirname1,'/',filename]; dirname2 = [Root_path,'/',dirname2]; filepath2 = [dirname2,'/',filename];

if allow_load_oldres && exist(filepath1,'file') && exist(filepath2,'file'), load(filepath1); load(filepath2); else %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % rdstate = 4831; snr_ix = 0; Num_grp=floor(N/subN); blk_err_c=nan(length(misnr:stp:mxsnr),floor(Nframe/F_LA),Num_grp); bit_err_u=nan(length(misnr:stp:mxsnr),floor(Nframe/F_LA),Num_grp); bit_tot_u=nan(length(misnr:stp:mxsnr),floor(Nframe/F_LA),Num_grp); bit_err_c=nan(length(misnr:stp:mxsnr),floor(Nframe/F_LA),Num_grp); bit_tot_c=nan(length(misnr:stp:mxsnr),floor(Nframe/F_LA),Num_grp); for snr=misnr:stp:mxsnr %%%%%%%%%%%%%%%%%%% snr_ix=snr_ix+1; frame_ix = 0; noisePowPerSubC = 1/10^(snr/10)/N; for la_ix=1:floor(Nframe/F_LA)

rnd = randint(1,1,chnums) + 1; % randmize channel index for different LA intervals, avoid high time-correlation

index = (rnd: rnd + F_LA * Nsymbol-1 ) + DELAY; h1 = ch1(:,index,:);

h2 = ch2(:,index,:);

H1 = func_add_csi_err(h1,N,flg_csi_err); % add CSI error H2 = func_add_csi_err(h2,N,flg_csi_err); % add CSI error

[H1_comb,H1_LA,ps1]=selectAntenna2(H1,N,subN,state1,T_div1); % tx antenna selection

[H2_comb,H2_LA,ps2]=selectAntenna2(H2,N,subN,state2,T_div2); % tx antenna selection

B=log2(M)*ones(floor(N/subN),1); % loaded bits per sub-carrier P1 = 1/N/T_div1*ones(floor(N/subN),1); % power per subCarrier P2 = 1/N/T_div2*ones(floor(N/subN),1); % power per subCarrier code_rate = cdrt*ones(floor(N/subN),1);

[T_mod1,T_mod2,T_sent,coded,intleav,fact1,fact2,real_len,raw_len,t] = ... T_mod_cod_intlv(N,subN,B,P1,P2,Nsymbol,code_rate,rdstate,T_div1,T_div2,ps1,p s2,state1,state2); % modulator & encoder & interleaver

tf(snr_ix,la_ix) = sum(B~=0)*F_LA;%length(find(B~=0))*F_LA; % should be N/subN * F_LA

tb_u(snr_ix,la_ix) = sum(B)*subN*Nsymbol*F_LA; tb_c(snr_ix,la_ix) = sum(raw_len)*F_LA;

if stbc == 1,

T_trans1=BT_alamouti(T_mod1,Nsymbol,state1); %doan chuong trinh thuc hien MIMO

T_trans2=BT_alamouti(T_mod2,Nsymbol,state2); end

for nf = 1:F_LA%F_PA % frame index within each PA window frame_ix = frame_ix + 1;

index3 = ((nf-1)*Nsymbol+1:nf*Nsymbol);

h2_1=h1(:,index3+DELAY,:); % only in the channel part, and combining part, no delay (adsbygoogle = window.adsbygoogle || []).push({});

h2_2=h2(:,index3+DELAY,:);

R_dfs1=BTR_ofdm(h2_1,N,cp_l,T_trans1,snr,T_div1,R_div1,Nsymbol,flg_offset,f d,BW,sampling_rate,noisePowPerSubC); % ofdm transiver

R_dfs2=BTR_ofdm(h2_2,N,cp_l,T_trans2,snr,T_div2,R_div2,Nsymbol,fl g_offset,fd,BW,sampling_rate,noisePowPerSubC); % ofdm transiver

H2_1 = H1_comb(:,index3+DELAY,:); % here, use H at the receiver, no delay H2_2 = H2_comb(:,index3+DELAY,:); if stbc == 1, R_comb1=BR_combiner(R_dfs1,H2_1,state1); R_comb2=BR_combiner(R_dfs2,H2_2,state2); end [blk_err_c(snr_ix,frame_ix,1:Num_grp),blk_tot_c(snr_ix,frame_ix,1:Num_grp),bit_ err_u(snr_ix,frame_ix,1:Num_grp),bit_tot_u(snr_ix,frame_ix,1:Num_grp),bit_err_c (snr_ix,frame_ix,1:Num_grp),bit_tot_c(snr_ix,frame_ix,1:Num_grp),wb_u1(snr_ix, frame_ix),wb_c1(snr_ix,frame_ix),tp_uu1(snr_ix,frame_ix),tp_cc1(snr_ix,frame_ix ),wf_u1(snr_ix,frame_ix),wf_c1(snr_ix,frame_ix)]... = R_mod_cod_intlv(N,subN,R_comb1,fact1,B,rdstate,code_rate,real_len,t,coded,T_s ent,intleav); % de-interleaver & de-coder & de-modulator

[blk_err_c(snr_ix,frame_ix,1:Num_grp),blk_tot_c(snr_ix,frame_ix,1:Num_grp),bit_ err_u(snr_ix,frame_ix,1:Num_grp),bit_tot_u(snr_ix,frame_ix,1:Num_grp),bit_err_c (snr_ix,frame_ix,1:Num_grp),bit_tot_c(snr_ix,frame_ix,1:Num_grp),wb_u2(snr_ix, frame_ix),wb_c2(snr_ix,frame_ix),tp_uu2(snr_ix,frame_ix),tp_cc2(snr_ix,frame_ix ),wf_u2(snr_ix,frame_ix),wf_c2(snr_ix,frame_ix)]... = R_mod_cod_intlv(N,subN,R_comb2,fact2,B,rdstate,code_rate,real_len,t,coded,T_s ent,intleav); % de-interleaver & de-coder & de-modulator

end end

disp(['SNR= ',num2str(snr),'dB finished']); end

%% calculate results % truong hop state1=1

ber_c1 = sum(wb_c1,2)./sum(tb_c,2)% avaible store ‘ber’ of OFDM % save results if ~exist(dirname1,'dir'), mkdir(dirname1); end; desp1 = [sys{state1},filename]; save(filepath1,'desp1','ber_c1','misnr','stp','mxsnr','t_rms','fd','state1','M','cdrt','subN') ;

%truong hop state2=2

ber_c2 = sum(wb_c2,2)./sum(tb_c,2)%avaible store ‘ber’ of MIMO_OFDM % save results if ~exist(dirname2,'dir'), mkdir(dirname2); end; desp2 = [sys{state2},filename]; save(filepath2,'desp2','ber_c2','misnr','stp','mxsnr','t_rms','fd','state2','M','cdrt','sub N'); end % plot results %**************figure; %***************************************************************** *** axes(handles.axes1) semilogy(misnr:stp:mxsnr,ber_c1,'-.r*',misnr:stp:mxsnr,ber_c2,':bs','linewidth',2); legend('OFDM 1x1','STBCOFDM 2x2'); xlabel('SNR [dB]'); ylabel('BER'); set(handles.axes1,'XminorTick','on') grid on

clear all;clc;

function MIMO_OFDM_OpeningFcn(hObject, eventdata, handles, varargin) handles.output = hObject;

% Update handles structure guidata(hObject, handles);

function varargout = MIMO_OFDM_OutputFcn(hObject, eventdata, handles) varargout{1} = handles.output;

function varargout = frames_Callback(hObject, eventdata, handles) % --- Executes during object creation, after setting all properties. function frames_CreateFcn(hObject, eventdata, handles)

% See ISPC and COMPUTER. if ispc

set(hObject,'BackgroundColor','white'); else

set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end

function varargout = fft_size_Callback(hObject, eventdata, handles) % hObject handle to fft_size (see GCBO)

% --- Executes during object creation, after setting all properties. function fft_size_CreateFcn(hObject, eventdata, handles)

% hObject handle to fft_size (see GCBO) % See ISPC and COMPUTER.

if ispc

set(hObject,'BackgroundColor','white'); else

set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end

function varargout = Nsubcarriers_Callback(hObject, eventdata, handles) % hObject handle to Nsubcarriers (see GCBO)

% Hints: get(hObject,'String') returns contents of Nsubcarriers as text

% str2double(get(hObject,'String')) returns contents of Nsubcarriers as a double % --- Executes during object creation, after setting all properties.

function Nsubcarriers_CreateFcn(hObject, eventdata, handles) % hObject handle to Nsubcarriers (see GCBO) (adsbygoogle = window.adsbygoogle || []).push({});

% eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER.

if ispc

set(hObject,'BackgroundColor','white'); else

set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end

function M_Callback(hObject, eventdata, handles)

% --- Executes during object creation, after setting all properties. function M_CreateFcn(hObject, eventdata, handles)

if ispc

set(hObject,'BackgroundColor','white'); else

set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end

function varargout = fd_Callback(hObject, eventdata, handles) function fd_CreateFcn(hObject, eventdata, handles)

if ispc

set(hObject,'BackgroundColor','white'); else

set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end

function varargout = t_rms_Callback(hObject, eventdata, handles) function t_rms_CreateFcn(hObject, eventdata, handles)

if ispc

set(hObject,'BackgroundColor','white'); else

set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end

function varargout = snr_Callback(hObject, eventdata, handles) function snr_CreateFcn(hObject, eventdata, handles)

if ispc

set(hObject,'BackgroundColor','white'); else

set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end

% --- Executes on selection change in M.

function popupmenu2_Callback(hObject, eventdata, handles) function popupmenu2_CreateFcn(hObject, eventdata, handles) if ispc

set(hObject,'BackgroundColor','white'); else

set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end

2) Interleaving,Coding and Mod received signal

function [T_mod1,T_mod2,T_sent,coded,intleav,fact1,fact2,real_len,raw_len,t] = ... T_mod_cod_intlv(N,subN,B,P1,P2,Nsymbol,code_rate,rdstate,T_div1,T_div2,ps1,p s2,state1,state2)

T_sent = cell(1,floor(N/subN)); coded = cell(1,floor(N/subN)); intleav = cell(1,floor(N/subN));T_mod1 = []; T_mod2 = [];

t = cell(1,floor(N/subN)); for k = 1:floor(N/subN)

lens = subN*B(k)*Nsymbol; (adsbygoogle = window.adsbygoogle || []).push({});

if code_rate(k) == 2/3&&mod(floor(lens*code_rate(k)),2)~=0

raw_len(k) = floor(lens*code_rate(k))-1;%lenh nay se rut gon chieu dai lens theo ti le k

else

raw_len(k) = floor(lens*code_rate(k)); end

raw_bits = randint(1,raw_len(k));

T_sent{k} = raw_bits;%dua mang "raw_bits" vao 1 vi tri "T_sent{k}"

[coded{k},t{k},real_len(k)] = N_encoder(code_rate(k),raw_bits,lens);%ma hoa raw_bit theo trellis k=1/2

if length(coded{k})==0 intleav{k} = []; mod1 = zeros(1,subN*Nsymbol); fact1(k) = 0; fact2(k) = 0; else intleav{k}=randintrlv(coded{k},rdstate); mod1 = qmodulator2(intleav{k},2^B(k));

fact1(k) = sqrt(P1(k)/pv(mod1));%P1 la nang luong tren mot song mang con; pv la tinh gia tri trung binh

fact2(k) = sqrt(P2(k)/pv(mod1)); end

tp = reshape(mod1,[],subN);

%sap xep lai ma tran mod1 thanh ma tran co subN cot mod2 = tp.';

mod3 = tp.';

mod2 = mod2 *fact1(k); mod3 = mod3 *fact2(k); T_mod1 = [T_mod1;mod2]; T_mod2 = [T_mod2;mod3]; End

3) Deinterleaving,decoding and demod received signal

function

[blk_err_c,blk_tot_c,bit_err_u,bit_tot_u,bit_err_c,bit_tot_c,bnum2_u,bnum2_c,tpb_ u,tpb_c,fnum_u,fnum_c] = ...

R_mod_cod_intlv(N,subN,R_comb,fact1,B,rdstate,code_rate,real_len,t,coded,T_ sent,intleav)

fnum_u = zeros(1,floor(N/subN)); fnum_c = zeros(1,floor(N/subN)); blk_err_c=zeros(1,floor(N/subN));

% if the block is in error, a '1' will be put in

% the place, if it is not in error '0' will used. blk_tot_c=zeros(1,floor(N/subN));% whether the block is loaded or not bit_err_u=zeros(1,floor(N/subN));

% stores the number of bits in error for uncoded

% configuration, for each block bit_tot_u=zeros(1,floor(N/subN));

% total number of uncoded bits loaded in each block

bit_err_c=zeros(1,floor(N/subN)); % stores the number of bits in error for coded % configuration, for each block

bit_tot_c=zeros(1,floor(N/subN)); % stores the total number of coded bits loaded in each block

for k = 1:floor(N/subN) % 1:512 % for each block tp = R_comb((k-1)*subN+1:k*subN,:).'; tp2 = tp(:).'; if fact1(k)~=0 r_dmd = qdemodulator(tp2/fact1(k),2^B(k)); dintlv=randdeintrlv(r_dmd,rdstate); %r_dcd = BR_decode2(code_rate(k),dintlv(1:real_len(k)),t(k)); r_dcd = BR_decode2(code_rate(k),dintlv(1:real_len(k)),t{k}); bnum2_u(k) = biterr(dintlv,coded{k}); % uncoded wrong bits bnum2_c(k) = biterr(r_dcd,T_sent{k}); % coded wrong bits blk_tot_c(k)=blk_tot_c(k)+1;

% increase the count for the loaded blocks

bit_tot_u(k)=bit_tot_u(k)+length(dintlv);% bit_tot_c(k)=bit_tot_c(k)+length(r_dcd);% else r_dmd = []; dintlv = []; bnum2_u(k) = 0; bnum2_c(k) = 0; end

tpb_u(k) = length(intleav{k}); % throughput for uncoded, if no error tpb_c(k) = length(T_sent{k}); % throughput for coded, if error if bnum2_u(k)>0 % with error (adsbygoogle = window.adsbygoogle || []).push({});

fnum_u(k) = fnum_u(k) +1; % fer + 1 tpb_u(k) = 0; % throughput set to 0 end

if bnum2_c(k)>0 % with error

fnum_c(k) = fnum_c(k) +1; % fer + 1 tpb_c(k) = 0; % throughput set to 0 end

end

% store data for each block

bit_err_u=bnum2_u;% total number of bits in error in each block for uncoded system

bit_err_c=bnum2_c;% total number of bits in error in each block for coded system %% yy's new part

bnum2_u = sum(bnum2_u); bnum2_c = sum(bnum2_c); tpb_u = sum(tpb_u); tpb_c = sum(tpb_c); fnum_u = sum(fnum_u); fnum_c = sum(fnum_c);

4) The multipath channel matrix generator

%Using rayleighchan function in MATLAB %chnums is the number of channel realizations %fd is the Doppler frequency

%divn is the number of diversity branches %t_rms is the delay spread in us

%The output is matrix ch, for channel impulse response %clear all;close all;

%clc;

%bug fixed for AWGN

function[ch1,ch2]=channelgenerator2(t_rms,fd,sampling_rate,N,cp_l,BW,chnums,d ivn1,divn2) if t_rms==0 && fd ==0, ch1 = ones(1,chnums,divn1); ch2 = ones(1,chnums,divn2); else Ch1=raych2(chnums*divn1,fd,t_rms,sampling_rate,N,cp_l,BW); Ch2=raych2(chnums*divn2,fd,t_rms,sampling_rate,N,cp_l,BW); for i=1:divn1 ch1(:,:,i)=Ch1(:,(i-1)*chnums+1:i*chnums); %save (sprintf('ch%d',i),'ch'); end for i=1:divn2 ch2(:,:,i)=Ch2(:,(i-1)*chnums+1:i*chnums); %save (sprintf('ch%d',i),'ch'); end end 5)SelectAnten2 function [H_comb,H_LA,ps]=selectAntenna2(H,N,subN,state,T_div) %H_comb = H(:,DELAY+1:end,:); ps = []; H_comb = H; ps = []; H_LA = squeeze(H(:,1,:)); 6)BT_alamouti

%Alamouti-STBC scheme for MISO-Alamouti %return if not MISO system

%T_mod is the modulated signal

%Nsymbol is the No. of symbols within each frame

%state can be 1,2,3,4 or 5, indicates different systems (1=SISO,2=MRC,3=MISO,4=EGC,5=AS) function T_trans=BT_alamouti(T_mod,Nsymbol,state) % if state~=3 % T_trans=T_mod; % return; % end if state == 2 || state == 6 for k=1:2:Nsymbol

Ant0(:,k:k+1) = [T_mod(:,k) -conj(T_mod(:,k+1))]; Ant1(:,k:k+1) = [T_mod(:,k+1) conj(T_mod(:,k))]; end T_trans(:,:,1)=Ant0;T_trans(:,:,2)=Ant1; else T_trans = T_mod; End 7) BTR_ofdm

%OFDM transiver plus channel

%B and P contains bits number and power for each subcarrier

%ch is the channel matrix, chnums is the No. of channel realizations

Một phần của tài liệu tổng quan về hệ thống mimo-ofdm mô hình stbc-ofdm (Trang 72 - 95)