Tag Archives: OFDM

BER for BPSK-OFDM in Frequency Selective Channel

OFDM Tx-Rx Block Diagram

As the data rates supported by wireless networks continue to rise the bandwidth requirements also continue to increase (although spectral efficiency has also improved). Remember GSM technology which supported 125 channels of 200KHz each, which was further divided among eight users using TDMA. Move on to LTE where the channel bandwidth could be as high as 20MHz (1.4MHz, 3MHz, 5MHz, 10MHz, 15MHz and 20MHz are standardized).

This advancement poses a unique challenge referred to as frequency selective fading. This means that different parts of the signal spectrum would see a different channel (different amplitude and different phase offset). Look at this in the time domain where the larger bandwidth means shorter symbol period causing intersymbol interference (as time delayed copies of the signal overlap on arrival at the receiver).

The solution to this problem is OFDM that divides the wideband signal into smaller components each having a bandwidth of a few KHz. Each of these components experiences a flat channel. To make the task of equalization simple a cyclic prefix (CP) is added in the time domain to make the effect of fading channel appear as circular convolution. Thus simplifying the frequency domain equalization to a simple division operation.

Shown below is the Python code that calculates the bit error rate (BER) of BPSK-OFDM which is the same as simple BPSK in a Rayleigh flat fading channel. However there is a caveat. We have inserted a CP which means we are transmitting more energy than simple BPSK. To be exact we are transmitting 1.25 (160/128) times more energy. This means that if this excess energy is accounted for the performance of BPSK-OFDM would be 1dB (10*log10(1.25)) worse than simple BPSK in Rayleigh flat fading channel.

Note:

  1. Although we have shown the channel as a multiplicative effect in the figure above, this is only true for a single tap channel. For a multi-tap channel (such as the one used in the code above) the effect of the channel is that of a filter which performs convolution operation on the transmitted signal.
  2. We have used a baseband model in our simulation and the accompanying figure. In reality the transmitted signal is upconverted before transmission by the antennas.
  3.  The above model can be easily modified for any modulation scheme such as QPSK or 16-QAM. The main difference would be that the signal would have a both a real part and an imaginary part, much of the simulation would remain the same. This would be the subject of a future post. For a MATLAB implementation of 64-QAM OFDM see the following post (64-QAM OFDM).
  4. Serial to parallel and parallel to serial conversion shown in the above figure was not required as the simulation was done symbol by symbol (one OFDM symbol in the time domain represented 128 BPSK symbols in the frequency domain).
  5. The channel model in the above simulation is quasi-static i.e. it remains constant for one OFDM symbol but then rapidly changes for the next, without any memory.

Shannon Capacity CDMA vs OFDMA

We have previously discussed Shannon Capacity of CDMA and OFMDA, here we will discuss it again in a bit more detail. Let us assume that we have 20 MHz bandwidth for both the systems which is divided amongst 20 users. For OFDMA we assume that each user gets 1 MHz bandwidth and there are no guard bands or pilot carriers. For CDMA we assume that each user utilizes full 20 MHz bandwidth. We can say that for OFDMA each user has a dedicated channel whereas for CDMA the channel is shared between 20 simultaneous users.

We know that Shannon Capacity is given as

C=B*log2(1+SNR)

or in the case of CDMA

C=B*log2(1+SINR)

where ‘B’ is the bandwidth and SINR is the signal to noise plus interference ratio. For OFDMA the SNR is given as

SNR=Pu/(B*No)

where ‘Pu’ is the signal power of a single user and ‘No’ is the Noise Power Spectral Density. For CDMA the calculation of SINR is a bit more complicated as we have to take into account the Multiple Access Interference. If the total number of users is ‘u’ the SINR is calculated as

SINR=Pu/(B*No+(u-1)*Pu)

The code given below plots the capacity of CDMA and OFDMA as a function of Noise Power Spectral Density ‘No’.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% CAPACITY OF CDMA and OFDMA
% u - Number of users
% Pu - Power of a single user
% No - Noise Power Spectral Density
%
% Copyright RAYmaps (www.raymaps.com)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

clear all
close all

u=20;
Pu=1;
No=1e-8:1e-8:1e-6;

B=20e6;
C_CDMA=u*B*log2(1+Pu./(B*No+(u-1)*Pu));

B=1e6;
C_OFDMA=u*B*log2(1+Pu./(B*No));

plot(No,C_CDMA/1e6);hold on
plot(No,C_OFDMA/1e6,'r');hold off
xlabel('Noise Power Spectral Density (No)')
ylabel('Capacity (Mbps)')
legend('CDMA','OFDMA')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Shannon Capacity of CDMA and OFDMA
Shannon Capacity of CDMA and OFDMA

We see that the capacity of OFDMA is much more sensitive to noise than CDMA. Within the low noise region the capacity of OFDMA is much better than CDMA but as the noise increases the capacity of the two schemes converges. In fact it was seen that as the noise PSD is further increased the two curves completely overlap each other. Therefore it can be concluded that OFDMA is the preferred technique when we are operating in the high SNR regime.

Udemy Course

• In this course you will learn the basic principles of wireless communications from 1G to 4G and beyond. You will learn about frequency reuse, capacity, channel coding, modulation and demodulation, OFDM, MIMO and host of other topics.

• This course is for you if you are a student and have just started learning about wireless communications or if you are a guy in the field who wants to get a better handle on the fundamental concepts of wireless communications.

Here is the link to the course.

 

Does Shannon Capacity Increase by Dividing a Frequency Band into Narrow Bins

Somebody recently asked me this question “Does Shannon Capacity Increase by Dividing a Frequency Band into Narrow Bins”. To be honest I was momentarily confused and thought that this may be the case since many of the modern Digital Communication Systems do use narrow frequency bins e.g. LTE. But on closer inspection I found that the Shannon Capacity does not change, in fact it remains exactly the same. Following is the reasoning for that.

Shannon Capacity is calculated as:

C=B*log2(1+SNR)

or

C=B*log2(1+P/(B*No))

Now if the bandwidth ‘B’ is divided into 10 equal blocks then the transmit power ‘P’ for each block would also be divided by 10 to keep the total transmit power for the entire band to be constant. This means that the factor P/(B*No) remains constant. So the total capacity for the 10 blocks would be calculated as:

C=10*(B/10)*log2(1+P/(B*No))

So the Shannon Capacity for the entire band remains the same.

PS: The reason for the narrower channels is that for a narrow channel the channel appears relatively flat in the frequency domain and the process of equilization is thus simplified (a simple multiplication/division would do).

Note: ‘No’ is the Noise Power Spectral Density and ‘B*No’ is the Noise Power.

Fast Fourier Transform – Code

Most of us have used the FFT routine in MATLAB. This routine has become increasingly important in simulation of communication systems as it is being used in Orthogonal Frequency Division Multiplexing (OFDM) which is employed in 4G technologies like LTE and WiMAX. We would not go into the theoretical details of the FFT, rather, we would produce the MATLAB code for it and leave the theoretical discussion for a later time.

The underlying technique of the FFT algorithm is to divide a big problem into several smaller problems which are much easier to solve and then combine the results in the end.

%%%%% INITIALIZATION %%%%%
clear all
close all

fm=100;
fs=1000;
Ts=1/fs;
nn=1024;
isign=1;

t=0:Ts:(nn-1)*Ts;

x_c=exp(1i*2*pi*fm*t);
x(1:2:2*nn-1)=imag(x_c);
x(2:2:2*nn)=real(x_c);

%%%%% BIT REVERSAL %%%%%
n=2*nn;
j=1;
for i=1:2:n-1
    if(j>i)
        temp=x(j);
        x(j)=x(i);
        x(i)=temp;

        temp=x(j+1);
        x(j+1)=x(i+1);
        x(i+1)=temp;
    end
    m=nn;
    while (m >= 2 && j > m)
        j=j-m;
        m=m/2;
    end
    j=j+m;
end

%%%%% DANIELSON-LANCZOS ALGO %%%%%
mmax=2;
while (n > mmax)
    istep=2*mmax;
    theta=isign*(2*pi/mmax);
    wtemp=sin(0.5*theta);
    wpr=-2*wtemp*wtemp;
    wpi=sin(theta);
    wr=1.0;
    wi=0.0;
    for m=1:2:mmax-1
        for i=m:istep:n
            j=i+mmax;
            tempr=wr*x(j)-wi*x(j+1);
            tempi=wr*x(j+1)+wi*x(j);
            x(j)=x(i)-tempr;
            x(j+1)=x(i+1)-tempi;
            x(i)=x(i)+tempr;
            x(i+1)=x(i+1)+tempi;
        end
        wtemp=wr;
        wr=wr*wpr-wi*wpi+wr;
        wi=wi*wpr+wtemp*wpi+wi;
    end
mmax=istep;
end
F=x(2:2:n)+1i*x(1:2:n-1);
plot((0:fs/(nn-1):fs),abs(F))

In the above example we have calculated an ‘nn’ point complex FFT of an ‘nn’ point complex time domain signal. The algorithm takes the input in a special arrangement where the ‘nn’ point complex input signal is converted into ‘2*nn’ real sequence where the imaginary components are placed in odd elements and real components are placed in even elements of the input sequence. A similar arrangement works for the output sequence.

Shown below is the FFT of a complex exponential with a frequency of 100 Hz. The plot is shown from 0Hz to 1000 Hz which is the sampling frequency. A signal with multiple frequencies would have to be passed through a Low Pass Filter (LPF) so that the signal components above 500 Hz (fs/2) are filtered out. When the FFT of a real signal is performed an image frequency is produced between 500 Hz to 1000 Hz.

Fast Fourier Transform of a Complex Exponential
Fast Fourier Transform of a Complex Exponential

Here we have discussed the case of complex input sequence. Simplifications can be made for a real sequence or for special signals such as pure sine and cosine waves. We will discuss these in later posts.

 [1] Numerical Recipes in C, The Art of Scientific Computing, Cambridge University Press.

Detecting Sinusoids in Noise

We have previously discussed the problem of detecting two closely spaced sinusoids using the Discrete Fourier Transform (DFT). We assumed that the data set we got was pure i.e. there was no noise. However, in reality this is seldom the case. There is always some noise, corrupting the signal. Let us now see how it effects the detection problem.

We consider Additive White Gaussian Noise (AWGN) as the corrupting source. The noise power is set equal to the power of the two sinusoids i.e. we have an SNR of 0 dB. This is quite a severe case, the noise power is usually a few dB below the signal power. We are also bounded by the number of samples, N=64, giving us a resolution of 15.87 Hz.

clear all
close all

fm1=100;
fm2=120;
fs=1000;
Ts=1/fs;
N=64;
t=0:Ts:(N-1)*Ts;

x1=sqrt(2)*cos(2*pi*fm1*t);
x2=sqrt(2)*cos(2*pi*fm2*t);
wn=randn(1,N);
x=x1+x2+wn;
W=exp(-j*2*pi/N);

n=0:N-1;
k=0:N-1;

X=x*(W.^(n'*k));

plot(k/N,20*log10(abs(X)))
xlabel ('Normalized Frequency')
ylabel ('X(dB)')

The data is plotted on a logarithmic scale so that we can compare the signal and noise  power levels.

DFT of Two Tones in Noise
DFT of Two Tones in Noise

It is observed that we still have two peaks around the required frequency bins but there are also a number of false peaks. These peaks are around 10 dB lower than the signal peaks and should not cause a false detection. So the signal to noise ratio of 0 dB in the time domain is translated to a signal to noise ratio of about 10 dB in the frequency domain (this can be realized using an appropriate filter).

Resolution of Discrete Fourier Transform

In the previous post we had introduced the Discrete Fourier Transform (DFT) as a method to perform the spectral analysis of a time domain signal. We now discuss an important property of the DFT, its spectral resolution i.e. its ability to resolve two signals with similar spectral content.

Initially one might think that increasing the sampling frequency would increase the spectral resolution but this totally incorrect. In fact if the sampling frequency is increased, keeping the number of time domain samples to be the same, the resolution actually decreases. So how do we calculate the spectral resolution. One simple way is to calculate the difference between two frequency bins as fs/(N-1) or 1/(N-1)Ts. Simply put the resolution in the frequency domain is the inverse of the sample length in the time domain.

So let us now calculate the DFT of two closely spaced sine waves keeping the sampling frequency to be the same and changing the number of time domain samples (only the result for N=64 shown here). We again list down the code used to calculate the DFT.

clear all
close all

fm1=100;
fm2=120;
fs=1000;
Ts=1/fs;
N=64;
t=0:Ts:(N-1)*Ts;

x1=cos(2*pi*fm1*t);
x2=cos(2*pi*fm2*t);
x=x1+x2;
W=exp(-j*2*pi/N);

n=0:N-1;
k=0:N-1;

X=x*(W.^(n'*k));

plot(k/N,abs(X))
xlabel ('Normalized Frequency')
ylabel ('X')

We first do some quick math to find the spectral resolution.

 fs/(N-1)=1000/(64-1)=15.87 Hz

Now the two tones are space 20 Hz apart (100 Hz and 120 Hz), so we can predict that the two tones would be detected successfully. The result of the DFT operation on the composite signal is shown below.

DFT of Two Tones
DFT of Two Tones

It is observed that although the two tones are detected, they are not exactly at the desired frequencies (0.10 and 0.12). Secondly the amplitude of the two tones is different although the time domain signals had equal amplitude. Both these phenomenon are due to the fact that we only have a limited number of frequency bins (N=64) due to which the resulting spectrum is only an estimate of the true spectrum.

There are better techniques than DFT to separate two closely spaced sinusoids and these are known as super resolution spectral techniques and would be discussed some other time.

Discrete Fourier Transform

Discrete Fourier Transform or DFT is a mathematical operation that transforms a time domain signal to frequency domain. It is usually implemented using the Fast Fourier Transform (FFT). The computational complexity of the DFT is N2 whereas its (N)log2N for the FFT, where N is the number of samples of the the time domain signal. Mathematically, the DFT is written as

and this operation can be easily implemented in MATLAB as shown below.

clear all
close all

fm=100;
fs=1000;
Ts=1/fs;
N=1024;
t=0:Ts:(N-1)*Ts;

x=cos(2*pi*fm*t);
W=exp(-j*2*pi/N);

n=0:N-1;
for k=0:N-1
        X(k+1)=sum(x.*(W.^(k*n)));
end

plot((0:k)/N,abs(X))
xlabel ('Normalized Frequency')
ylabel ('X')

The DFT of the cosine function with frequency of 100Hz is shown below. It must be noted that the frequency in the figure below is normalized by the sampling frequency. So the peaks in the graph occur at 0.1*1000=100Hz and 0.9*1000=900Hz (image frequency). Actually if you zoom in you will see that the peaks are not exactly at 0.1 and 0.9 but  are slightly offset as the frequency bins are not located at exactly those frequencies.

DFT of a cosine wave
DFT of a cosine wave

In case of multiple sinusoids the resolution of the DFT becomes important. Higher the sample size (duration of the time domain signal) higher is the resolution of the DFT. As stated earlier the DFT is a computationally complex operation and usually the Fast Fourier Transform (FFT) is used to compute the frequency domain behavior. We will discuss this in the following posts.

A simple way to expedite the process of DFT calculation is to use matrix manipulation instead of a “for loop”.This is shown below.

clear all
close all

fm=100;
fs=1000;
Ts=1/fs;
N=128;
t=0:Ts:(N-1)*Ts;

x=cos(2*pi*fm*t);
W=exp(-j*2*pi/N);

n=0:N-1;
k=0:N-1;

X=x*(W.^(n'*k));

plot(k/N,abs(X))
xlabel ('Normalized Frequency')
ylabel ('X')

Although matrix manipulation makes for a nice and clean code, it was found that there was no improvement in the computation time. Both the “for loop” code and the “matrix multiplication” code took about 0.35 seconds to execute. However, increasing the sample size from 128 to 1024 results in significant better computation time for the latter scheme.

CDMA vs OFDMA

Property CDMA OFDMA
1. Channel bandwidth Full system bandwidth Variable system bandwidth to accommodate users with different data rates, 1.25, 2.50, 5.00, 10.00, 15.00 and 20.00 MHz, actual transmission bandwidth is a bit lower than this
2. Frequency-selective scheduling Not possible A key advantage of OFDMA, although it requires accurate real-time feedback of channel conditions from receiver to transmitter
3. Symbol period Very short—inverse of the system bandwidth Very long—defined by subcarrier spacing and independent of system bandwidth
4. Equalization Complicated time domain equalization Simple frequency domain equalization
5. Resistance to mulitpath Rake receiver can combine various multipath components Highly resistant to multipath due to insertion of cyclic prefix (CP)
6. Suitability for MIMO MIMO is not suited to a wideband frequency selective channel MIMO is suited to the independent narrowband flat fading channels that the subcarriers provide
7. Resistance to narrowband interference Resistant to narrow band interference Some subcarriers to be affected by narrowband interference
8. Separation of users Scrambling and orthogonal spreading codes Frequency and time although scrambling and spreading can be added as well

Reference: Agilent 3GPP Long Term Evolution System Overview, Product Development and Test Challenges Application Note.

BER of 64-QAM OFDM in Frequency Selective Fading-II

In the previous post we had considered a static frequency-selective channel. We now consider a time-varying frequency selective channel with 7 taps. Each tap of the time domain filter has a Gaussian distributed real component with variance 1/(2*n_tap) and a Gaussian distributed imaginary component with variance (1/2*n_tap). The amplitude of each tap is thus Rayleigh distributed and the phase is Uniformly distributed. Since the power in each component is normalized by the filter length (n_tap) the BER performance would remain the same even if the filter length is changed (this has been verified experimentally).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% FUNCTION TO SIMULATE PERFORMANCE OF 64-OFDM IN TIME VARYING FREQUENCY SELECTIVE CHANNEL
% n_bits: Input, length of binary sequence
% n_fft: Input, length of FFT (Fast Fourier Transform)
% EbNodB: Input, energy per bit to noise power spectral density ratio
% ber: Output, bit error rate
% Copyright RAYmaps (www.raymaps.com)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function[ber]= M_QAM_OFDM_fading(n_bits,n_fft,EbNodB)

Eb=7;
M=64;
k=log2(M);
n_cyc=32;
EbNo=10^(EbNodB/10);
x=transpose(round(rand(1,n_bits)));
h1=modem.qammod(M);
h1.inputtype='bit';
h1.symbolorder='gray';
y=modulate(h1,x);
n_sym=length(y)/n_fft;
n_tap=7;

for n=1:n_sym;
    s_ofdm=sqrt(n_fft)*ifft(y((n-1)*n_fft+1:n*n_fft),n_fft);
    s_ofdm_cyc=[s_ofdm(n_fft-n_cyc+1:n_fft); s_ofdm];
    ht=(1/sqrt(2))*(1/sqrt(n_tap))*(randn(1,n_tap)+j*randn(1,n_tap));
    Hf=fft(ht,n_fft);
    r_ofdm_cyc=conv(s_ofdm_cyc,ht);
    r_ofdm_cyc=(r_ofdm_cyc(1:n_fft+n_cyc));
    wn=sqrt((n_fft+n_cyc)/n_fft)*(randn(1,n_fft+n_cyc)+j*randn(1,n_fft+n_cyc));
    r_ofdm_cyc=r_ofdm_cyc+sqrt(Eb/(2*EbNo))*wn.';
    r_ofdm=r_ofdm_cyc(n_cyc+1:n_fft+n_cyc);
    s_est((n-1)*n_fft+1:n*n_fft)=(fft(r_ofdm,n_fft)/sqrt(n_fft))./Hf.';
end

h2=modem.qamdemod(M);
h2.outputtype='bit';
h2.symbolorder='gray';
h2.decisiontype='hard decision';
z=demodulate(h2,s_est.');
ber=(n_bits-sum(x==z))/n_bits
return
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

As before we have used an FFT size of 128 and cyclic prefix of 32 samples. The FFT and IIFT operations are normalized to maintain the signal to noise ratio (SNR). The extra energy transmitted in the cyclic prefix is also accounted for in the SNR calibration.

64-QAM BER in Time Varying Frequency Selective Channel
64-QAM BER in Time Varying Frequency Selective Channel

It is observed that the BER performance of 64-QAM OFDM in the time-varying frequency-selective channel is quite similar to that in the static frequency-selective channel with complex filter taps. It must be noted that with 64-QAM the goal is to achieve higher bit rate, error rates can be improved using antenna diversity and channel coding schemes.

Given below is the wrapper that should be used along with the above code. The wrapper basically calls the above routine for each value of EbNodB. The length of the binary sequence and the FFT size are other inputs to the function. The bit error rate at the specific EbNodB is the output of the function.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all;
close all;
k=6;
n_fft=128;
l=k*n_fft*1e3;
EbNodB=0:2:20;
for n=1:length(EbNodB);n
ber(n)=M_QAM_OFDM_fading(l,n_fft,EbNodB(n));
end;
semilogy(EbNodB,ber,'O-');
grid on
xlabel('EbNo')
ylabel('BER')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

In future we would use the standard LTE channel models, namely EPA, EVA and ETU in our simulation.