How to design baseband filter for OFDM?

7 views (last 30 days)
I design OFDM, after i add CP, i want to give pulse shaping, or window filter (like hamming, hanning, blackman), but the output seems wrong, the main lobe attenuate as sidelobe. I know my ofdm is baseband signal, and i think it's ok with my code. What i want to ask is, whats wrong with my filter design? how to fix it? Is it same with pulse shaping with rcosine? Thank you
Please help me, i have done 2 weeks reseach on internet and matwork code, i dont really know how to do next.
Here's the part that is wrong. Even i use fvtool(filt_hamm), i think freq response of filter is true, the output must be true, but actually no, I know it's wrong when i find its BER (and its PSD is not good), and really bad compare without filtering, it must be wrong.
filt_hamm=fir1(4095,n_subcarrier/n_fft,hamming(4096)); %cut off at n_subcarrier/n_fft
for y=1:1:n_simbol
Tx_OFDM_filt_hamm(y,:)=filter(filt_hamm,1,Tx_OFDM_cp(y,:));
end
This is my code, it's working except the filter
clc; clear all; close all;
%%Parameter OFDM
n_subcarrier=1000; % Number of subcarrier
n_simbol=100; % Number of symbol
n_fft=4096; % Size FFT/IFFT
M=16; % Constellation Order
Tipe=2; % Modulate type, 1=PSK, 2=QAM
Phase_Offset=0;
N=4 ; % percentage of cyclic prefix n_fft/N
%%Transmitter
if Tipe == 1
Tx = modem.pskmod('M',M,'PhaseOffset',Phase_Offset,'SymbolOrder','gray','InputType','bit');
Rx = modem.pskdemod('M',M,'PhaseOffset',Phase_Offset,'SymbolOrder','gray','OutputType','bit');
else
Norm_mod=sqrt(3/2/(M-1));
Tx = modem.qammod('M',M,'PhaseOffset',Phase_Offset,'SymbolOrder','gray','InputType','bit');
Rx = modem.qamdemod('M',M,'PhaseOffset',Phase_Offset,'SymbolOrder','gray','OutputType','bit');
end
Tx_data=double(rand(n_subcarrier*log2(M),n_simbol)<.5);% Generate bitsream
Tx_modulated=Norm_mod*modulate(Tx,Tx_data); % Modulating
Tx_Zpad = [Tx_modulated(n_subcarrier/2+1:end,:);... % Add Zero Padding at the center
zeros(n_fft-n_subcarrier,n_simbol);...
Tx_modulated(1:n_subcarrier/2,:)];
Tx_OFDM=ifft(Tx_Zpad,n_fft); % IFFT
Tx_p2s=Tx_OFDM.'; % Parallel to serial
CP_part=Tx_p2s(:,end-(n_fft/N)+1:end); % Part Of CP
Tx_OFDM_cp=[CP_part Tx_p2s]; % Add CP to OFDM
filt_hamm=fir1(4095,n_subcarrier/n_fft,hamming(4096)); %cut off at n_subcarrier/n_fft
for y=1:1:n_simbol
Tx_OFDM_filt_hamm(y,:)=filter(filt_hamm,1,Tx_OFDM_cp(y,:));
end
Channel + Receiver
n_tap=4096; %
h_rayleigh=(randn(n_simbol,n_tap)+1i*randn(n_simbol,n_tap)).*sqrt(1/2);
h_ray_freq=fft(h_rayleigh,length(Tx_OFDM_cp),2); % channel impulse response
Tx_OFDM_rayleigh=Tx_OFDM_cp.*h_ray_freq;
SNR_awal=-10; SNR_tambah=2;SNR_akhir=30;const=0; % Awal means start (first iteration)
r=zeros(size(SNR_awal:SNR_tambah:SNR_akhir)); % tambah means increament
for snr=SNR_awal:SNR_tambah:SNR_akhir % akhir means end (last interation)
const=const+1;
Rx_AWGN=awgn(Tx_OFDM_rayleigh,snr,'measured'); % Noise AWGN
Rx_equalization=Rx_AWGN./h_ray_freq; % ideal equalization
Rx_OFDM_cp_remove=Rx_equalization(:,(n_fft/N)+1:n_fft+(n_fft/N)); % release Cyclic prefix
Rx_s2p=Rx_OFDM_cp_remove.'; % Serial to parallel
Rx_deOFDM=fft(Rx_s2p,n_fft) ; % FFT
Rx_Zpad= [Rx_deOFDM(n_fft-n_subcarrier/2+1:n_fft,:);... % release Zero Padding
Rx_deOFDM(1:n_subcarrier/2,:)];
Rx_demodulation=demodulate(Rx,Rx_Zpad./Norm_mod); % Demodulation
[n, r(1,const)]=biterr(Tx_data,Rx_demodulation); % Calculate BER
end
%%Graph
snr=SNR_awal:SNR_tambah:SNR_akhir;
% Plotting BER vs SNR
figure(1);
if M==2
semilogy(snr,r(1,:),'-ok','DisplayName','OFDM 2QAM');
elseif M==4
semilogy(snr,r(1,:),'-om','DisplayName','OFDM 4QAM');
elseif M==8
semilogy(snr,r(1,:),'-oc','DisplayName','OFDM 8QAM');
elseif M==16
semilogy(snr,r(1,:),'-ob','DisplayName','OFDM 16QAM');
elseif M==32
semilogy(snr,r(1,:),'-og','DisplayName','OFDM 32QAM');
elseif M==64
semilogy(snr,r(1,:),'-or','DisplayName','OFDM 64QAM');
end
hold on
grid on;
title('OFDM Bit Error Rate vs SNR');
ylabel('Bit Error Rate');
xlabel('SNR [dB]');
legend('show')
figure(2);
hold on
[Pxx1,W1]=pwelch(Tx_OFDM_cp(1,:),[],[],[],'centered','psd');
[Pxx3,W3]=pwelch(Tx_OFDM_filt_hamm(1,:),[],[],[],'centered','psd');
plot(W1,10*log10(Pxx1/max(Pxx1)),'DisplayName','OFDM');
plot(W3,10*log10(Pxx3/max(Pxx3)),'DisplayName','OFDM hamming'); hold on
grid on
xlim([-pi,pi])
set(gca,'xtick',[-pi,-pi/2,0,pi/2,pi])
set(gca,'xticklabel',{' -\pi';'-0.5\pi';' 0';' 0.5\pi';' \pi'})
xlabel('Normalize Frequency (radian/sampel)')
ylabel('Power spectral density (PSD)')
title('OFDM');
legend('show')
  1 Comment
Rishabh Rawat
Rishabh Rawat on 4 Jan 2019
Hi,
Any solution to this query? I am having the same doubt.

Sign in to comment.

Answers (1)

Madhumitha Munusamy
Madhumitha Munusamy on 23 Sep 2019
i am having a little problem over here. can someone help me
i have a OFDM matlab code. In that i want to replace cyclic prefix by NPR filter to analyze the performance but it's showing error.

Community Treasure Hunt

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

Start Hunting!