Oflate, I am getting frequent requests for **bit error rate **simulations using **OFDM (Orthogonal Frequency Division Multiplexing)** modulation. In this post, we will discuss a simple OFDM transmitter and receiver, find the relation between Eb/No (Bit to Noise ratio) and Es/No (Signal to Noise ratio) and compute the bit error rate with BPSK.

## OFDM modulation

Let us use the OFDM system loosely based on IEEE 802.11a specifications.

Parameter |
Value |

FFT size. nFFT | 64 |

Number of used subcarriers. nDSC | 52 |

FFT Sampling frequency | 20MHz |

Subcarrier spacing | 312.5kHz |

Used subcarrier index | {-26 to -1, +1 to +26} |

Cylcic prefix duration, Tcp | 0.8us |

Data symbol duration, Td | 3.2us |

Total Symbol duration, Ts | 4us |

You may refer to post Understanding an OFDM Transmission for getting a better understanding of the above mentioned parameters.

## Cyclic prefix

In an OFDM transmission, we know that the transmission of cyclic prefix does not carry ‘extra’ information in Additive White Gaussian Noise channel. The signal energy is spread over time whereas the bit energy is spread over the time i.e.

.

Simplifying,

## Frequency spread

In OFDM transmission, all the available subcarriers from the DFT is not used for data transmission. Typically some subcarriers at the edge are left unused to ensure spectrum roll off. For the example scenario, out of the available bandwidth from -10MHz to +10MHz, only subcarriers from -8.1250MHz (-26/64*20MHz) to +8.1250MHz (+26/64*20MHz) are used.

This means that the signal energy is spread over a bandwidth of 16.250MHz, whereas noise is spread over bandwidth of 20MHz (-10MHz to +10MHz), i.e.

Simplifying,

.

## Relation between Eb/No and Es/No in OFDM

Combining the above two aspects, the relation between **symbol energy** and the **bit energy** is as follows:

.

Expressing in decibels,

## Simulation model

The attached Matlab/Octave simulation script performs the following:

(a) Generation of random binary sequence

(b) BPSK modulation i.e bit 0 represented as -1 and bit 1 represented as +1

(c) Assigning to multiple OFDM symbols where data subcarriers from -26 to -1 and +1 to +26 are used, adding cyclic prefix, concatenation of multiple symbols to form a long transmit sequence

(d) Adding White Gaussian Noise

(e) Grouping the received vector into multiple symbols, removing cyclic prefix, taking the desired subcarriers

(f) Demodulation and conversion to bits

(g) Counting the number of bit errors

Click here to download: Script for BER computation of BPSK using OFDM

**Figure: Bit Error Rate plot for BPSK using OFDM modulation**

Can observe that the simulated bit error rate is in good agreement with the theoretical bit error rate for BPSK modulation i.e.

. š

Can u explain why u have used ifft(fftshift) as well as fftshift(fft)? why not simple ifft and fft?

@Nag: fftshift is used to take the samples from [0:31, 32:63] and replace it as [-32:-1, 0:31].

The post on -ve frequency will be of help.

https://dsplog.com/2008/08/08/negative-frequency/

https://dsplog.com/2008/02/03/understanding-an-ofdm-transmission/

Hi Krishna,

I want to know what is the effect of different modulation techniques like BPSK,QPSK, 16-QAM,64-QAM on OFDM bit error rate for constant SNR 15db?

@Neetu: For a given SNR, the highest order modulation (i.e. 64QAM in your list) will have the highest probability of bit errors.

Please check out the post https://dsplog.com/2012/01/01/symbol-error-rate-16qam-64qam-256qam/ for more details

Hi Krishna Sankar,

Your blog is very helpful.

I am working on OFDM throughput calculation for 16,64-QAM. I am using 512 FFT and 360 data carriers, channel bandwidth of 5Mhz. How do i get the number of bits per sub carrier?

@Preethi: For 16QAM we have 4 bits per subcarrier and 64QAM has 6 bits per subcarrier.

Btw, are you loading all subcarriers with the same constellation type ?

mimo ofm zero force equalizer

Hi,

Can you plz provide the simulink model for parallel concatenated turbo decoder?

@Neetu: sorry, i do not have simulink and have not yet discussed on turbo decoder

sir

do u have coded OFDM using Reed Solomon codes over Rayleigh fading channel. im doing my project in this. i have done upto ifft and dont know whether it is correct or not. it showing some error.

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 = 239; % number of symbols

EbN0dB = [0:45]; % bit to noise ratio

EsN0dB = EbN0dB + 10*log10(nDSC/nFFT) + 10*log10(64/80); % converting to symbol to noise ratio

% Define Reed-Solomon coding parameters

m = 8; % Number of bits per symbol

n = 2^m-1; % Length of encoded data (255 for m=8)

k = 239; % Required length of source data (ie RS(255,239) )

t= (n-k)/2;

nw=nBitPerSym;

M = modem.pskmod(2); % modulation object

for ii = 1:length(EbN0dB)

ip=randint(nw,k,2^m);

msgw = gf(ip,m); % Random k-symbol messages

c = rsenc(msgw,n,k); % Encode the data.

c = reshape(c,nBitPerSym*(nSym+16),1).’;

ipMod = 2*c-1; % BPSK modulation 0 –> -1, 1 –> +1

ipMod = reshape(ipMod,nBitPerSym,nSym+16).’; % grouping into multiple symbols

% Assigning modulated symbols to subcarriers from [-26 to -1, +1 to +26]

xF = [zeros(nSym+16,6) ipMod(:,[1:nBitPerSym/2]) zeros(nSym+16,1) ipMod(:,[nBitPerSym/2+1:nBitPerSym]) zeros(nSym+16,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.’)).’;

end

??? Error using ==> gf.ifft at 12

X Must be a vector.

sir,kindly plz check my initial code. hopefully waiting for ur reply.

@vyga: is it giving error when noise is forced to zeros?

sir

sorry, i didnt understand your question … Till RS encoding and Assigning modulated symbols to subcarriers from [-26 to -1, +1 to +26] there was no error.. but when taking ifft, it showing error as

“Error using ==> gf.ifft at 12

X Must be a vector.”

sir, i have a doubt. can ifft apply on binary numbers only? here in RS code after encoding, we are getting some decimal values less than 255.. actually my project topic is concatenated Reed Solomon and Convolutional Codes for OFDM over fading channel.. for that i have to show RS and CC alone.. thank you for your coded OFDM using CC.. Sir, plz help me to simulate using RS code…

@vyga: ifft can be applied on any type of number – integer/float/double etc

Thank you sir…

From your code(coded OFDM using CC) instead of CC, i replaced it with RS and did the coding but not getting an expected output. i dont knw whether it is correct or not. I got simulated output just parallel to x-axis.. sir please help me.. here is the code…

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 = 239; % number of symbols

EbN0dB = [0:45]; % bit to noise ratio

EsN0dB = EbN0dB + 10*log10(nDSC/nFFT) + 10*log10(64/80); % converting to symbol to noise ratio

m = 8; % Number of bits per symbol

n = 2^m-1;

k = 239; % Codeword length and message length

t = (n-k)/2; % Error-correction capability of the code

nw = nBitPerSym; % Number of words to process

N=nBitPerSym*nSym;

Eb_N0_dB = [0:45]; % multiple Eb/N0 values

nTx = 1;

nRx = 1;

for ii = 1:length(Eb_N0_dB)

ipBit = randint(nw,k,2^m);

msgw = gf(ipBit,m); % Random k-symbol messages

c = rsenc(msgw,n,k); % Encode the data.

code = double(c.x);

ipMod = 2*code-1; % BPSK modulation 0 –> -1, 1 –> +1

ipMod = reshape(ipMod,nBitPerSym,nSym+16).’;

% Assigning modulated symbols to subcarriers from [-26 to -1, +1 to +26]

xF = [zeros(nSym+16,6) ipMod(:,[1:nBitPerSym/2]) zeros(nSym+16,1) ipMod(:,[nBitPerSym/2+1:nBitPerSym]) zeros(nSym+16,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];

% channel

nTap = 10;

ht = 1/sqrt(2)*1/sqrt(nTap)*(randn(nSym+16,nTap) + j*randn(nSym+16,nTap));

% computing and storing the frequency response of the channel, for use at recevier

hF = fftshift(fft(ht,64,2));

% convolution of each symbol with the random channel

for jj = 1:nSym+16

xht(jj,:) = conv2(ht(jj,:),xt(jj,:));

end

xt = xht;

% Concatenating multiple symbols to form a long vector

xt = reshape(xt.’,1,(nSym+16)*(80+nTap-1));

% Gaussian noise of unit variance, 0 mean

nt = 1/sqrt(2)*[randn(1,(nSym+16)*(80+nTap-1)) + j*randn(1,(nSym+16)*(80+nTap-1))];

% Adding noise, the term sqrt(80/64) is to account for the wasted energy due to cyclic prefix

yt = sqrt(80/64)*xt + 10 ^(-EsN0dB(ii)/20)*nt;

yt = reshape(yt.’,80+nTap-1,(nSym+16)).’; % formatting the received vector into symbols

yt = yt(:,[17:80]); % removing cyclic prefix

% converting to frequency domain

yF = (sqrt(nDSC)/nFFT)*fftshift(fft(yt.’)).’;

% equalization by the known channel frequency response

yF = yF./hF;

% extracting the required data subcarriers

yMod = yF(:,[6+[1:nBitPerSym/2] 7+[nBitPerSym/2+1:nBitPerSym] ]);

% BPSK demodulation

% +ve value –> 1, -ve value –> -1

ipModHat = 2*floor(real(yMod/2)) + 1;

ipModHat(find(ipModHat>1)) = +1;

ipModHat(find(ipModHat<-1)) = -1;

% converting modulated values into bits

ipBitHat = (ipModHat+1)/2;

msg2 = gf( ipBitHat,m);

msg2 = reshape(msg2.',nSym+16, nBitPerSym).';

%rs decode

decoded = rsdec(msg2,n,k);

x = decoded;

decoded_x = decoded.x;

z = double(decoded_x);

% Compute bit error rate from simulation.

[num,rt] = biterr(ipBit,z);

end

simBer = rt/(nSym*nBitPerSym);

EbN0Lin = 10.^(EbN0dB/10);

theoryBer = 0.5.*(1-sqrt(EbN0Lin./(EbN0Lin+1)));

%close all;

figure

semilogy(EbN0dB,theoryBer,'bs-','LineWidth',2);

hold on

semilogy(EbN0dB,simBer,'mx-','LineWidth',2);

axis([0 35 10^-5 1])

grid on

legend('Theory', 'Simulation');

xlabel('Eb/No, dB')

ylabel('Bit Error Rate')

title('BER for BPSK using OFDM')

sir,kindly plz check my code. hopefully waiting for ur reply.

@vyga: for debugging the code, please consider a zero noise case and see if you can correctly recover all the bits.

sir first of all thanks for your code….

please tell me meaning following commands .why is nSym*80 done ?

% Concatenating multiple symbols to form a long vector

xt = reshape(xt.’,1,nSym*80);

% Gaussian noise of unit variance, 0 mean

nt = 1/sqrt(2)*[randn(1,nSym*80) + j*randn(1,nSym*80)];

@Manish Kumar: In the simulation we are assuming 64 samples form and fft symbol, and 16 samples are appended as cyclic prefix – adding upto 80 samples per symbol.

Dear Sir

I want to simulate a bandwidth efficient OFDM scheme and want to compare its bandwidth efficiency with existing scheme.

How to evaluate or compare any two mudulation/communication schemes for bandwidth efficiency? I mean what sort of graphs or tables do I have to plot/tabulate?

please reply

@kiran: capacity in bits/per seconds/per Hz is a good metric for comparing the modulation schemes.

The following two posts might be of help

https://dsplog.com/2008/06/18/bounds-on-communication-shannon-capacity/

https://dsplog.com/2008/07/08/compare-bpsk-qpsk-4pam-16qam-16psk-64qam-32psk/

Dear Krishna Sir,

I want to know how relevant is the study on BPSK OFDM other than making the concepts clear ? Are there any practical applications where we have to go for BPSK modulated (as it has only real output after modulation ) OFDM systems instead of using QAM or higher order psk schemes ? Please reply

@kiran: Typical communication standards specify a range of modulation schemes – starting with BPSK (the lowest rate, but more coverage), going all the way to higher order 64/256QAMs

For eg, wireless LAN 802.11ag standard uses BPSK for providing the lowest 6Mbps data rate and 64QAM for the 54Mbps data rate.

Hello Krishna Sir,

I am doing thesis in MIMO OFDM. I need a code for MIMO OFDM BER v/s SNR in MATLAB.

Modulation can be bpsk,16 qam, qpsk or any other. 2 transmitting antenna, 2 rx antenna.

Please help me out.

I will be very obliged.

@Anurag Sharma: Please checkout posts under

https://dsplog.com/category/mimo/

https://dsplog.com/category/ofdm/

Sir, I want to simulate the OFDM synchronization but i dont know what should be the judging factors for synchronization. i mean for BER performance analysis we have BER vs SNR curves, similarly to evaluate performance of any synchroization scheme, what are the deciding factors? Please reply

@kiran: Typically, one would want to check the mean square error of

a) frequency offset estimate,

b) sampling clock offset estimate,

c) symbol boundary estimate

d) channel estimate and so on.

EVM is a good metric to be used for evaluation.

dear sir

i neeed ofdm with rs code so please help me for implement

@nirav: I have to discuss ReedSolomon code. Will add to the TODO’s.

hi: krishna

i need helpe of OFDM system and ICI

all matlab code

1-Frequency domain equalization

2-Time domain windowing

3-Pulse shaping

4-ICI self cancellation

5-Maximum likelihood Estimation

6-Extended Kalman Filtering

@asia:

Sorry, due to time pressure I wont be able to help you with the matlab code part.

However please refer some of the posts in https://dsplog.com/tag/ofdm for your reference.

Hello Mr.Krishna..

Can you please suggest me how to start with matlab coding..

evn i dnt kno hw to start wth it..i have studid matlab help and books regarding this but actuly nt getting wat to do next..m starting my thesis work on this bt nt getting how to start…with MIMO OFDM equalizer for spatial multiplexing ..means shall i hav coaching for it?

@Meenakshi: Matlab is a relatively easy language to learn.

For the MIMO-OFDM equalizer aspect, you take a look at

a) Some posts on MIMO : https://dsplog.com/tag/mimo

b) Some posts on OFDM : https://dsplog.com/tag/ofdm

Good luck.

Hello Krishna Sankar.

Thank you for good instruction of OFDM.

I have a question..

In your simulation, nFFT=64, used subcarrier=52, and you normalized to make transmitted power 1. In this case, whatever the number of used subcarrier is chosen, BER performance is same.. However, if I remove normailzation factor, the less the number of subcarrier is used, the better performance is shown. In the extreme case that 10 subcarrier is used, error is zero…

Could you tell me what is correct?

in real situation, do we normalize it to make transmitted power 1? or you just normalized to show same BER performance..

Thank you for your nice reply in advance.

Thank you!!

@Ryan: The changes in normalization will shift the curve to the right or left (but does not change the slope). For this simulation, I wanted the ofdm BER to overlap with the EB/N0 vs BER plots – hence did the normalizations to reach the same Eb/N0 using OFDM too. Am writing another post with comparing Eb/N0, Es/N0, SNR etc. Will update soon.

hello Mr. Krishna Sankar

in ofdm (FFT) , when i want to remove the guard interval (zeros) , then nDSC=nFFT,, i need to normalize the ifft operation too ???

thank you

@osama: For removing the guard interval, believe you wanted to remove the cyclic prefix (and not the null subcarriers)?

Mr. Krishna Sankar

i want to remove the zeros that are used for guard interval. i do not remove cyclic prefix

in other word, i want to use 64 subcarrier for data and 16 subcarrier as cyclci prefix ?

thank you

@osama: mm…cyclic prefix is a time domain concept

Mr. Krishna Sankar

i am know that, but it is represent an extra overhead.

with CP we repeat transmission part of data so we need extra bandwidth (i.e, the CP reserved 16 subcarrier).

thank you

@osama: Well, we need more time, not more bandwidth… š

please give me help on PAPR rduction for IEEE 802.11

@Manish: Sorry, I have not studied the problem

sir iam doing work in adaptive overlap and add technique in mb ofdm….so please solution the matlab code……………..

@raju: sorry, am not familiar with the topic

Hello Krishna.

First of all thank you very much for all your simulations that have helped me a lot. I wanted to ask you why after applying the fft at the received signal, you applied the following command:

ipModHat = 2*floor(real(yMod/2)) + 1; ?

Why does it have to be applied before veryfing if the real part of the received symbol is positive or negative?

Thank you in advance

@Raul: This is one way of quantizing the received signal to +ve and -ve.

For eg,

octave:8> yMod = [-2:0.5:1.9]

octave:9> [ 2*floor(real(yMod/2)) + 1;yMod]

ans =

-1.00000 -1.00000 -1.00000 -1.00000 1.00000 1.00000 1.00000 1.00000

-2.00000 -1.50000 -1.00000 -0.50000 0.00000 0.50000 1.00000 1.50000

Helps?

Yes, it helps a lot. Thank you very much Krishna

help me to creat matlab code for ofdm in wiener filter at receiver side

@david: Sorry i have not tried

one more question: I think if we use other types of modulation(16-qam,qpsk,etc) , then on the condition of AWGN channel, the BER-EbN0 will be the same no matter whether we adopt the OFDM technique. ~~~ is that right?

then we do obtain that the simulation results are the same as the theory ber??

@Michael: Yes, BER vs Eb/N0 should be the same

Thank you very much ,I do get the same results! I am so happy now.

I owe all to your helpful website,Thank again!

On the topic of the effect of oversampling,you can have a look at the help doc of matlab,there is a explanation.

Or you can refer to my blog ,I paste the ‘explanation’ on that. since I am from Chinese,you can ignore those words,just have a look at the last picture.

http://blog.csdn.net/mike190267481/article/details/7235028

Regards!

@Michael: Glad to help. Thanks.

Hi Krishna,

thank you very much for your very helpful website.I have learn a lot about OFDM via your website.

I have a question today, that is,in your code,when you add noise you account for the effect of CP ,if we don’t consider this then results will be a little different with the thereotical curve.

I would like to think that because you want to get the ‘right’ results ,so you make it up for the CP

Thank you again!

@Michael: Yes, I account for the CP to get the ‘right’ results. For a practical system, we typically plot the SNR vs BER curve…

I’m so glad to have your relay so soon,recently,I also do some investigation on this issue .You have just mention about the SNR.

I am confused by the relation between SNR and Es/N0 and you have shown me a good explanation about the relation about Es/N0 and Eb/N0.So,if we get the relation between SNR and Es/N0 then we can conver Eb/N0 to SNR

From my point of view,I think SNR and Es/N0 will be the same in almost cases,but for the oversampling. is that right?

Thank you again

Best Wishs!

@Michael: Mmm… for the oversampling affecting the SNR, can you point to a specific example?

hi krishna,

i am doing work in OFDM & CDMA . i required solution matlab code of PAPR of OFDM by SLM and PTS for diffrent value of N subsymbols .

@Manish: I have not studied much on PAPR, but some brief discussion can be found at

https://dsplog.com/tag/papr

hi!!!!!!!!! me too working on the same for my PG work!!!!!!!!!!!

if we tried together we can able to do it!

Hi Krishna,

thank you very much for your very helpful website.

I’m now doing analyzing the sampling offset in OFDM. but now i even cannot get a correct graph after adding the noise!

can you tell me what’s wrong with my programme?

clear;

flag=-4;

while flag==-4

N=input(‘number of data=’);

if N<=0 || mod(N,1)~=0

disp('numberof data is not valid');

else

flag=flag+1;

end

end

while flag==-3

time_step=input('time step=');

if time_step=1 || (1/time_step)<2*N

if time_step=1

disp(‘time step is wrong, please input from 0s to 1s and match to the number of the data’)

end

if (1/time_step)<2*N

disp('The time step is wrong which leads to less than minimum nyquist bandwidth');

end

else

flag=flag+1;

end

end

t=0:time_step:1-time_step;

while flag==-2

ebno_max=input('ebno max=');

if ebno_max=0.5

transmit_data(n)=1;

else

transmit_data(n)=-1;

end

end

for n=1:N

temp_signal=transmit_data(n)*cos(2*pi*n*t);

transmit_signal=transmit_signal+temp_signal;

end

for ebno=1:ebno_max

noise_factor=sqrt(0.5*(length(t)*N))/(2*ebno);

noise=randn(1,length(t)).*noise_factor;

resultant_signal=transmit_signal+noise;

for n=1:length(t)

sampled_signal(n)=resultant_signal(n);

end

RCV=real(fft(sampled_signal));

for n=1:N

check(n)=RCV(n+1);

end

counter=0;

for n=1:N

if check(n)>=0

recieved_data(n)=1;

else

recieved_data(n)=-1;

end

end

for n=1:N

if recieved_data(n)~=transmit_data(n)

counter=counter+1;

else

end

end

pe(ebno)=counter/length(transmit_data);

end

ebno=1:ebno_max;

semilogy(ebno,pe);

title(‘Error Performance of Bipolar Signaling in OFDM without sampling offset’)

xlabel(‘Signal to Noise Ratio (dB)’);

ylabel(‘probability error(Pe)’);

@Katy: I din’t understand your code. How are you trying to model sampling clock offset?

Hi Krishna

I am doing a project on ofdma dynamic bandwidth allocation schemes.As I am new to matlab, can you send me the basic MATLAB codes for simulation of mac layer protocols.It will be very helpful if you have the present GPON dba matlab codes for maclayer for different traffic loads.

@Toms: Sorry, I have not tried modeling MAC layer concepts in Matlab

Hello,

Thanks for your code.

I have a question: I didn’t understand how to model different fading for each OFDM symbol?

Assuming OFDM symbol N=64 bits;

for each OFDM symobl no. i

fading(i,:)=(randn(1,N)+j*randn(1,N))/sqrt(2);

So what is the term to add to this line to get different Flat fading for each OFDM symbol?

Thanks

@Davy: In the post on BPSK BER in OFDM with multipath channel

https://dsplog.com/2008/08/26/ofdm-rayleigh-channel-ber-bpsk/,

have discussed a 10 tap channel, with the channel taps randomly selected for each symbol.

Hope that helps….

hi every1….i wud lik 2 know whether 16 QAM is better or qpsk in terms of BER??….if its QPSK, den y BPSK n QPSK hav almost same BER???…BPSK wud hav been better than QPSK…

@vasanth: For achieving the same BER, 16QAM requires higher Eb/N0 than QPSK.

QPSK and BPSK has similar BER, as the information sent on QPSK is on orthogonal dimensions which does not interfere

Hai Krisnha

I just ask why do you use sign .’ after the script

ipMod = reshape(ipMod,nBitPerSym,nSym) .ā

what does the sign .’ mean ??

Thanks

wahyu

@Wahyu: The .’ means transpose

Hello,

I was wonder if you are going to post anything related to Basic LTE transmission which might be similar to this post.

@makra: I have not do written anything on LTE till now. Its on my growing to-do list š

Hi, Krishna Sankar, thank you for this wonderful post, but, when I come to my project which is based on the OFDM system, I need to use pilots to estimate the channel, and according to the IEEE802.11a and your statement, we would allocate 4 pilot subcarriers at -21, -7, 7, and 21, and the data is allocated from -26 to 26, so, my question is that how can we estimate the channel for the data from -26 to -21 and from -7 to 0(DC, and from your source code, this DC would be removed) by linear interpolation?

@Xudong Wu: Well, in 802.11a we have a preamble portion defined as “Long Training Field” at the beginning of the packet. All the subcarriers in this preamble is known at the receiver, and this is used to estimate the channel. As the packet duration is in the order of 100’s of us, the channel can be assumed to be constant for the duration of the packet.

The pilots are used to correct for residual frequency errors, sampling clock offset etc.

Thank you for your explaination, so, can you make a post to illustrate channel estimation in OFDM system?

@Xudong Wu: Ok, will do so.

Hey krishna. I have certain questions to ask….

1. Why the length of the CP is taken exactly 16 samples.

2.I have been able to generate QPSK but for 16 qam what normalization should I do as I am keeping the symbol energy to be

EsN0dB=EbN0dB+10*log10(4)+ 10*log10(52/64)+10*log10(64/80);

do I need to add some scalling factors to get accurate result…as when I am following your simulation then in case of 16Qam without cyclic prefix the result is comming out to be correct…but with cyclic prefix the curve just deviates…..

could you please help.

@Neil:

1/ Its a system design choice. For indoor wireless lan, the worst case delay spread is found to be around 0.8us (and 0.8us with 20MHz sampling gives 16 samples)

2/ Scaling factor for 16QAM is 1/sqrt(10). Please refer https://dsplog.com/2007/09/23/scaling-factor-in-qam/

Hello dear. yours Matlab program is really helpful. I am unable to understand line number 34 i.e. xt = (nFFT/sqrt(nDSC))*ifft(fftshift(xF.ā)).ā , i need following queries:

1. Why there is a need of normalization?

2. Before ifft, you have taken fftshift that swaps the data elements, why there is need of fftshift?

3. how this line counts error nErr(ii) = size(find(ipBitHat – ipBit),2);? Please elaborate.

Please reply

@UK:

1) The normalization is to make the transmit power unity – to allow for precise definition of Es/N0.

2) The matlab ifft expects the signals to be present in the order from [0 to 63] rather than [-32 to 31]

3) The find() looks for differences between the two variables. The size() counts the number of differences.

Idonāt try to simulte cfo for mimo system only but for mimo ofdm I propose a new scheme that targets MMIO OFDM systems which have unsynchronized oscillators such that CFO of individual paths have to be estimated separately. This scheme may also apply to OFDM systems with multi-user access. The new method, which is similar to Mooseās method, estimates the CFO by measuring the carrier phase difference between 2 identical successive training sequences embedded in the preambles. In order to make CFO estimates be more time efficient,I allow 2 transmitter antennas transmit their training sequence concurrently in every time period, except the first and the last period. I use Frank-Zadoff code with different phase shifts in the training sequences in different antennas. Due to the good correlation property of Frank-Zadoff code, it helps reduce the interference caused by the concurrent transmissions from other antennas.

please helpppppppppppppppppppppppp

please reply me itās urgent Ineed the code itās really important and thanks alot

@eng_dina: Good luck with you are algorithm investigation. Hope you have made the simulations and obtained satisfactory results.

I want to add 4 pilot carriers in the unused 12 slots that is left(64-52) in the code u have put up.Can u just help me in this regard

@ajith: You can assign modulated symbols into those indices which are untouched

thanks for your your graet work

please I study for my master in frequency synchronization in mimo ofdm system but i have problem with the matlab code to simulate to find out if estimation of the CFO on one path is affected by the CFO values of the adjacent paths and examine the estimator accuracy in term of its mean and variance

please help me itās urgent and necessary

@eng_dina: How are you modeling the CFO for MIMO systems?

If all the chains have a common RF clock, then all the chains will have similar CFO and the estimate from all the chains can be combined to improve the accuracy of the CFO estimation.

If the chains have independent RF clock, then we need to estimate CFO on each chain independently.

Hi, could u please post a new subject to describe the SER and BER for MQAM(M>=4) in OFDM?

I’m confused about the Es here, does it mean the sample energy in time domain or the energy in frequency domain in used data sub-carriers?

And, why do you use the same theory BER formula for BPSK in an un-coded awgn? how can I get SER from BER(vice versa) in OFDM?

@danial: My replies

a) Extending to M>4 should be reasonably simple. You may have a look at the following posts for reference

Symbol error rate for 16QAM in AWGN

https://dsplog.com/2007/12/09/symbol-error-rate-for-16-qam/

Bit error rate for 16QAM in AWGN assuming Gray coded bit mapping

https://dsplog.com/2008/06/05/16qam-bit-error-gray-mapping/

b) Es stands for energy per constellation symbol (defined in frequency domain)

c) OFDM does not do any special except that it allows for sending information on parallel channels simultaneously. Hence the BER in AWGN is same as BER with OFDM in AWGN

d) The relation between Symbol error rate and bit error rate is independent of whether we use OFDM. I have a brief discussion on this relation in the post Bit error rate for 16QAM in AWGN assuming Gray coded bit mapping

https://dsplog.com/2008/06/05/16qam-bit-error-gray-mapping/

Hope this helps

Hi Krishna Sankar,

% Taking IFFT, the term (nFFT/sqrt(nDSC)) is for normalizing the power %of transmit symbol to 1

xt = (nFFT/sqrt(nDSC))*ifft(fftshift(xF.ā)).ā;

Why the normalization factor in the ifft is (nFFT/sqrt(nDSC)) instead of sqrt(nFFT/nDSC), just like sqrt(80/64) when considering cp?

And in the receiver ,

% Taking FFT (converting to frequency domain)

yF = (sqrt(nDSC)/nFFT)*fftshift(fft(yt.ā)).ā;

why to multiply sqrt(nDSC)/nFFT ? In order to normalize again?

But when you normalize the transmitted signal , you just add awgn, nothing else affect it . Why to multiply the factor?

Hi Krishna Sankar, I think very carefully about the coefficient nDSC/nFFT in the formula Es=nDSC/nFFT*Eb but I didn’t get the point. Is Eb the bit energy that spreads over nDSC subcarriers? Es also spreads over nDSC subcarriers because no energy is located to the guard bands, so I think in the frequency domain, it should be Es = Eb. Please give me the answer soon, I have to explain to my teacher. Thank you in advance

P.S: Thank you for your Matlab code, it helps me a lot with my thesis.

Hi Krishna sankar,

Your simulation is a great help to me, and I can well understand it.

However, there is one question confusing me: Although the simulation result showed the same performance between BPSK in AWGN and BPSK over OFDM in AWGN, could you please give me a deeper explanation?

{In my opinion, the system can be descripted as

xF_est = FFT(IFFT(xF))+n)=xF+FFT(n)

xF: the transmitted symbols

n: noises

xF_est: the estimate of transmitted symbols

As far as I know, FFT(n) don’t have the same statistic property as n. So we can’t get the same result as BPSK in AWGN. Is this correct?

}

Thanks in advance!

Best Regards,

Zhongliang

@Zhongliang: Well, I think fft(n) has the same statistical property as n, and hence we get the same result.

Unfortunately, am unable to point you to some text books which describes the proof for above. If you stumble across something, please let me know.

Hi Krishna sankar

I am really thanks becuase you give me response i am written detail here

bit error rate versus bit signal-to-noise ratio for eight

different operation modes (6, 9, 12, 18, 24, 36, 48, and

54 Mbps) under AWGN channel.

compare the throughput performance of

802.11g and 802.11a which employ same OFDM

technique, but used different MAC parameters,

specified in Table

Table 2. IEEE 802.11g and 802.11a Parameters

Parameters 802.11g 802.11a

CW min 32 16

CW max 1024 1024

Slot Time 20 Ī¼s 9 Ī¼s

SIFS 10 Ī¼s 16 Ī¼s

DIFS 50 Ī¼s 34 Ī¼s

Propagation Delay 1 Ī¼s 1 Ī¼s

Basic Rate 1 Mbps 6 Mbps

Data Rate 54 Mbps 54 Mbps

Packet Payload 1000 Bytes 1000 Bytes

MAC Header 28 Bytes 28 Bytes

RTS Packet 44 Bytes 44 Bytes

CTS Packet 38 Bytes 38 Bytes

ACK Packet 38 Bytes 38 Bytes

PHY Header 24 Bytes 24 Bytes

these are paramters for 802.11a and 802.11g

if you need more information i can give to you

thanks

BR

@kim: For error rates for various modulation schemes, you can

https://dsplog.com/2007/08/05/bit-error-probability-for-bpsk-modulation/

https://dsplog.com/2007/11/06/symbol-error-rate-for-4-qam/

https://dsplog.com/2007/12/09/symbol-error-rate-for-16-qam/

https://dsplog.com/2008/06/05/16qam-bit-error-gray-mapping/

For the implications of MAC level parameters, please refer to the paper

Throughput and Delay Limits of IEEE 802.11, Yang Xiao, Jon Rosdahl, IEEE COMMUNICATIONS LETTERS, VOL. 6, NO. 8, AUGUST 2002

Dear Krishan

Thank for Reply

but I need simulation matlab codes for Post and Pre-FFT Beamforming in an OFDM System

Please help me

Thank a lot

@waleed: Sorry, I am not familiar with the topic which you are referring to.

is there any code with help me to comparission between 802.11a and 802.11g

@kim: What are metrics on which you wish to compare?

Hi Krishna sankar

because 802.11a and g same parameter

@kim: Yes, 802.11a and OFDM rates in 802.11g share the same baseband. Only the RF carrier changes from 5GHz to 2.4GHz band

Hi Krishna sankar

i am new user , i want to BPSK BER with OFDM modulation with 802.11g. so what should i do….? i can do it with above equation…

please can you give reply as soon as possibe

because it is related to my project

@kim: This post should serve as a basic starting step. Ofcourse, in 802.11a/g OFDM chain, there are other stuff like scrambler, coding, interleaving, filters etc….

Good luck.

Hello! Kirishna

will u pls. help… or send me matlab prog. which compareies the Ber vs multipath delay spread for different modulations used in OFDM like 16psk,qpsk,bpsk,8psk,32psk,etc.. PLEASE REPLY AS SOON AS POSSIBLE…

@Ruby: You may find the comparison of various modulation schemes in AWGN in

https://dsplog.com/2008/07/08/compare-bpsk-qpsk-4pam-16qam-16psk-64qam-32psk/

You have given the Es/No smilarly,

for CDMA in rappaport’s book , He has explained from the block diagram till the derivation of probability of error.With Gaussain approximations too.

Could you suggests me one or where have you reffered for the derivation of the same kind and deeper explanation.

@rakesh: Adding OFDM to BPSK does not change the underlying BER for BPSK modulation. The derivation of BER for BPSK in AWGN is captured in https://dsplog.com/2007/08/05/bit-error-probability-for-bpsk-modulation/

Hi Krishna

Thanks very much, your guidance, your work and your advice is really getting me through in my dissertation work.You are indeed a supervisor for this my project, and i will not finish this work workout puting ur name in the ACKNOWLDGEMENT section of this project. More grace to your ego.

Actually i have used your answer below to try and achieve a different noise (SNR), that is to get different graph for different SNR, but i was unable to do that. WHEN I USE SNR=[0:10], THE FIRST GRAPH WAS PLOTTED, BUT WHEN I USE SNR=[0:20], AND [0:30] THE GRAPH STILL REMAIN AT SNR=[0:10] .i believe that something is still missing, pls i will need your help, so that i can provide solution to this.

Secondly, i want to use SIMULINK, a real life model of mobile to base station link and work out BER for various noise conditions, pls i will appreciation if you provide guidance on this for me OR probably a solution.

Eb_No_dB =[0:10], –> 0 to 10dB in steps of 1dB

Eb_No_dB =[0:20], –> 0 to 20dB in steps of 1dB

Eb_No_dB =[0:30], –> 0 to 30dB in steps of 1dB

Thanks very much.

NNAMDI

@Egerue: Thanks. You might want to check the axis() command in the simulation code š

Hello Krishna,

While looking at your code, I find that you are adding CP before converting the parallel stream in to serial. So it means there is a cyclic prefix for every parallel branch.

I’m not too sure about this since I think CP should have been added at the very end, after the stream has been converted from parallel to serial.

May I know why you are doing this? Wouldn’t this be wrong? Although the graph seems to be correct. Perhaps I’m mistaken

Furthermore, I’m not sure when you reply so kindly forward the answer to this query on my email address, which is [my user name here]@yahoo.com

@communications_engineer: Well, the parallel to serial aspect is a ‘notional’ thing. Don’t you agree? We need to add cyclic prefix for every ofdm symbol (i.e for every ifft out).

Dear Krishna,

thnks for Your simulations which are very usefull.

Does this script work correctly only if we know frequency response?

I ask You that because I thought that if we know frequency response, we

can compensate influence of Rayleigh fading and than we have BER like in

AWGN systems. In Your simulation You have frequency response, but BER

graphic has still tipicall shape for Rayleigh channel.

Thanks very much!

@David: Yes, the script assumes that the receiver knows the channel. Even if the receiver knows the frequency response and compensates for it, it still wont be like AWGN. Recall, Y = HX + N

At receiver, we do Y/H = X + N/H.

The term N/H can cause poorer BER. Makes sensE?

dear Krishna,

it’s ok for second reply (understood)

but i can not understand why you multiply by sqrt(80/64) ??how this term normalize symbol power??

@ahmed: Since the cyclic prefix samples are ignored by the receiver, the noise added to those samples does not have any effect on demodulation. To account for that, the term sqrt(80/64) is used.

dear Krishna,

1-we assume that the cyclic prefix is of duration 16 samples and the data symbol is of duration 64 samples. The term sqrt(80/64) is to normalize the transmit power. can you explain by equation how this term make transmit power=1?

2-you said that we put 12 carriers (6+6)at the edges of band to prevent interference from other bandsā¦.in your simulation,you used ifftshift and put zeros in the middle.why???

please reply as soon as possible.

@ahmed:

1/ The noise added to the 16 samples of cyclic prefix does not have any effect as these samples are discarded

2/ Please refer to the post on -ve frequency to understand the need for fftshift

https://dsplog.com/2008/08/08/negative-frequency/

https://dsplog.com/2008/02/03/understanding-an-ofdm-transmission/

Hi krishna, I have actually read the answers given to you by the concerns generated by the formula below

10^(-Eb_N0_dB(ii)/20)*n

for further clarification, i have actually divided by 18,16,14,12āā3 to get different plots that actually decreases down the graph . Want to know if is how one can plot for BER with variable noise in the channel. I will appreciate if you reply me soon. Thanks

@Egerue: Do not change the division factor. Rather change the value of Eb_N0_dB. The division by 20 is required to convert dB into voltage.

Hi Krishna

Pls in the formular below

yt = sqrt(80/64)*xt + 10^(-EsN0dB(ii)/20)*nt;

i have tried to vary the /20 to get different kind of plots. But want to comfirm from you if is where you have to get “Variable noise in an OFDM channel to obtain different BER plots

dear sir,

1-we assume that the cyclic prefix is of duration 16 samples and the data symbol is of duration 64 samples. The term sqrt(80/64) is to normalize the transmit power. can you explain by equation how this term make transmit power=1?

2-you said that we put 12 carriers (6+6)at the edges of band to prevent interference from other bands….in your simulation,you used ifftshift and put zeros in the middle.why???

please reply as soon as possible.

@ahmed:

1/ The noise added to the 16 samples of cyclic prefix does not have any effect as these samples are discarded

2/ Please refer to the post on -ve frequency to understand the need for fftshift

https://dsplog.com/2008/08/08/negative-frequency/

https://dsplog.com/2008/02/03/understanding-an-ofdm-transmission/

@EGRUE: Yes, the term 10^(-EsN0dB(ii)/20) is to scale noise voltage differently.

Hi, I didn’t get your line, can you please make it simpler?

you said:

” The term 10^(-EsN0dB(ii)/20) is to scale the noise voltage such that the ratio between signal energy and noise energy is scaled. ”

Thanks.

@Karan: The variable EsN0dB represents the Symbol to Noise Ratio in dB. To convert it to a scaling factor for noise voltage, we convert that by 10^(-EsN0dB(ii)/20)

Helps?

Hi Krishna, how are you doing ? what’s current topic you are work on?

which is more logical way of representing (S-P & modulator) ?

method 1: bits pass to modulator first & then reshaping

ipBit = rand(1,nBitPerSym*nSym) > 0.5 ;

ipMod = 2*ipBit-1; % BPSK modulation 0 –> -1, 1 –> +1

ipMod = reshape(ipMod,nBitPerSym,nSym).’; % grouping into multiple symbolsa

method 2: first reshaping & then pass to modulator

ipBit = rand(1,nBitPerSym*nSym) > 0.5 ;

ipBit = reshape(ipBit, nBitPerSym,nSym).’ ;

ipMod = 2*ipBit-1; % BPSK modulation 0 –> -1, 1 –> +1

I think when no. of symbol=no. of bits(BPSK case), then it doesn’t matter the priority But for other modulation techniques like QPSK, MPSK , MQAM, (M> 2).. the method 2 should be followed. Am I right?

Thanks in advance.

@Karan: Well, for higher order modulation schemes, we need to group bits to form a constellation symbol. As we are doing a model, it does not matter how we do as long as it is mathematically accurate š

Note that the grouping am performing here is to group into OFDM symbols.

could help me to understand

xF = [zeros(nSym,6) ipMod(:,[1:nBitPerSym/2]) zeros(nSym,1) ipMod(:,[nBitPerSym/2+1:nBitPerSym]) zeros(nSym,5)] ;

thank you

@christine: The variable xF represents the input to the iFFT. It represents subcarrier indices from [-32 to 31]. However as we are using only indices from [-26 to -1, 1 to 26], we have 6 zeros in the beginning, 26 used subcarriers, unused dc subcarrier which is not used, 26 used subcarriers, then again 5 zeros at the edge. Helps?

Hi Krishna,

I have a problem understanding the term ” number of used subcarrier=52″.

I understood the significance of the guard interval (Tcp+Td=Ts). In your example does the the data symbols ( 3.2 Āµs) correspond to the 52 used subcarriers. And deos the Tcp correspond to 14 other sub-carriers?

Is this correct.

Best,

Ismail

@Ismail: The data symbol duration of 3.2us corresponds to the fft size (64) and the sampling clock (20MHz). To send 64 samples at 20MHz, we need 3.2us. It does not correspond to the number of used subcarriers.

Hi Krishna

your script is really very good

actually i got bit confused regarding data rate you used in the script BPSK BER with OFDM modulation. can you help me how we can we calculate data rate in the above script. plz tell me why you use nsym=10^4, any reason plz help me

@Bhasker Gupta: The actual data rate is notional in this script. In the system, it depends on how fast we sample the ifft samples. For example, if we have a sampling clock of 20MHz and as we are using 80 samples to send 52 bits,

the data rate = number of bits per symbol / symbol duration = 52 / (80/20) = 13Mbps.

I use nSym = 10^4 to get statistically accurate results.

hi krishna

thanks for answering my previous query

in your script you added term 10^(-EsN0dB(ii)/20)*nt to xt as additive white gaussian noise. i want to know how actually the above term comes. how can i do same thing with awgn command in matlab. secondly i want to include RS channel coding in above script will you help me plz.

@Bhasker: The term 10^(-EsN0dB(ii)/20) is to scale the noise voltage such that the ratio between signal energy and noise energy is scaled. I do not have matlab, hence unable to help with the arguments in awgn() in Matlab.

I have not discussed RS codes in the posts till now. Hope to do so in future.

i did that and thanks but i tried to do same thing you did for qpsk but it is not working. could you hel me.

@amy: Sorry, due to time constraints, I find it difficult to debug the code. If you can mail more about “what is not working”, i can try to help.

We can use this one. the above one was a function.

u0=4*pi*realpow(10,-7);

ur=1;

e0=8.85*realpow(10,-12);

er=5.3;

con=5.8*realpow(10,7);

cond=5*realpow(10,-6);

ra=1.128e-3;

s=6*ra;

L=(u0/pi)*log((s/(2*ra))+sqrt((s/(2*ra)).^2 – 1));

C=(pi*e0*er)/(log((s/(2*ra))+sqrt((s/(2*ra)).^2 -1)));

G=(pi*cond)/(log((s/(2*ra))+sqrt( (s/(2*ra)).^2 -1)));

RS=50;

l=20;

RL=91.84;

n=10000;

f=1:n:100000000;

[n2 m2]=size(f);

ts=1e-9;

t=[0:1:299]*ts;

[n1 m1]=size(t);

R_Surface=sqrt((pi*f*u0*ur)/con);

R=(((R_Surface)/(pi*ra))*((s/(2*ra))/sqrt((s/(2*ra)).^2 – 1)));

Z= sqrt((R+j*2*pi*L*f)./(G+j*2*pi*C*f));

r= sqrt((R+j*2*pi*L*f).*(G+j*2*pi*C*f));

A=cosh(r*l);

B=Z.*sinh(r*l);

C=sinh(r*l)./Z;

D=cosh(r*l);

H=RL./(A*RL + B+ C*RL*RS + D*RS);

h=20* log10(abs(H));

for tx=1:m1

sum=0;

for kx=1:m2

sum=sum+H(kx)*exp(j*2*pi*t(tx)*f(kx));

end

y(tx)=(n/100e6)*sum;

end

figure(1)

plot(f,h)

figure(2)

plot (t,y)

hello again Krishna

.it is power line channel it was in frequency domain using ifft program

for tx=1:m1

sum=0;

for kx=1:m2

sum=sum+H(kx)*exp(j*2*pi*t(tx)*f(kx));

end

y(tx)=(n/100e6)*sum;

end

y isin time domain.

which bag do you mean?

please i need help really ergent

which bug

@Amy: Hmm… why dont you use ifft to generate the frequency response of the channel?

Also, typically we can convolve the time domain transmit sequence with the time domain channel.

hello Krishna

i have a power line channel .could you please help me to simulate ofdm using the channel

here is the code

function y=testno(data_tobeatransmited)

u0=4*pi*realpow(10,-7);

ur=1;

e0=8.85*realpow(10,-12);

er=5.3;

con=5.8*realpow(10,7);

cond=5*realpow(10,-6);

ra=1.128e-3;

s=6*ra;

L=(u0/pi)*log((s/(2*ra))+sqrt((s/(2*ra)).^2 – 1));

C=(pi*e0*er)/(log((s/(2*ra))+sqrt((s/(2*ra)).^2 – 1)));

G=(pi*cond)/(log((s/(2*ra))+sqrt( (s/(2*ra)).^2 – 1)));

RS=50;

l=20;

RL=91.84;

q=length(data_tobeatransmited);

n=10000;%100000000/m;

f=1:n:100000000;

[n2 m2]=size(f);

ts=1e-9;

m=300/(q+1);

t=[0:m:299]*ts;

[n1 m1]=size(t);

R_Surface=sqrt((pi*f*u0*ur)/con);

R=(((R_Surface)/(pi*ra))*((s/(2*ra))/sqrt((s/(2*ra)).^2 – 1)));

Z= sqrt((R+j*2*pi*L*f)./(G+j*2*pi*C*f));

r= sqrt((R+j*2*pi*L*f).*(G+j*2*pi*C*f));

A=cosh(r*l);

B=Z.*sinh(r*l);

C=sinh(r*l)./Z;

D=cosh(r*l);

H=RL./(A*RL + B+ C*RL*RS + D*RS);

h=20* log10(abs(H));

% w=length(H);

% H=reshape(H,w,1);

for tx=1:m1

sum=0;

for kx=1:m2

sum=sum+H(kx)*exp(j*2*pi*t(tx)*f(kx));

end

y(tx)=(n/100e6)*sum;

end

H is the transfer function and y is the impluse response

thank you

@Amy: What is the bug in the code?

sir in reference to your simulation for ber of ofdm in fading channel ,

i want to know why have u added only 10 taps ? what is the logic behind it ?

@hemdutt: In the simulations, I have a defined a cyclic prefix of duration 16 samples. I wanted to have a channel which is having shorter duration than the cyclic prefix. Hence I chose 10.

Dear Krishna Sankar

I have looked for the equation that you used in the simulation:

EsN0dB = EbN0dB + 10*log10(nDSC/nFFT) + 10*log10(64/80)+10*log2(M);

Or EsN0 = EbN0*(nDSC/nFFT)*(64/80)*log2(M); but I couldn’t find it in any reference.

If we multiply this equation by ts, we will get

EsN0 = EbN0*(nDSC/nFFT)*(64*ts/80*ts)*log2(M);

EsN0 = EbN0*(nDSC/nFFT)*T/Ts*log2(M);

Which does not consistent with the following equation :

EsN0 = EbN0*(T/Ts)*Rc*log2(M)

Where

T: Fourier period

Ts: OFDM symbol period

Rc: code rate

M=2^no.bits

Where there is an extra term (nDSC/nFFT) in your equation.

Reference book:

Theory and application of OFDM and CDMA, by Henriks, page 159

Could you give me your reference please?

Thanks in advance

@Sami: I do not have a reference for the term (nDSC/nFFT). However, the term is needed because we are using only nDSC subcarriers out of the nFFT subcarriers. When we define the variance of noise in time domain, the variance on each subcarrier is the same and affects the subcarriers which are not used also. However, the un-used subcarriers need not be factored in for Eb/N0 definition. Hence the usage of the term nDSC/nFFT.

Hope this helps. Please revert for clarifications.

Hi,

The expression provided in the above discussions

Es/No = Eb/No * (nDSC/nFFT) * (Ts/(Ts+Tcp))

The first term (nDC / nFFT) can be seen as a factor to get the effective SNR (Es/No) in the system which has fewer sub-carriers loaded than the noise bandwidth. So SNR per subcarriers is better by that factor. The second term (Ts/(Ts+Tcp)) is a result of the usual Es/No = Eb/No * (R/B) for any system.

I hope this clears the confusion.

Regards,

Amit Shaw

@Amit: Thanks.

Dear Krishna

Power normalization means that the power of the signal should equal one after normalization.

but when I calculate the power of the following:

1) x1 = 1/sqrt(2)*[randn(1,nSym*80) + j*randn(1,nSym*80)];

2) x2 = sqrt(80/64)*xt

the power do not equal one.

Could you explain what going on, pls?

Thanks in advanced

@Sami: The power of x1 is indeed one. Why did you multiply by sqrt(80/64)?

Dear Krishna Sankar

-For x1, the power will be one only if we make the value of nSym very large, but for small values of nSym the power does not normalized. So I think its better to generate the noise first, then calculate the generated noise power, after that normalize the generated noise power. In this case the noise power will be 100% normalized, and it will be independent on the value of nSym.

-For x2, I read your reply for Jimmy that you multiply by sqrt(80/64) for normalization purpose.

Thanks in advance

————————————————————————–

Krishna Pillai December 29, 2008 at 5:58 am

@jimmy: In the simulation model, we assume that the cyclic prefix is of duration 16 samples and the data symbol is of duration 64 samples. The term sqrt(80/64) is to normalize the transmit power. This normalization ensures that scaling of noise with respect to Es/No is valid.

@Sami: My replies:

1/ To be statistically accurate, we need more number of samples. I think, rather than simulating with lesser number of samples and then doing an ‘extra’ normalization on top of it, we would be better of simulating with a large number of samples

2/ The reply to Jimmy was about normalizing the transmit signal (and not the noise signal, which you are referring to). Jimmy’s query about sqrt(80/64) is pertaining to the transmit OFDM symbol where only 64 samples are useful (the rest 16 are redundant).

Hope this helps.

Dear Krishna

I am trying to simulate an OFDM system using Cyclic Delay Diversity with different number of Tx antennas and 1 Rx antenna. I thought if i could use your program; but I have few questions for you:

1- I want to use Wimax frequency selective and flat fading channels, how can I create such a channels in your program? or the frequency selective channel you have created (random complex numbers) is also valid for Wimax and if I put nTap =1 would i be flat fading channel? I know there is also a built in function in MATLAB for such channels but I am unable to simulate using them.

2- As I increase the number of Tx antennas e.g. 2nd antenna, do I have to create a new set of parameters for it? e.g. separate channel, frequency response and noise for this 2nd signal. If its true; then How will I equalize 2 different signals after FFT as I would have already combined these two signals right after the Rx antenna (so now there is only 1 signal again).

One of my idea is to calculate separate frequency response for each channel and then add them to form a combined freq. response and then equalize using this single freq. response. Am I right! or whats your suggestion?

I would really appreciate your prompt help.

Regards.

@Muhammad:

1/ For WiMAX channel models, you may refer to the article Channel Models for Fixed Wireless Applications, Vinko Erceg, KVS Hari et al,

http://wirelessman.org/tga/docs/80216a-03_01.pdf

If you put nTap=1, then the channel is flat fading.

2/ You can write down the equations for 2-transmit 1-receive antenna case. Since you might be knowing the channel for each subcarrier, you can divide by the channel to equalize the received symbol. Hopefully the post on Transmit Beamforming might be of help.

https://dsplog.com/2009/04/13/transmit-beamforming/

Dear sir

i am ding project on pulse shaping design for ofdm ….i am writing but not getting properly can u give any code for that …sothat i can go further plz ..

thank you sir

regards

@chanti: In typical OFDM systems, as we are using sinusoidal pulse shapes (thanks to ifft), we typically do not need to do any ‘extra’ pulse shaping.

Hi! First of all thanks for your script that clarify me several aspects in OFDM. What I do not understand is how you obtain the expression

Es/N0 = Eb/No (nDSC/nFFT)(Td/(Td+Tcp))

starting from the two expression:

Es = (Td/(Td+Tcp))Eb and

Es = (nDSC/nFFT)Eb.

I want to extend the simulation to a general mQAM constellation and if I understand how this expression is derived, probably I can write an expression similar for example for 16QAM or 64QAM.

Thank you in advance

@Daniele: My replies:

1/ The term Es = (Td/(Td+Tcp))Eb comes because, we are sending samples over the time (Td+Tcp). However, useful information is contained only in the time Td.

2/ The term Es = (nDSC/nFFT)Eb comes because, we sending nFFT subcarriers. However, we are sending data only on nDSC subcarriers.

3/ Well, for a higher order modulation like M-QAM, one might also want to factor in that each symbol carrier log2(M) bits. For example, Es’/N0 = kEb/N0, where k = 4.

Also note: if you are using QAM constellation, you might want to normalize the transmit power to 1 by using the scaling factor 1/sqrt (2/3*(M-1)) https://dsplog.com/2007/09/23/scaling-factor-in-qam/

Thanks for your kind answer and clarifications.

It would be great if you could explain this sentence reported in your e-book about the simulations in awgn:

RelationĀ betweenĀ Eb/NoĀ andĀ Es/NoĀ inĀ OFDM

Combining (??how??)Ā theĀ aboveĀ twoĀ aspects [Es = (Td/(Td+Tcp))Eb] and [Es=(nDSC/nFFT)Eb],Ā theĀ relationĀ betweenĀ symbolĀ energyĀ andĀ theĀ bitĀ energyĀ isĀ asĀ follows:Es/N0 = Eb/No (nDSC/nFFT)(Td/(Td+Tcp)).

Looking in this list of comment, I’m not the first that ask you the same question (see lk n.44). Also useful could be a reference where to find how this relation is derived.

Thank you again.

Hello Karishna

I have nothing to say but you are doing very good work. I wrote my own code for BPSK-OFDM and it worked fine in AWGN channel, but when I involve the rayleigh channel (even the static single path one) my results of BER stays around 0.5. my thoughts are that I have some problem in the channel modelling as I am using the built-in matlab to build it. I will very much be grateful if you can email me to send you my code to have a look at and might suggest a better channel modelling.

with my best regards

@Abdulgader: Thanks. I have written a post on BER with flat fading Rayleigh channel in OFDM @

https://dsplog.com/2008/08/26/ofdm-rayleigh-channel-ber-bpsk/

There is one more post @

https://dsplog.com/2008/08/10/ber-bpsk-rayleigh-channel/

Hope this helps.

In your code should this line EsN0dB = EbN0dB + 10*log10(nDSC/nFFT) + 10*log10(64/80); % converting to symbol to noise ratio

be

EsN0dB = EbN0dB + 10*log10(nDSC/nFFT) + 10*log10(3.2/4); % converting to symbol to noise ratio

instead??

@santro: The result of 10*log10(64/80) and 10*log10(3.2/4) are the same, no? I just used the other one, because I assume that the sampling frequency is 20MHz, hence 3.2us = 64 samples and 4us = 80 samples.

Krishna:

If I wanted to extend your equation for Es/No = f(Eb/No) to an OFDM system with QPSK inputs, how would I do that? I’m trying to build a Matlab script that computes the BER for OFDM using QPSK but I can’t get the correct noise variance.

Thanks,

Thomas

UC San Diego

@Thomas: For QPSK, we have two bits transmitted in each constellation symbol, so Es/N0 = 2Eb/N0

Thanks krishna, this is indeed a great help to understand signal processing issues in OFDM, but I still do not understand why we need to normalize when using the FFT/IFFT or adding a term to compensate for the wasted power in CP. I really appreciate your help.

@Saria: We add all those normalizations to ensure that we define the correct Eb/N0 when obtaining the BER curves.

SO, it is not something applied in the practical signal transmission using the standard of the IEEE 802.11?

Also, in general for any modulation or multiple access scheme, when do I need to normalize and how do I determine the value of normalization factor. Really, many thanks.

@Saria: There will be normailzation factors defined based on the modulation schemes. For eq, in 802.11a spec you can see normalization used as follows:

BPSK – 1

QPSK – 1/sqrt(2)

16-QAM – 1/sqrt(10)

64-QAM – 1/sqrt(42) and so on.

I had discussed on how the normalization factor for an M-QAM modulation is derived @ https://dsplog.com/2007/09/23/scaling-factor-in-qam/

Hope this helps.

Krishna, do u have script for QPSK BER with OFDM modulation?

@said: Well, I do not have QPSK in OFDM modulation, however I do have QPSK in AWGN @

https://dsplog.com/2007/11/06/symbol-error-rate-for-4-qam/

Hope this helps.

hello sir

sir i m working on ofdm with neural network but i m not understand what input i give and what target so pleae help me sir

Hi Krishna,

i’m working hard on a project about PLC – Powerline Communications, and i need to simulate a channel PLC with OFDM, and it can be with QAM or PSK. Do you have something like that?

Congratulations about this site, it’s helping a lot to many students around the world. Thank you.

@Monique: I do not have a model of the channel in power line comunication. I have discussed BER for BPSK in OFDM with Ralyeligh multipath channel @

https://dsplog.com/2008/08/26/ofdm-rayleigh-channel-ber-bpsk/

Hope this helps.

hi krishna,

can u plz suggest me some cancellation techniques for ICI(inter carrier interference)

i’m in dire need for the matlab codes for any algorithm to cancel ICI…plz help me

@Atif: One approach is to remove the effect of frequency offset in time domain.

y(t) = x(t).*exp(j*2*pi*f_d*t), where

y(t) – is the received signal with frequency offset

x(t) – is the transmitted signal

f_d – is the frequency offset

t – is the time.

Assuming that we have an estimate of f_d, we can remove that by

r(t) = y(t)*exp(j*2*pi*-f’_d*t), where

f’_d – is the estimate of frequency offset.

HI KRISHNA

i want the codes for studying the effect of changing length of cyclic prefix on BER,Es/N,POWERPLz help me

Maria,

I think the code by Krishna is available for ofdm.

and you can take help from the code. its really very helping things from Krishna.

and one more thing … can you kindy send me the book which is free when we register? i have tried alot of times but havent received it yet … it will really nice of you

thanks

@invizible: I just the instructions over to you on email.

hi, thankyou very much for previous responses… i hope you are doing fine … i saw your above code for ofdm transmission and i made some changes i.e. doubled the cyclic prefix and then plotted the curves … but the performence was exactly the same… shouldnt it get better with increase in cyclic prefix i mean in terms of error improvement?

thanking in advance …

invizi

@invizible: Hmm… the increase in cyclic prefix wont bring you better performance in AWGN case. As you are aware, cyclic prefix does not carry any extra information. It justs serves as a buffer to prevent interference from the previous symbol in a multipath channel. So, your observation that there is no improvement with extra cyclic prefix in AWGN is correct.

hi kirshina

sorry i forgot to mension the nt term noise will be produced as usual with randn it is not zero.

second question

the normalization term you have used for the ifft

(nFFT/sqrt(nDSC))*ifft() can you give more explanation to it,if possible book or paper reference for the particular bit

thanks

@mohammed: My replies:

(1) So, are you getting zero error rate, if you force the noise term nt to 0?

(2) The term (nFFT/sqrt(nDSC)) is for normalizing the transmit power to unity.

hi krishna

in your ofdm-bpsk your for loop changes according to EbNo and doing

yt = sqrt(80/64)*xt + 10^(-EsN0dB(ii)/20)*nt;

i was trying to to keep the ebno constant say at 10db and do the following

x=real(Transmi_signal);

y=imag(Transmi_signal);

% Calculating Attenution of the signal

spow=(sum(x.^2+y.^2)./nSym./nDSC);

attn=0.5*spow/(10.^(-EbN0/10));

attn(i)=sqrt(attn);

and

yt = sqrt((Td+Tcp)/Td)*Transmi_signal + nt.*attn(i);

and i will run the programme for a number of times,but the attn. is not changing and getting almost a constant Ber graph.

any help

@mohammed: Well, if you make the noise term (nt) to zero, are you getting zero bit error?

hi krishna..

i am very new to ofdm, i have to simulate the ofdm with adding noise and etc..

can u help me in that because i am not getting start…

regards.

Maria

@maria: To avoid the effect of noise, please make the multiply the term 10^(-EsN0dB(ii)/20)*nt with 0. Further, you may also refer to the post on OFDM transmission only @

https://dsplog.com/2008/02/03/understanding-an-ofdm-transmission/

hi…do you have qpsk ber with ofdm modulation matlab coding with some explaination???

if you do could u post the url??

TQ

@keroppi: Sorry, I have not posted on BER with QPSK with OFDM.

guys i am getting a very surprising result which i wanna discuss with u people…coz its confusing me…

actually i have to make OFDM bandwidth efficient…for this purpose when i completely removed cyclic prefix(guard interval) i saw that number of bit errors increases and probabilty of error increases as well…and this is logical….but thats not the case with 54Mbps datarate…For 54Mbps when i removed the guard interval it starts showing less bit errors and data rate became improved….why happened openly for 54Mbps…Plzzzzzzz help me out why this is happening????

waiting for replies…

regards

zain

@zain: Well, no. In AWGN, the absence of cyclic prefix should not cause bit errors to increase (need to ensure that Es/No and Eb/N0 are scaled appropriately).

Dear,

I find ur work very intresting, especially the matlab implementation. Thank you for that. And now the question :

– Could u pls explain how did u connected the two formulas to become the EsNo = EbN0*(nDSC/nFFT)*(Td/(Td+Tcp)) ? Did u use the EbNo = (S/N)x(B/R) ? (S/N – SNR, B-Bandwidth, R-Bitrate).

Thank u in advance !

@Ik: The relation Eb/No = (S/N)*(B/R), is mostly tuned for single carrier systems. The underlying concept is still the same, however for OFDM, we need to consider some of the additional parameters like cylic prefix, number of used subcarriers etc.

Hope the explanation provided in the post helps.

Thanks for response. But i don’t quite get it. If u write Es = A*Ey, and Es = B*Ey then mathematically A = B. You can not just multiply those values and write Es = A*B*Ey, don’t you think ? Can you describe it mathematically how did u come to this farmula ? Thank you !

Did you find an answer to this question?

hey thanks krishna….

we add four pilot carriers modulate nothing on them and we just terminate these four carriers at reciever side…so why to waste our bandwidth by using these pilots??

why we have to use pilots???

…

can u pleez post here specifications table of IEEE802.11n as u have done above for IEEE802.11b…

THANKS…alot for helping me….i will be in touch with u for queries like that…ok

secondly can anyone tell that why we use 4 pilot carriers???

why we need them??

@ zain: Typically there will be carrier frequency offset errors, phase noise, sampling clock offset errors etc between a transmitter and receiver. The pilot subcarriers enables a receiver to estimate the phase and compensate for it, prior to data subcarrier demodulation

hi guys…im new on this site…i am doing project on OFDM..i have made OFDM simulation models on simulink for data rate 6,9,12,18,36,and 54 Mbps…now i have to made these simulations Bandwidth efficient…would u guys help0 me in this regard….one sugestion in my mind is to remove guard interval that is 16 point cyclic prefix..and to find out some technique to handle the resultion ISI…

2NDLY how to use BERTOOL with simulink models??plzz help me…

waiting for ur help…

my email address is

shooter_silent87@yahoo.com

@zain:

As you said, one way is to reduce the duration of the cyclic prefix. If I were you, I would not eliminate cyclic prefix completely, rather use a shorter value of cyclic prefix. For ex, in 802.11n specification there is short GI mode, where cyclic prefix duration is 0.4us (instead of the normal 0.8us).

Another way to improve data rate is to use to reduce the number of guard subcarriers.

Probable third way to improve data rate is to use MIMO. However that requires more than one transmit and receive antenna.

I do not have Simulink with me. Hence wont be able to help you with bertool on simulink.

Good luck.

I didnot understand how you got the final equation between Es/No and Eb/No. How you equate 20 MHz.Es = 16.25 MHz Eb?? I thing there should be equation number of easy reference.

@sandeep: This is because, the signal bandwidth is on 20MHz, however the used data subcarriers is only 16.25MHz.

If you are not comfortable using the MHz, then you may use the subcarrier count

64Es = 52*Eb.

Does that help?

Thanks for your great help.

I meant it for the first case that you answer to my second question. (not the MIMO)

Let’s say we want to implement channel coding to the system and the size of the coded bits is 60. Can we use 60 subcarriers instead of 52?

The resulting effect: is it the transmitted signal will be more likely to be interfered by other signals?

If the size of the coded bits is 104, can we divide it into 2 streams to append the cyclic prefix separately and later concatenate the 104 coded bits at the receiver?

Thank you

Thank you

@jimmy: Yes, we can send on 60 subcarriers. For the unit level BER simulations the fact that we do not have sufficient gap between spectrum from adjacent channels does not matter. This matters only when we try to deploy the system and try to meet the spectral mask requirements as put up by 802.11a specification.

If the coded bits is 104, we can use double the number of OFDM symbols to transmit the information. I hope you meant that when you said two streams? OR where you thinking of parallel transmission stream (aka MIMO)?

@jimmy: If you see the simulation model, for defining the Eb/No I have considered the wastage due to cyclic prefix and unused subcarriers. That is why the Eb/No curves are matching. If we plot the Es/No curves we will see the difference (in a simple BPSK Eb/No = Es/No).

In typical WLAN, there may be multiple transmissions happening on different frequency bands. Multiple frequency bands are separated by atleast 20MHz. If you notice, the null subcarriers are located at both edges of each band. The presence of null subcarriers on each band ensure that the energy in one band does not leak into the other band and vice versa.

Hope this helps.

Hi, in the simulation result, the performance of both cases (with and without ofdm) is the same.

For the case with ofdm, it uses 52 subcarriers. 12 subcarriers are unused and 16 subcarriers are for the cyclic prefix. The energy would be spread among both the used and unused carriers. Since there is wastage of energy, why does the performance of both cases (with and without ofdm) appear to be the same?

For the WLAN, the fft size is 64 and the used subcarrier is 52. Isn’t it better to use a larger number of subcarriers instead of wasting it?

Thank you

Hi, may i know why do we need to multiply the transmitted signal by sqrt(80/64)?

% Adding noise, the term sqrt(80/64) is to account for the wasted energy due to cyclic prefix

yt = sqrt(80/64)*xt + 10^(-EsN0dB(ii)/20)*nt;

If we include channel coding in the matlab code, the redundant bits needs to be accounted for. Is it done like the code below

% Gaussian noise of unit variance, 0 mean

nt = 1/sqrt(2*code_rate)*[randn(1,nSym*80) + j*randn(1,nSym*80)];

Thank you

@jimmy: In the simulation model, we assume that the cyclic prefix is of duration 16 samples and the data symbol is of duration 64 samples. The term sqrt(80/64) is to normalize the transmit power. This normalization ensures that scaling of noise with respect to Es/No is valid.

Yes, I think scaling of the noise by 1/sqrt(code_rate) to account for coding is correct. For eg, if coding rate is 1/2, the variance of noise is doubled as we require to send two coded bits for each data bit.

Hi, how do we add in channel coding to the matlab code?

Let’s say we want to use block codes. Can we use any size for n and k?

@jimmy: Well, it depends on the type of block code which you want to simulate. In this OFDM example, if the number of bits after coding is not coming as an integer multiple of number of bits per symbol, we can add extra zeros (which maybe ignored at the receiver).

Thank you for your reply.

I have one more question.

For the multipath channel which has tapped delay line coefficients h=[a b c], when you say making the variance of the multipath channel to unity, do you mean that |a|^2+|b|^2+|c|^2=1?

Thank you.

@roisin: Yes, normalize the average channel power over multiple channel realizations to 1.

@roisin:

(a) Yes, it should include the alphabet size. I did not include in the above equation as we were discussing BPSK case.

(b) It depends on the variance of the multipath channel. Typically, we can try to make the variance of the multipath channel to unity. Then there is no need to modify the variance in the noise term.

I used this approach for simulating BPSK BER in OFDM with 10-tap Rayleigh channel

URI: https://dsplog.com/2008/08/26/ofdm-rayleigh-channel-ber-bpsk/

Hope this helps.

Also, should there be any modifications to the addition of noise if our transmitted signal passed through a frequency selective channel? For example if our channel has tapped delay line profile (like a SUI channel) h=[1 0.3162 0.1], then the recieved signal is conv(s, h)+noise, where s is the OFDM symbol with cyclic prefix. The convolution will yield a signal with length=(fftsize+cyclic_prefix_size+length(h)-1). The noise to be added must also be a vector of this size, but what modifications must be made to the variance No, or the SNR expression?

Thank you very much.

In the code you define SNR as:

EsN0dB = EbN0dB + 10*log10(nDSC/nFFT) + 10*log10(64/80);

but should it include the additional term:

10*log10(log2(M)); where M is the alphabet size

@mohammed: It depends on the system which we have – some specifications like 802.11a has coding/interleaving etc.

In the simplest case, we can directly apply the data to the defined data subcarriers in the ifft. That is the approach which we used in the Matlab/Octave simulation model provided in this post.

Hope this helps.

@MUTHUKRISHNAN: I do not think that the following statement – “You have written the code assuming that the bits are coming at the rate of 20Mbps.” is true.

If you see, in the simulation model, I have assumed that the (a) number of data subcarriers is 52

(b) modulation is BPSK

(c) there is no coding

(d) fft size is 64

(e) cyclic prefix size is 16 samples

(f) symbol duration is 80 samples

The key to control visualize the spectrum is on the assumption of sampling frequency of the fft. If the fft is operating at a frequency fs, then the symbol duration in the above system is 80/fs. The data rate is 52/(80/fs). If fs is assumed to be 20MHz, then the data rate is 13Mbps, Do you agree?

You can use pwelch() command to plot the spectrum of an OFDM packet consisting of multiple OFDM symbols. The Matlab/Octave script in the following URI might be helpful.

Understanding an OFDM transmission

https://dsplog.com/2008/02/03/understanding-an-ofdm-transmission/

Hope this helps.

i am using ifft size 64,for 52 subcarriers

hi krishna

i am trying to simulate ofdm with bpsk.i was able to get the +1 -1 signs.what do i need to do before applying this out put to IFFT.

thanks for your help before hand

Hi,

I saw your code for OFDM transmitter. You have written the code assuming that the bits are coming at the rate of 20Mbps. Is there a way to write a MATLAB script that will simulate a random bit generator at 20MHz using RAND function or should we only go to simulink for that? I would like to see the spectrum of the OFDM symbols for an random input of 20MHZ. though we can plot the spectrum by taking the x-axis as Fs*(-N/2:1:N/2)/N, it would only be to visulaise the plot.

Can you give me a hint on that?

Thank you.

Bye.

@victor: Yes, it can be. However, I do expect coding/debugging to be take more time in C++.

thank’s…can it made using another methode?except matlab.haw about C++.

@Moayid: Thanks for the comment. However, may I suggest I would prefer to help you debug (than debugging the code myself).

I think, to keep things simple, firsly you should try

(a) with out adding noise

(b) before moving to bit error rate, maybe its simpler to find symbol error rate.

(c) Once you get the symbol error rate curve correct, then one may move to bit error rate.

The following posts on 16QAM maybe helpful.

URI: https://dsplog.com/2007/12/09/symbol-error-rate-for-16-qam/

URI: https://dsplog.com/2008/06/05/16qam-bit-error-gray-mapping/

Hope this helps.

@Hussien: Typically for channel estimation, we send a known sequence (called preamble). Using the knowledge of the known sequence and what we received, we can estimate the channel.

For eg, in an OFDM system, the system model can be written as

Y = HX + N where

Y – is the received symbol on subcarrier k

H – is the channel on subcarrier k

X – is the transmitted symbol on subcarrier k

N – is the noise on subcarrier k

Since X is known, the estimate of H is,

H^ = Y/X

For synchronization, different aspects need to addressed:

(a) Frequency synchronization – You can find an example of frequency offset estimation in 802.11a system at

https://dsplog.com/2008/03/03/frequency-offset-estimation-using-80211a-short-preamble/

(b) Time synchronization – Aligning the symbol boundary

(c) Sampling clock offset tracking

etc

Hi Krishna,

Thank you very much for your matlab script. I’m trying BER for OFDM using 16QAM, but I dont know what is Wrong in my code?! here is my code:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% BER for OFDM using 16QAM Modulation

clear all

close all;

clc;

M = 16; % number of QAM constellation points (4,16,64,256)

nFFT = 64; % fft size

nDSC = 52; % number of data subcarriers

Td = 64; % Data Symbol Duration

Tcp = 16; % cylic prefix Duration (GI=1/4)

nBitPerSym = 52; % number of bits per OFDM symbol (same as the number of subcarriers for BPSK)

nSym = 10^4; % number of symbols

k = log2(M); % bits per symbol

EbN0dB = [0:16]; % bit to noise ratio

EsN0dB = EbN0dB + 10*log10(nDSC/nFFT) + 10*log10(64/80)+ 10*log10(k); % converting to EsNo (EsN0 = EbN0*(nDSC/nFFT)*(Td/(Td+Tcp))

% OFDM

for ii = 1:length(EbN0dB)

% Transmitter

%data Generation

ipBit = randint(1,nBitPerSym*nSym,M);

%Data Modulation

ipMod = (1/sqrt(10))*qammod(ipBit,M); % 16QAM modulation

tx = ipMod;

% S/P

ipMod = reshape(ipMod,nBitPerSym,nSym).’; % grouping into multiple symbolsa

% Assigning modulated symbols to subcarriers from [-26 to -1, +1 to +26] (zeros padding)

xF = [zeros(nSym,6) ipMod(:,[1:nBitPerSym/2]) zeros(nSym,1) ipMod(:,[nBitPerSym/2+1:nBitPerSym]) zeros(nSym,5)] ;

% Taking IFFT, 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];

% P/S

xt = reshape(xt.’,1,nSym*80);

% Generation Gaussian noise of unit variance, 0 mean

nt = 1/sqrt(2)*[randn(1,nSym*80) + j*randn(1,nSym*80)];

% Adding noise, the term sqrt(80/64) is to account for the wasted energy due to cyclic prefix

yt = sqrt(80/64)*xt + 10^(-EsN0dB(ii)/20)*nt;

yts = sqrt(80/64)*xt + 10^(-EsN0dB(ii)/20)*nt;

% Receiver

% S/P

yt = reshape(yt.’,80,nSym).’;

% removing cyclic prefix

yt = yt(:,[17:80]);

% Taking FFT (converting to frequency domain)

yF = (sqrt(nDSC)/nFFT)*fftshift(fft(yt.’)).’;

% zero removal

yMod = yF(:,[6+[1:nBitPerSym/2] 7+[nBitPerSym/2+1:nBitPerSym] ]);

rx = reshape(yMod,1,520000);

% 16QAM Demodulation

ipBitHat = qamdemod(yMod*sqrt(10),M); % rxData =qamdemod(rxDataMod*sqrt(10),M);

% P/S

ipBitHat = reshape(ipBitHat.’,nBitPerSym*nSym,1).’;

% counting the errors

nErr(ii) = size(find(ipBit – ipBitHat),2);

end

simBer = nErr/(nSym*nBitPerSym);

theoryBer = (1/k)*3/2*erfc(sqrt(k*0.1*(10.^(EbN0dB/10))));

figure (1)

semilogy(EbN0dB,theoryBer,’ms-‘,’LineWidth’,2,’MarkerSize’,5);

hold on

semilogy(EbN0dB,simBer,’bx-‘,’LineWidth’,2,’MarkerSize’,5);

axis([0 16 10^-5 1]);

grid on

legend(‘theory’, ‘simulation’);

xlabel(‘Eb/No, dB’)

ylabel(‘Bit Error Rate’)

title(‘Bit error probability curve for 16QAM using OFDM’)

hold off

%####################

Regards

Moayid

Hi Krishna

One more thing: Iām looking for MATLAB code for channel estimation and synchronization for OFDM system.

@Hussein: Thanks. I do not have the codes, but I would think that it will be reasonable to extend the available simulation models to 16QAM case.

For 16-QAM in AWGN (without OFDM) you may look at the posts,

URI: https://dsplog.com/2008/06/05/16qam-bit-error-gray-mapping/

URI: https://dsplog.com/2007/12/09/symbol-error-rate-for-16-qam/

For extending them to OFDM, you may use the following posts as reference:

https://dsplog.com/2008/06/10/ofdm-bpsk-bit-error/

https://dsplog.com/2008/08/26/ofdm-rayleigh-channel-ber-bpsk/

Hope this helps.

Hi Krishna

thank you very much for Your simulation and theory prgram, really they are very useful. Do you have the matlab code for OFDM with 16-QAM in AWGN and Rayleigh Channels.

Best Regards

Hussien

@Lealem : I have not yet written any posts on Trellis coded modulation. I hope to do so in future (maybe within couple of months).

Hello! Krishna

Thank you! for ur help . But now i have got a problem when i wrote a matlab code to simulate the BER performance of a trellis coded OFDM ( OFDM with trellis coded Modulation) and i can’t get a proper result . Please try to help me by sending a Matlab code to simulate OFDM with TCM.

Thank you in advance

Lealem

@ravi kumar:

As you can see, there is no difference in Eb/No vs BER plot provided for ‘BPSK in AWGN’ and ‘BPSK over OFDM in AWGN’.

As I have stated prior, in AWGN there is no performance improvement/loss by doing OFDM modulation. However, in multipath channel, when using a properly designed OFDM, the equalization becomes simpler.

A good book to read is OFDM Wireless LANs: A Theoretical and Practical Guide by Juha Heiskala , John Terry

hi, KRISHNA

can u explain me the main difference of simulation results between the BPSK and BPSK with OFDM.What are the main factors that will effect the BER,and in which of the two two systems the BER performance is good,please help me as soon as possible because my project submission last date is 30th Sep., and what are the referances i have to read to understand this project.I hopefully waiting for your response,thank you

@tariq: Well, I was unable to understand your concern. In the next line,

ipMod = 2*ipBit-1; % BPSK modulation 0 –> -1, 1 –> +1

the random binary data is converted to +1’s and -1’s respectively for binary 1 and binary 0.

Agree? OR where you looking for something else?

dear , thank you very much

can i use not rand binary data in line 9 in the script

i mean i have data positive and negative and want to put it instead of binary random data ,

so please i want your help in solving this problem , because i try to put this data but failed to run .

regards

traiq

Hello! Kirishna ur matlab script is very help full to simulate an OFDM over AWGN channel using BPSK and also other modulation scheme.Can u forward me a matlab script that can be used to simulate performance of BPSK modulated OFDM with a combination of TCM(Trellis coded Modulation)over a fading channel.

Hope fully u will