Vous êtes sur la page 1sur 4

BPSK

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% programme Matlab: ofdm-wifi-a.m pour gnrerer la tansmission OFDM base sur
les spcifications
% IEEE 802.11A
%==========================================================================
% nombre de bits gnrer:
%=================================
nBit = 2500;
% La taille de la FFT
%=================================
nFFTSize = 64;
% l'indice des sous-porteuses [-26 -1 1 26]
%==========================================================================
subcarrierIndex = [-26:-1 1:26];
% on gnre le flux bits (1 et 0)
%==========================================================================
ip = rand(1,nBit) > 0.5;
% nombre de bits par symbole OFDM
%==========================================================================
nBitPerSymbol = 52;
%nombre de symboles OFDM gnrer
%==========================================================================
nSymbol = ceil(nBit/nBitPerSymbol);
% la modulation BPSK bit0 --> -1 bit1 --> +1
%=========================================================================
ipMod = 2*ip - 1;
ipMod = [ipMod zeros(1,nBitPerSymbol*nSymbol-nBit)];
ipMod = reshape(ipMod,nSymbol,nBitPerSymbol);
% initialisation vecteur du signal la sortie IFFT
st = [];
% Opration de IFFT pour chaque symbole OFDM
%==========================================================================
for ii = 1:nSymbol
inputiFFT = zeros(1,nFFTSize);
% chaque symbole de a1 a52 est assign l'indice de la sous-porteuse [26 -1 1 26]
inputiFFT(subcarrierIndex+nFFTSize/2+1) = ipMod(ii,:);
% prmitation des sous-porteuses d'indices [-26 -1] l'entre de la fft
d'indices [38 63]
inputiFFT = fftshift(inputiFFT);
outputiFFT = ifft(inputiFFT,nFFTSize);
% on ajoute le cyclic prefix de 16 chantillons (1/4 symbole OFDM)
outputiFFT_with_CP = [outputiFFT(49:64) outputiFFT];

st = [st outputiFFT_with_CP];
end
close all
fsMHz = 20;
[Pxx,W] = pwelch(st,[],[],4096,20);
plot([-2048:2047]*fsMHz/4096,10*log10(fftshift(Pxx)));
xlabel('frquence, MHz')
ylabel('densit spectrale de puissance')
title('Spectre de transmission OFDM (bas sur 802.11a)');

PROBA DERREUR
nFFT = 64; % fft size
nDSC = 52; % number of data subcarriers
nBitPerSym = 52; % number of bits per OFDM symbol (same as the number of
subcarriers for BPSK)
nSym = 10^4; % number of symbols
EbN0dB = [0:10]; % bit to noise ratio
EsN0dB = EbN0dB + 10*log10(nDSC/nFFT) + 10*log10(64/80);
for ii = 1:length(EbN0dB)
% Transmitter
nBit = rand(1,nBitPerSym*nSym) > 0.5;
ipMod = 2*nBit-1; % BPSK modulation 0 --> -1, 1 --> +1
ipMod = reshape(ipMod,nBitPerSym,nSym).';
% Assigning modulated symbols to subcarriers from [-26 to -1, +1 to +26]
xF = [zeros(nSym,6) ipMod(:,[1:nBitPerSym/2]) zeros(nSym,1)
ipMod(:,[nBitPerSym/2+1:nBitPerSym]) zeros(nSym,5)] ;
% Taking FFT, the term (nFFT/sqrt(nDSC)) is for normalizing the power of
transmit symbol to 1
xt = (nFFT/sqrt(nDSC))*ifft(fftshift(xF.')).'; % Appending cylic prefix
xt = [xt(:,[49:64]) xt]; % Concatenating multiple symbols to form a long
vector
xt = reshape(xt.',1,nSym*80);
nt = 1/sqrt(2)*[randn(1,nSym*80) + j*randn(1,nSym*80)];
yt = sqrt(80/64)*xt + 10^(-EsN0dB(ii)/20)*nt;
yt = reshape(yt.',80,nSym).'; % formatting the received vector into
symbols
yt = yt(:,[17:80]); % removing cyclic prefix
yF = (sqrt(nDSC)/nFFT)*fftshift(fft(yt.')).';
yMod = yF(:,[6+[1:nBitPerSym/2],7+[nBitPerSym/2+1:nBitPerSym]]);
ipModHat = 2*floor(real(yMod/2)) + 1;
ipModHat(find(ipModHat>1)) = +1;
ipModHat(find(ipModHat<-1)) = -1;
ipBitHat = (ipModHat+1)/2;
ipBitHat = reshape(ipBitHat.',nBitPerSym*nSym,1).';
% counting the errors
nErr(ii) = size(find(ipBitHat - nBit),2);
end
simBer = nErr/(nSym*nBitPerSym);
theoryBer = (1/2)*erfc(sqrt(10.^(EbN0dB/10)));
figure
semilogy(EbN0dB,theoryBer,'bs-','LineWidth',2); hold on
semilogy(EbN0dB,simBer,'mx-','LineWidth',2);
axis([0 10 10^-5 1])
grid on
legend('theory', 'simulation');
xlabel('Eb/No, dB')
ylabel('Bit Error Rate')
title('Bit error probability curve for BPSK using OFDM')

QAM-16

clear all;
N = 16;
f = 1.5625e6;
d = 1e5;
t0 = 0;
t1 = 1e-4;
fs = 100e6;
T = (t1-t0)*fs;
%t = linspace(t0,t1,T);
t= t0:1/fs:t1;
T = length(t);

x = randint(1000,1,16);
m =qammod(x,16);

y = ifft(m);

frecs = [f:d:f+N*d]';
subportadoras1 = zeros(N+1,T);
subportadoras2 = zeros(N+1,T);
for i = 1:N+1
subportadoras1(i,:) = real(y(i))*sin(2*pi*frecs(i)*t);
subportadoras2(i,:) = imag(y(i))*sin(2*pi*frecs(i)*t+pi/2);
end
sent = sum(subportadoras1+subportadoras2);
figure(1);pwelch(sent);
scatterplot(m,1,0,'*');