# Simulation of OFDM system in Matlab – BER Vs Eb/N0 for OFDM in AWGN channel

(9 votes, average: 4.67 out of 5)

This article is a part of the ebook : Simulation of digital communication systems using Matlab – available in both PDF and EPUB format.

To simulate an OFDM system, following design parameters are essential. Lets consider the OFDM system parameters as defined in IEEE 802.11[1] specifications

Given parameters in the spec:
N=64; %FFT size or total number of subcarriers (used + unused) 64
Nsd = 48; %Number of data subcarriers 48
Nsp = 4 ; %Number of pilot subcarriers 4
ofdmBW = 20 * 10^6 ; % OFDM bandwidth

Derived Parameters:
deltaF = ofdmBW/N; % Bandwidth for each subcarrier – include all used and unused subcarries
Tfft = 1/deltaF; % IFFT or FFT period = 3.2us
Tgi = Tfft/4; % Guard interval duration – duration of cyclic prefix – 1/4th portion of OFDM symbols
Tsignal = Tgi+Tfft; % Total duration of BPSK-OFDM symbol = Guard time + FFT period
Ncp = N*Tgi/Tfft; %Number of symbols allocated to cyclic prefix
Nst = Nsd + Nsp; % Number of total used subcarriers
nBitsPerSym=Nst; %For BPSK the number of Bits per Symbol is same as number of subcarriers

We will use the following model for simulating the OFDM system.

The channel in this case is modeled as a simple AWGN channel. Since the channel is considered to be an AWGN channel, there is no need for the frequency domain equalizer in the OFDM receiver ( Frequency domain equalizer will be helpful only if the channel introduces multipath fading). Since our channel is an AWGN channel, the frequency domain equalizer block in the above diagram can be removed.

### Calculating Es/N0 or Eb/N0 for OFDM system:

In order to do a Monte Carlo simulation of an OFDM system, required amount of channel noise has to be generated that is representative of required Eb/N0. In Matlab it is easier to generate a Gaussian noise with zero mean and unit variance. The generated zero-mean-unit-variance noise has to be scaled accordingly to represent the required Eb/N0 or Es/N0. If we have Es/N0, the required noise can be generated from zero-mean-unit-variance-noise by,

$$required\;noise = 10^{-\frac{E_s}{N_0} \frac{1}{20}} \times noise$$

Since the OFDM system transmits and received the data in symbols, it is appropriate/easier to generate required noise based on Es/N0 instead of Eb/N0 (as given above). But we are interested in plotting BER against Eb/N0. Ok!!! Then… how do we convert given Eb/N0 to Es/N0 for an OFDM system ?

Normally for a simple BPSK system, bit energy and symbol energy are same. So Eb/N0 and Es/N0 are same for a BPSK system. But for a OFDM BPSK system, they are not the same. This is because, each OFDM symbol contains additional overhead in both time domain and frequency domain. In the time domain, the cyclic prefix is an additional overhead added to each OFDM symbol that is being transmitted. In the frequency domain, not all the subcarriers are utilized for transmitted the actual data bits, rather a few subcarriers are unused and are reserved as guard bands.

### Effect of Cyclic Prefix on Es/N0:

The following diagram illustrates the concept of cyclic prefix. Each OFDM symbol contains both useful data and overhead (in the form of cyclic prefix). The bit energy represents the energy contained in the useful bits. In this case, the bit energy is spread over N bits (where N is the FFT size). On top of the useful data, additional Ncp bits are added as cyclic prefix, which forms the overhead. So if the entire OFDM symbol is considered, the symbol energy is spread across N+Ncp bits.

This relationship is given as

$$Es(N+N_{cp})=NE_{b}$$

which translates to,

$$E_{s}=\frac{N}{N+N_{cp}}E_{b} \;\;\;\;\;\;\;\; (1)$$

### Effect of unused subcarriers on Es/N0:

As mentioned earlier, not all the subcarriers are used for transmission. Out of the total N subcarriers, only Nst carriers are used for OFDM symbols transmission (this includes both data and pilot subcarriers). Again, in the frequency domain, the useful bit energy is spread across Nst subcarriers, whereas the symbol energy is spread across N subcarriers. This gives us another relationship between Es and Eb as given below

$$E_{s}\times {N}=N_{st}\times E_{b}$$

which translates to,

$$E_{s}=\frac{N_{st}}{N}\times E_{b} \;\;\;\;\;\;\;\;(2)$$

From (1) and (2), the overall effect of both cyclic prefix and unused subcarriers on Es/N0 is given by

$$\frac{E_{s}}{N_{0}}=\left ( \frac{N}{N_{cp}+N} \right )\left ( \frac{N_{st}}{N} \right )\frac{E_{b}}{N_{0}} \;\;\;\;\;\;\;\;(3)$$

which, when converted to dB yields the following relationship.

$$\left (\frac{E_{s}}{N_{0}}\right )_{dB}=\left ( \frac{N}{N_{cp}+N} \right )_{dB}+\left ( \frac{N_{st}}{N} \right )_{dB}+\left( \frac{E_{b}}{N_{0}}\right)_{dB} \;\;\;\;\;\;\;\;(4)$$

Since Ncp cylic prefix are added to the OFDM symbol, the output signal from the parallel to serial converter has to be boosted to compensate for the wastage of energy associated with the addition of cyclic prefix. To properly generate the required SNR in Matlab, the signal term at the output of the parallel to serial converter has to be scaled as follows

$$Boosted\;OFDM\;signal = \sqrt{\frac{N_{cp}+N}{N}}\times OFDM\;signal$$

The received signal is represented as (for the given Eb/N0)

$$y = boosted \; OFDM \; signal + required \; noise$$

### Arrangement of subcarriers:

The IEEE 802.11 specification, specifies how to arrange the given subcarriers. The 52 used subcarriers (data + pilot) are assigned numbers from -26,-25,…-2,,-1 and 1,2,…,25,26. The following figure illustrates the scheme of assigning these subcarriers to the IFFT inputs.

### Simulation:

Check this book for full Matlab code.
Simulation of Digital Communication Systems Using Matlab – by Mathuranathan Viswanathan

### Simulated Result:

From the simulated result, it can be ascertained that the OFDM- BPSK modulation has no advantage over a normal BPSK system in AWGN. OFDM proves to be effective in multipath environments.

# Introduction to OFDM – orthogonal Frequency division multiplexing – part 4 – Cyclic Prefix

(5 votes, average: 4.00 out of 5)

Consider a non-ideal channel h(t)≠δ(t), that causes delay dispersion. Delay dispersion manifests itself as Inter Symbol Interference (ISI)on each subcarrier channel due to pulse overlapping. It will also cause ICC (Inter Carrier Interference ) due to the non-orthogonality of the received signal. Adding cyclic prefix to each OFDM symbol mitigates the problems of ISI and ICC by removing them altogether.

Lets say, without cyclic prefix we transmit the following N values (N=Nfft=length of FFT/IFFT) for a single OFDM symbol.

$$X_0,X_1,X_2,…,X_{N-1}$$

Lets consider a cyclic prefix of length Ncp, ( where Ncp<N ), is formed by copying the last Ncp values from the above vector of X and adding those Ncp values to the front part of the same X vector.With a cyclic prefix length Ncp, ( where Ncp<N ), the following values constitute a single OFDM symbol :

If T is the duration of the an OFDM symbol in secs, due to the addition of cyclic prefix of length Ncp, the total duration of an OFDM symbol becomes T+Tcp, where Tcp=Ncp*T/N. Therefore, the number of samples allocated for cyclic prefix can be calculated as Ncp=Tcp*N/T, where N is the FFT/IFFT length, T is the IFFT/FFT period and Tcp is the duration of cyclic prefix.

### The key ideas behind adding cyclic prefix :

1) Convert linear convolution in to circular convolution which eases the process of detecting the received signal by using a simple single tap equalizer
If you wish to know how the addition of cyclic prefix converts linear convolution to circular convolution, visit this link
2) Help combat ISI and ICC.

When a cyclic prefix of length Ncp is added to the OFDM symbol, the output of the channel (r) is given by circular convolution  of channel impulse response (h) and the OFDM symbols with cyclic prefix (x).

$$r=h \circledast x$$

As we know, for the discrete signals, circular convolution in the time domain translates to multiplication in the frequency domain.Thus, in frequency domain, the above equation translates to

$$R=HX$$

At the receiver, R is the received signal (in Frequency domain) and our goal is to estimate the transmitted signal (X) from the received signal R. From the above equation, the problem of detecting the transmitted signal at the receiver side translate to a simple equalization equation as follows

$$\hat{X}= \frac{R}{H}$$

After the FFT performed at the receiver side (i.e. after the FFT block in the receiver side), a single tap equalizer (which essentially implements the above equation) is used to estimate the transmitted OFDM symbol. It also corrects the phase and equalizes the amplitude.

A basic OFDM architecture with Cyclic Prefix is given below. (In the following diagram, symbols represented by small case letters are assumed to be in time domain, whereas the symbols represented by uppercase letters are assumedto be in frequency domain)

The IEEE specs specify the length of the Cyclic prefix in terms of its duration.
Lets see how to convert the specified duration (Tcp) in to actual number of samples assigned for cyclic prefix (Ncp).

Lets see an example of deriving Ncp from IEEE 802.11 spec [1]

# Introduction to OFDM – orthogonal Frequency division multiplexing – part 3

(5 votes, average: 4.80 out of 5)

In the previous article, the architecture of an OFDM transmitter was described using sinusoidal components. Generally, an OFDM signal can be represented as

$$OFDM\; signal = c(t)=\sum_{n=0}^{N-1}s_{n}(t)sin(2\pi f_{n}t )$$

$$s(t)$$ = symbols mapped to chosen constellation (BPSK/QPSK/QAM etc..,)

$$F_n$$ = orthogonal frequency

This equation can be thought of as an IFFT process ( Inverse Fast Fourier Transform). The Fourier transform breaks a signal into different frequency bins by multiplying the signal with a series of sinusoids. This essentially translates the signal from time domain to frequency domain. But, we always view IFFT as a conversion process from frequency domain to time domain.

FFT is represented by

$$X(k)=\sum_{n=0}^{N-1}x(n)sin(\frac{2\pi kn}{N})+j\sum_{n=0}^{N-1}x(n)cos(\frac{2\pi kn}{N})$$

where as its dual , IFFT is given by

$$x(n)=\sum_{n=0}^{N-1}X(k)sin(\frac{2\pi kn}{N})-j\sum_{n=0}^{N-1}X(k)cos(\frac{2\pi kn}{N})$$

The equation for FFT and IFFT differ by the co-efficients they take and the minus sign. Both equation does the same thing. They multiply the incoming signal with a series of sinusoids and separates them into bins.In fact, FFT and IFFT are dual and behaves in a similar way.IFFT and FFT blocks are interchangeable.

Since the OFDM signal ( c(t) in the equation above ) is in time domain, IFFT is the appropriate choice to use in the transmitter, which can be thought of as converting frequency domain samples to time domain samples. Well, you might ask : s(t) is not in frequency domain and they are already in time domain; so whats the need to convert it into time domain again ? The answer is IFFT/FFT equation comes handy in implementing the conversion process and we can eliminate the individual sinusoidal multipliers required in the transmitter/receiver side. The following figure illustrates, how the use of IFFT in the transmitter eliminates the need for separate sinusoidal converters. Always remember that IFFT and FFT blocks in the transmitter are interchangeable as long as their duals are used in receiver.

The entire architecture of a basic OFDM system with both transmitter and receiver will look like this

An OFDM system is defined by IFFT/FFT length – N ,the underlying modulation technique ( BPSK/QPSK/QAM), supported data rate, etc..,. The FFT/IFFT length N defines the number of total subcarriers present in the OFDM system. For example, an OFDM system with N=64 provides 64 subcarriers. In reality, not all the subcarriers are utilized for data transmission. Some subcarriers are reserved for pilot carriers (used for channel estimation/equalization and to combat magnitude and phase errors in the receiver) and some are left unused to act as guard band. OFDM system do not transmitany data on the subcarriers that are near the two ends of the transmission band ( Not necessarily at the ends of the bands, implementation may differ). These subcarriers are collectively called guard band. The reservation of subcarriers to guard bands helps to reduce the out of band radiation and thus eases the requirements on transmitter front-end filters.The subcarriers in the guard band are also called Null subcarriers or virtual subcarriers.

For example IEEE 802.11 standard[1] specifies the following parameters for its OFDM physical layer.

FFT/IFFT size = 64 ( implies 64 subcarriers in total = used + unused = Nfft)

Number of data subcarriers = 48 ( Nd)

Number of pilot subcarriers = 4 (Np)

Derived parameters from the above specification.

Number of total USED subcarriers = 52 ( Nu = Nd+ Np )

Number of total UNUSED subcarriers = 12 ( Nun = Nfft – Nu ).

According to the spec, these 52 used subcarriers are distributed in the following way. The 52 used subcarriers are named as 1,2,3,…,26 and -1,-2,-3,…,-26. The used subcarriers 1 to 26 are mapped to 1 to 26 of IFFT inputs and the subcarriers -1,-2,..,-26 are mapped to the IFFT inputs 38 to 63. The remaining IFFT inputs 27 to 37 and the input 0 (dc input) are set to 0 .In this manner the 12 null subcarriers are mapped to IFFT inputs.

Full Matlab Code available at Simulation of Digital Communication Systems using Matlab – an ebook by Mathuranathan Viswanathan

# Introduction to OFDM – orthogonal Frequency division multiplexing

(12 votes, average: 4.42 out of 5)

This post is a part of the ebook : Simulation of digital communication systems using Matlab – available in both PDF and EPUB format.

In modulations, information is mapped on to changes in frequency, phase or amplitude (or a combination of them) of a carrier signal. Multiplexing deals with allocation/accommodation of users in a given bandwidth (i.e. it deals with allocation of available resource).
OFDM is a combination of modulation and multiplexing. In this technique, the given resource (bandwidth) is shared among individual modulated data sources. Normal modulation techniques (like AM, PM, FM, BPSK, QPSK, etc.., ) are single carrier modulation techniques, in which the incoming information is modulated over a single carrier. OFDM is a multicarrier modulation technique, which employs several carriers, within the allocated bandwidth, to convey the information from source to destination. Each carrier may employ one of the several available digital modulation techniques (BPSK, QPSK, QAM etc..,).

### Difference between FDM and OFDM:

OFDM is a special case of FDM ( Frequency Division Multiplexing). In FDM, the given bandwidth is subdivided among a set of carriers. There is no relationship between the carrier frequencies in FDM. For example, consider that the given bandwidth has to be divided among 5 carriers (say a,b,c,d,e). There is no relationship between the subcarriers ; a,b,c,d and e can anything within the given bandwidth.

If the carriers are harmonics, say (b=2a,c=3a,d=4a,d=5a , integral multiple of fundamental component a ) then they become orthogonal. This is a special case of FDM, which is called OFDM (as implied by the word – ‘orthogonal’ in OFDM)

### Designing OFDM Transmitter:

Consider that we want to send the following data bits using OFDM : D = {d0,d1,d2,…). The first thing that should be considered in designing the OFDM transmitter is the number of subcarriers required to send the given data. As a generic case, lets assume that we have N subcarriers. Each subcarriers are centered at frequencies that are orthogonal to each other (usually multiples of frequencies).

The second design parameter could be the modulation format that we wish to use. An OFDM signal can be constructed using anyone of the following digital modulation techniques namely BPSK, QPSK, QAM etc..,
The data (D) has to be first converted from serial stream into parallel stream depending on the number of sub-carriers (N). Since we assumed that there are N subcarriers allowed for the OFDM transmission, we name the subcarriers from 0 to N-1. Now, the Serial to Parallel converter takes the serial stream of input bits and outputs N parallel streams (indexed from 0 to N-1). These parallel streams are individually converted into the required digital modulation format (BPSK, QPSK, QAM etc..,). Lets call this output S0,S1,..SN. The conversion of parallel data (D) into the digitally modulated data (S) is usually achieved by a constellation mapper, which is essentially a look up table (LUT). Once the data bits are converted to required modulation format, they need to be superimposed on the required orthogonal subcarriers for transmission. This is achieved by a series of N parallel sinusoidal oscillators tuned to N orthogonal frequencies (f0,f1,…fN-1). Finally, the resultant output from the N parallel arms are summed up together to produce the OFDM signal.

The following figure illustrates the basic concept of OFDM transmission (note: In order to give a simple explanation to illustrate the underlying concept,the usual IFFT/FFT blocks that are used in actual OFDM system, are not used in the block diagram) .

### Example:

The first example illustrates the concept of OFDM transmission with BPSK modulation as its underlying modulation format. The second example illustrates the OFDM transmission with pi/4 shifted QPSK modulation. Here 5 orthogonal subcarriers are assumed for the OFDM transmission.