MyOFDM Tutorial V 01
MyOFDM Tutorial V 01
2008
michael.biester@googlemail.com
1/22
OFDM Tutorial
version 0.1
Contents
1 Signal description............................................................................................................................. 2
1.1 analogue signal processing ...................................................................................................... 3
1.2 source ....................................................................................................................................... 3
1.2.1 analogue transmitter .......................................................................................................... 3
1.2.2 spectral properties ............................................................................................................. 4
1.2.3 physical channel # analogue ............................................................................................. 6
1.2.4 analogue receiver .............................................................................................................. 6
1.3 digital signal processing............................................................................................................ 8
1.3.1 digital transmitter ............................................................................................................... 8
1.3.2 time discrete channel ......................................................................................................... 9
1.3.3 digital receiver.................................................................................................................. 11
1.4 why using the cylic prefix ? ..................................................................................................... 13
2 A simple simulator .......................................................................................................................... 18
2.1 scope....................................................................................................................................... 18
2.2 simulation parameters............................................................................................................. 18
2.3 QAM source ............................................................................................................................ 18
2.4 IFFT block ............................................................................................................................... 18
2.5 obtaining and adding the cyclic prefix..................................................................................... 19
2.6 time discrete channel .............................................................................................................. 19
2.7 discard cyclic prefix................................................................................................................. 20
2.8 transform to data vector .......................................................................................................... 21
2.9 post processing....................................................................................................................... 22
2.9.1 obtain errors................................................................ Fehler! Textmarke nicht definiert.
2.9.2 plot constellation diagram of subcarriers......................................................................... 22
31.03.2008
michael.biester@googlemail.com
2/22
1 Scope
The document reviews some very basic features of an OFDM transmission system. The need of such
a document may be questionable since there is already a wealth of introductory texts on this topic.
However the main motivation to start such a document was to familiarise myself with the principles of
OFDM transmission systems and to document my "learning progress".
The basic signal processing steps found in OFDM systems are provided both in the analogue domain
and as a time discrete description which is thought to be more suitable for simulation projects. From
the time discrete formulation of the signal processing a simple simulation tool is derived. There will be
two versions of a basic simulator:
Python + several extension modules (required for MATLAB style array processing and plotting
capabilities comparable to MATLAB)
MATLAB
Choosing two different programming environments is mainly for historical reasons. I started using
MATLAB around 1993 for almost any scientific programming task. Other programming tasks however
lead me to use Python and its extension modules as well. Overtime it became apparent that Python
can be a very good substitute for MATLAB in numerous projects of scientific programming.
Considering the price tag attached to MATLAB and its toolboxes, the existence of free software
providing equivalent functionality should trigger some experiments with these tools anyway. This
becomes even more important when you start to do some programming for self-education at home
where access to a MATLAB license is more or less unlikely.
As further versions of this document evolve the focus will be more on how to write a fully fledged
simulation tool covering more advanced topics such as synchronisation issues of the OFDM receiver
and the impact of various imperfections commonly found in any practical implementation of the
transmitter and the receiver. Programming of such tools will use mainly Python + numeric extension
modules + C/C++ programs in those cases where computational speed is of paramount importance.
31.03.2008
michael.biester@googlemail.com
3/22
2 Signal description
2.1 analogue signal processing
fig. 2-1) model of signal transmission
2.2 source
The source provides complex data symbols x
k,l
.
k is an index in the range [0, N-1]
l is the block index ; used to number OFDM symbols.
2.2.1 analogue transmitter
An OFDM transmitter uses a set of waveforms
k
(t) for data transmission. Moreover each OFDM
symbol comprises N subcarriers with center frequencies kf . Index k denotes the sub-carrier index .
The range of k is in :
k [0, N-1]
f = 1/T
p
Furthermore we define a duration T
cp
(duration of the cyclic prefix) and the duration T of an OFDM
symbol.
T = T
p
+ T
cp
With these definitions waveforms
k
(t) are expressed as :
( )
( )
[ ]
=
otherwise
T t for e
t
cp
T t k f j
k
0
, 0
2
Sometimes it is more convenient to use this definition
( )
( )
( ) [ ]
=
=
otherwise
T t for t p t p e
t
cp
T t k f j
k
0
, 0 1 ) (
2
Note that for t [0, T
cp
] we have
( ) ( )
cp p k k
T t for T t t + = 0
(due to this property the time interval [0, T
cp
] is called the cyclic prefix) .
transmitter channel receiver source sink
x
k,l
x
k,l
s
l
(t) s(t) g(t) r(t)
31.03.2008
michael.biester@googlemail.com
4/22
Each OFDM symbol is a weighted superposition of these N waveforms. Specifically the l'th OFDM
symbol is
( ) ( )
=
=
1
0
,
N
k
k l k l
T l t x t s
The weights x
k,l
are complex numbers representing data for transmission (e.g. a set of M-QAM
symbols).
From the definition of waveforms the l'th OFDM symbol is defined on the interval
lT t [l+1]T
The sub interval
lT t lT + T
cp
belongs to the cyclic prefix part of the l'th OFDM symbol .
The entire signal s(t) is just the sequence of OFDM symbols.
( ) ( )
=
=
= =
l
N
k
k l k
l
l
T l t x t s t s
1
0
,
) (
2.2.2 spectral properties
The power spectral density is defined as the Fourier transformation of the autocorrelation function
R().
( ) ( ) ( ) { } = t s t s E R
*
( ) ( ) { }
=
d e t s t s E f S
f j 2 *
) (
( ) ( ) ( ) ( )
( ) ( ) ( ) ( ) T l t p T l t p T l t T l t x x
t s t s t s t s
l
N
k l
N
k
k k l k l k
l l
l l
=
=
=
' '
1
0 '
1
0 '
*
'
*
' , ' ,
'
* *
When taking expected the expected value
( ) ( ) { } t s t s E
*
non-zero contribution occur only if we have simultaneously k = k' and l = l' .
( ) ( ) { } ( ) ( ) ( ) ( ) { }
=
=
l
N
k
k k l k
T l t p T l t p T l t T l t x E t s t s E
1
0
*
2
,
*
with
( ) ( ) ( ) ( ) ( ) ( ) T l t p T l t p e T l t p T l t p T l t T l t
k f j
k k
=
2 *
31.03.2008
michael.biester@googlemail.com
5/22
{ }
2
2
, k l k
x E =
and finally
( ) ( ) ( ) ( ) { }
T T for
T
e
T
T l t p T l t p T l t T l t x E
k f j
k
N
k
k k l k
|
|
\
|
=
1
1
2 2
1
0
*
2
,
Hence the power spectral density is expressed as
[ ]
=
|
|
\
|
=
1
0
2 2
1
1
) (
N
k
T
T
k f f j
k
d e
T T
f S
[ ] ( )
=
|
\
|
=
1
0
0
2
2 cos 1 2
1
) (
N
k
T
k
d k f f
T T
f S
[ ] ( )
[ ] ( )
=
=
1
0
0
2
2
1
0
0
2
2 cos 2
1
2 cos 2
1
) (
N
k
T
k
N
k
T
k
d k f f
T
d k f f
T
f S
[ ] ( )
[ ] ( )
[ ] ( )
[ ] ( )
2
1
0
2
1
0
2 2
2
sin
4
1
2
1 2 cos
2
1
) (
=
=
(
\
|
=
=
N
k
k
N
k
k
T k f f
T k f f
k f f
T k f f
T
f S
In an OFDM transmission system the sub-carrier spacing f is as
f = 1/T
The maximum spectral contribution of each sub-carrier occurs at frequencies where the spectral
components of all other sub-carriers is zero.
31.03.2008
michael.biester@googlemail.com
6/22
example
fig. 2-2) normalised OFDM spectrum
2.2.3 physical channel # analogue
The physical channel is either characterised by its channel impulse response g(t) or in the frequency
domain by its Fourier transform G(f) . Initially we assume a fixed channel impulse response. Later this
simplification may be dropped. Furthermore a finite duration of g(t) is assumed.
g(t) defined for 0 t T
cp
2.2.4 analogue receiver
The input signal of the receiver is denoted r(t) .
( ) ( ) ( ) ( ) ( ) ( ) ( ) t n d t s g t n t s t g t r
cp
T
+ = + =
0
*
n(t) is the noise contribution of the receiver .
( ) ( ) ( ) ( ) t n d t s g t r
l
T
l
cp
+ =
=
0
Defining the l'th filtered OFDM symbol by u
l
(t)
31.03.2008
michael.biester@googlemail.com
7/22
( ) ( ) ( )
=
cp
T
l l
d t s g t u
0
we observe that u
l
(t) is defined on the finite time interval
( )
[ ]
+ +
=
otherwise
T T l t T l for defined
t u
cp
l
0
1
Generally signal u
l
(t) overlaps the consecutive signal u
l+1
(t) by a time span of T
cp
. This overlap is due
to the channel impulse response g(t) . It leads to interference with the first part of the consecutive
signal.
So the useful part of u
l
(t) is restricted to time interval
lT + T
cp
t [l+1]T
It is therefore the task of the receiver's signal processing to extract these signal intervals from the
OFDM signal .
( ) ( ) ( ) t n t u t r
l
l
+ =
=
( ) ( ) ( )
=
=
1
0
0
,
N
k
T
k l k l
cp
d T l t g x t u
Inserting the definition equation for the waveform function we get
( ) ( )
( )
=
=
1
0
0
2
,
N
k
T
T T l t k f j
l k l
cp
cp
d e g x t u
and
( )
( )
( )
=
=
1
0
0
2
2
,
N
k
T
k f j
T T l t k f j
l k l
cp
cp
d e g e x t u
The integral is just the Fourier transform G(f) evaluated at frequencies kf .
( ) ( )
=
cp
T
k f j
d e g f k G
0
2
Hence
( ) ( )
( )
=
=
1
0
2
,
N
k
T T l t k f j
l k l
cp
e x f k G t u
Using the signal in the interval
lT + T
cp
t [l+1]T
we want to reconstruct data symbols x
k,l
.
( )
( )
[ ]
( )
( ) ( )
[ ]
=
+
+
+
+
=
1
0
1
2 2
,
1
2
N
k
T l
T T l
T T l t k f j T T l t k f j
l k
T l
T T l
T T l t k f j
l
cp
cp cp
cp
cp
dt e e x f k G dt e t u
31.03.2008
michael.biester@googlemail.com
8/22
( )
( )
[ ]
( )
[ ] ( )
[ ]
( )
[ ]
=
+
+
+
+
=
=
1
0
0
2
,
1
0
1
2
,
1
2
N
k
T
t k k f j
l k
N
k
T l
T T l
T T l t k k f j
l k
T l
T T l
T T l t k f j
l
p
cp
cp
cp
cp
dt e x f k G
dt e x f k G dt e t u
( )
( )
[ ]
( )
=
=
+
+
k k
k k for T x f k G
dt e t u
p l k
T l
T T l
T T l t k f j
l
cp
cp
0
,
1
2
Hence we get x
k,l
by
( ) ( )
( )
[ ]
+
+
=
T l
T T l
T T l t k f j
l
p
l k
cp
cp
dt e t u f k G
T
x
1
2 1
,
1
2.3 digital signal processing
2.3.1 digital transmitter
Each OFDM symbol is constructed from a set of complex data symbols denoted by x
k,l
. In this
notation we have indices k, l to indicate the
sub-carrier index k [0, N-1]
index of the OFDM symbol l
For each index l (OFDM symbol) the N data symbols x
k,l
are transformed into a new sequence y
m,l
using equation
[ ]
+
=
=
otherwise
N l m N l for e x A
y
N
k
N l m k
N
j
l k
l m
0
1 ) 1 (
1
0
2
,
,
Sequence y
l
y
l
= [y
(lN+0),l
, y
(lN+1),l
, , y
([l+1]N-2),l
, y
([l+1]N-1),l
]
cannot be used directly for transmission. Instead y
l
is extended to a longer sequence z
l
by adding a
finite length prefix. For reasons explained later in this document the prefix is constructed from the last
L samples of sequence y
l
.
Note :
L is generally chosen larger than the maximum number of significant samples of the channel impulse
response. The new sequence (also known as OFDM symbol) is thus the concatenation of two
sequences
z
l
= [y
([l+1]N-L),l
, y
([l+1]N-L+1),l
, , y
([l+1]N-2),l
, y
([l+1]N-1),l
] , [y
(lN+0),l
, y
(lN+1),l
, , y
([l+1]N-2),l
, y
([l+1]N-1),l
]
Since we use a repetition of samples of y
l
for the prefix the part of sequence z
l
where
0 n L-1
31.03.2008
michael.biester@googlemail.com
9/22
equals
z
l
[n + N]
This property is similar to periodicity and the prefix is commonly denoted as "cyclic prefix" for this
reason.
The total length of sequence z
l
is N
tot
= N + L
The transmitted sequence is then just the juxtaposition of sub-sequences z
m,l
.
[ ]
+ +
=
=
otherwise
L N l m N l for e x A
z
N
k
N l L m k
N
j
l k
l m
0
1 ) 1 (
1
0
2
,
,
For indices m in the range [lN, , lN-1+L] samples z
m,l
are just the cyclic prefix.
Defining the pulse function p[m]
[ ]
+
=
otherwise
L N m for
m p
0
1 0 1
we may rewrite sub-sequences z
m,l
by
[ ]
( ) [ ] L N l m p e x A z
N
k
N l L m k
N
j
l k l m
+ =
=
1
0
2
, ,
Using the last equation the transmitted sequence z[m] is expressed as
[ ]
[ ]
( ) [ ]
=
=
+ = =
l
N
k
N l L m k
N
j
l k
l
l m
L N l m p e x A z m z
1
0
2
, ,
Many publications on OFDM signal processing define a time discrete waveform
k
[m] by
[ ]
[ ]
+
=
otherwise
L N m m p e
m
L m k
N
j
k
0
1 0 ] [
2
which gives
[ ] ( ) [ ]
=
=
+ = =
l
N
k
k l k
l
l m
L N l m x A z m z
1
0
, ,
2.3.2 time discrete channel
The discrete channel impulse response is denoted by g[n] . We will always assume a finite number
L+1 of samples.
g[n] = [ g[0], g[1], , g[L] ]
It is expected however that only samples up to some index M < L are significant .
The discrete channel performs a convolution of the input sequences z[m].
31.03.2008
michael.biester@googlemail.com
10/22
Let r[m] be the channel's output signal.
[ ]
=
=
n
n m g n z m r ] [ ] [
( ) [ ] [ ]
=
+ =
n l
N
k
k l k
n m g L N l n x A m r
1
0
,
] [
The last expression seems daunting. However some simplifications are possible by taking into
account that waveform functions
k
[.] and impulse response g[.] both are defined over a finite range of
indices.
For a given time index m index we have
0 m-n L
which restricts n to the range
-L+m n m
So we can introduce finite summation limits for n .
( ) [ ] [ ]
= + =
=
+ =
l
m
m L n
N
k
k l k
n m g L N l n x A m r
1
0
,
] [
For a more convenient notation we express index m by
( ) r L N l m
m
+ + =
l
m
and r are integers. r is defined on the interval r [0, N+L-1] . Hence any value of m is uniquely
defined by the index tuple (l
m
, r) .
Wavefunctions ( ) [ ] L N l n
k
+ are defined for
0 n l(N+L) N+L-1
-(N+L) + 1 + n l(N+L) n
Inserting the minimum possible values of n
n
min
= -L + m
n
max
= m
we get:
-(N+L) + 1 L + m l(N+L) m
and
-(N+L) + 1 L + l
m
(N+L) + r l(N+L) l
m
(N+L) + r
(l
m
1)(N+L) + r + 1 L l(N+L) l
m
(N+L) + r
(l
m
1) + (r + 1 L)/(N+L) l l
m
+ r/(N+L)
31.03.2008
michael.biester@googlemail.com
11/22
(l
m
1) + (r + 1 L)/(N+L) l l
m
+ r/(N+L) = lm
and finally
0 r (L-1) (l
m
1) l lm
( )
( ) [ ] [ ] ( ) ( ) [ ] [ ]|
\
|
+ + +
= + + =
+ = + =
=
m
m L n
m
m L n
N
k
m k l k
N
k
m k l k
m
n m g L N l n x n m g L N l n x A
r L N l r m r
1
0
,
1
0
,
1
] [ ] [
In this case two OFDM symbols contribute to the output. It is easy to see that up to L samples of
OFDM symbol with index l
m
are corrupted by intersymbol interference ISI from the preceeding OFDM
symbol with index (l
m
1) .
L r (N+L-1) l = lm
( )
( ) [ ] [ ]
+ =
=
+
= + + =
m
m L n
N
k
m k l k
m
n m g L N l n x A
r L N l r m r
1
0
,
] [ ] [
Here only OFDM symbol with index l
m
contributes to the output sequence r[m] .
2.3.3 digital receiver
An ideal receiver would detect sequence r[m] and partition it into chunks of blocks (index l
m
) of (N+L)
samples. We have seen that the first L samples of each block may be useless due to ISI. So the next
step is to discard these leading L samples and retain the part for
L r (N+L-1) l = lm
( )
( ) [ ] [ ]
+ =
=
+
= + + =
m
m L n
N
k
m k l k
m
n m g L N l n x A
r L N l r m r
1
0
,
] [ ] [
Inserting
[ ]
[ ]
+
=
otherwise
L N m m p e
m
L m k
N
j
k
0
1 0 ] [
2
( )
( ) [ ]
( ) [ ]
+ =
=
+
+
= + + =
m
m L n
N
k
m
L L N l n k
N
j
l k
m
n m g L N l n p e x A
r L N l r m r
m
1
0
2
,
] [
] [ ] [
The value of ( )] [ L N l n p
m
+ is always 1 for n [-L+m, m] . So we have
31.03.2008
michael.biester@googlemail.com
12/22
( )
( ) [ ]
[ ]
+ =
=
+
= + + =
m
m L n
N
k
L L N l n k
N
j
l k
m
n m g e x A
r L N l r m r
m
1
0
2
,
] [ ] [
Looking at g[m-n] for index n running from (-L+m) to m we observe that [m-n] runs from L to 0
regardless of the specific choice for index m.
r runs from L to (N+L-1) . Hence we define r' .
L r r = '
( ) [ ]
[ ]
=
+ + +
=
L
u
N
k
L L N l m u L k
N
j
l k
u L g e x A
r r
m
0
1
0
2
,
] ' [
[ ]
[ ]
=
+
=
L
u
N
k
L r u k
N
j
l k
u L g e x A
r r
0
1
0
'
2
,
] ' [
The receiver's task is to recover transmitted data symbol x
k,l
of the l
th
OFDM symbol. To this end we
evaluate
[ ]
[ ]
= =
=
+
=
=
=
1
0 ' 0
1
0
' '
2
'
2
,
1
0 '
' '
2
] ' [ ] ' [
N
r
L
u
N
k
r k
N
j L r u k
N
j
l k
N
r
r k
N
j
u L g e e x A
e r r k o
Using w = L u we obtain
[ ]
[ ]
= =
=
=
1
0 ' 0
1
0
' '
2
'
2
,
] ' [
N
r
L
w
N
k
r k
N
j w r k
N
j
l k
w g e e x A k o
Re-ordering this equation yields
[ ]
[ ]
=
=
=
L
w
N
k
N
r
r k k
N
j w k
N
j w k
N
j
l k
e e e x w g A k o
0
1
0
1
0 '
' '
2 2 2
,
] ' [
o[k'] takes on non-zero values only if k = k' .
[ ]
=
=
L
w
w k
N
j
l k
e w g x N A k o
0
'
2
, '
] ' [
But [ ]
L
w
w k
N
j
e w g
0
'
2
is just the DFT of the channel impulse evaluated at frequency instant k' .
31.03.2008
michael.biester@googlemail.com
13/22
[ ] [ ]
=
=
L
w
w k
N
j
e w g k G
0
'
2
'
[ ] ' ] ' [
, '
k G x N A k o
l k
=
The data symbol x
k',l
is then
[ ] [ ]
=
= =
1
0 '
' '
2
, '
] ' [
1
'
1 1
] ' [
1
'
1 1
N
r
r k
N
j
l k
e r r
N k G A
k o
N k G A
x
Compensating for the frequency dispersive distortion of the channel amounts just to a complex gain
correction of the k' subcarrier with the inverse of the channels discrete frequency reponse at the
subcarrier's frequency k' .
summary
The receiver has to perform these signal processing steps:
1. detect sequence r[m] and partition it into chunks of blocks (index l
m
) of (N+L) samples. In an
actual implementation this partitioning would require some synchronisation beforehand. After
all the receiver needs to know where to apply the split and the synchronisation algorithm
provides just this information.
2. Next the cyclic prefix of length L is removed from the data block . If the channel's impulse
response is reasonably short compared to L there will be no ISI of adjacent OFDM symbols.
3. The remaining data block has length N. Applying the FFT to this block and correcting each
sample of the FFT' output by multiplying with the inverse of the complex channel gain at this
subcarrier frequency provides a possibly scaled version of the transmitted complex symbols
x
k,l
.
4. Correct data symbol by applying a scaling factor. A practical receiver would have to apply
methods which provide the required scaling factor AGC function.
2.4 why using the cylic prefix ?
to be written
31.03.2008
michael.biester@googlemail.com
14/22
3 Impact of an OFDM signal to Imperfections
The previously presented analogue/digital models of OFDM transmission excluded any imperfections
introduced by hardware of the transmitter and receiver. In any practical transmission scenario various
imperfections must be considered. A by far incomplete list of these imperfection is summarised here :
TX section
1. I-/Q imbalance, quadrature phase error of up-conversion scheme
2. residual LO in case of a direct up-conversion transmitter
3. filter distortion
4. Phase noise from up-conversion
5. nonlinearities of the TX high power amplifier
RX section
1. Phase noise from down-conversion
2. filter distortion
3. I-/Q imbalance, quadrature phase error of down-conversion scheme
4. residual frequency errors
5. synchronisation errors of OFDM symbol timing
Most of these imperfections are beyond the scope of this document. Only the impact of residual
frequency errors is studied in more detail in this document.
3.1 impact of residual frequency errors
For reasons of simplicity the effect of residual frequency errors is studied for digital OFDM
transmission.
Again we start with the received sequence r[m] but include the term
m
f
f
j
s
e
2
f denotes the frequency offset. f
s
is the sampling frequency of the received sequence r[m] . The
sequence is partitioned it into chunks of blocks (index l
m
) of (N+L) samples. Again the first L samples
of each block are discarded. The remaining part of block with index l
m
is then :
L r (N+L-1) l = lm
( )
( ) [ ] [ ]
+ =
+
= + + =
m
m L n
N
k
m
f
f
j
m k l k
m
f
f
j
m
n m g e L N l n x A
e r L N l r m r
s
s
1
0
2
,
2
] [ ] [
Inserting
31.03.2008
michael.biester@googlemail.com
15/22
[ ]
[ ]
+
=
otherwise
L N m m p e
m
L m k
N
j
k
0
1 0 ] [
2
( )
( ) [ ]
( ) [ ]
+ =
+
+
= + + =
m
m L n
N
k
m
m
f
f
j
L L N l n k
N
j
l k
m
n m g L N l n p e e x A
r L N l r m r
s
m
1
0
2
2
,
] [
] [ ] [
The value of ( )] [ L N l n p
m
+ is always 1 for n [-L+m, m] . So we have
( )
( ) [ ]
[ ]
+ =
+
= + + =
m
m L n
N
k
m
f
f
j
L L N l n k
N
j
l k
m
n m g e e x A
r L N l r m r
s
m
1
0
2
2
,
] [ ] [
Looking at g[m-n] for index n running from (-L+m) to m we observe that [m-n] runs from L to 0
regardless of the specific choice for index m.
r runs from L to (N+L-1) . Hence we define r' .
L r r = '
( ) [ ]
( ) [ ]
[ ]
=
+ + +
+ + +
=
L
u
N
k
L r L N l
f
f
j
L L N l m u L k
N
j
l k
u L g e e x A
r r
m
s
m
0
1
0
' 2
2
,
] ' [
( ) [ ]
[ ]
[ ]
+
+ +
=
L
u
N
k
r
f
f
j
L r u k
N
j
l k
L L N l
f
f
j
u L g e e x e A
r r
s
m
s
0
1
0
' 2
'
2
,
2
] ' [
The receiver's task is to recover transmitted data symbol x
k,l
of the l
th
OFDM symbol. To this end we
evaluate
( ) [ ]
[ ]
[ ]
= =
+
+ +
=
=
=
1
0 ' 0
1
0
' '
2
' 2
'
2
,
2
1
0 '
' '
2
] ' [ ] ' [
N
r
L
u
N
k
r k
N
j
r
f
f
j
L r u k
N
j
l k
L L N l
f
f
j
N
r
r k
N
j
u L g e e e x e A
e r r k o
s
m
s
Using w = L u we obtain
( ) [ ]
[ ]
[ ]
= =
+ +
=
1
0 ' 0
1
0
' '
2
' 2
'
2
,
2
] ' [
N
r
L
w
N
k
r k
N
j
r
f
f
j
w r k
N
j
l k
L L N l
f
f
j
w g e e e x e A k o
s
m
s
Re-ordering this equation yields
31.03.2008
michael.biester@googlemail.com
16/22
( ) [ ]
[ ]
[ ]
=
+ +
=
L
w
N
k
N
r
r
f
f
j
r k k
N
j w k
N
j
l k
L L N l
f
f
j
s
m
s
e e e x w g e A k o
0
1
0
1
0 '
' 2
' '
2 2
,
2
] ' [
A closed form solution does not seem possible. But for a small frequency offset f a reasonable good
approximation of
' 2 r
f
f
j
s
e
is
{ 1 ' 0 ' 2 1
' 2
N r for r
f
f
j e
s
r
f
f
j
s
Then samples o[k'] are expressed as
( ) [ ]
[ ]
[ ]
( ) [ ]
[ ]
[ ]
=
=
+ +
=
+ +
|
|
\
|
+
=
L
w
N
k
N
r
r k k
N
j w k
N
j
l k
L L N l
f
f
j
s
L
w
N
k
N
r
r k k
N
j w k
N
j
l k
L L N l
f
f
j
e r e x w g e
f
f
A j
e e x w g e A k o
m
s
m
s
0
1
0
1
0 '
' '
2 2
,
2
0
1
0
1
0 '
' '
2 2
,
2
' 2
] ' [
Using property
[ ]
=
=
=
otherwise
k k N
e
N
r
r k k
N
j
0
'
1
0 '
' '
2
and defining
[ ]
[ ]
=
=
1
0 '
' '
2
' '
N
r
r k k
N
j
e r k k M
we get
( ) [ ]
[ ]
( ) [ ]
[ ] [ ]
= =
+ +
=
+ +
|
|
\
|
+
=
1
0 0
2
,
2
0
'
2
, '
2
' 2
] ' [
N
k
L
w
w k
N
j
l k
L L N l
f
f
j
s
L
w
w k
N
j
l k
L L N l
f
f
j
e w g k k M x e
f
f
A j
e w g x N e A k o
m
s
m
s
And having seen that
[ ]
L
w
w k
N
j
e w g
0
'
2
is just the DFT of the channel impulse evaluated at frequency instant k' .
[ ] [ ]
=
=
L
w
w k
N
j
e w g k G
0
'
2
'
31.03.2008
michael.biester@googlemail.com
17/22
( ) [ ]
[ ]
( )
( ) [ ]
[ ] [ ]
=
+ +
+ +
|
|
\
|
+
=
1
0
,
2
, '
2
' 2
2
1
' ] ' [
N
k
l k
L L N l
f
f
j
s
l k
L L N l
f
f
j
k G k k M x e
f
f N N
A j
k G x N e A k o
m
s
m
s
Applying scaling factors (1/A) , (1/N) and correcting for frequency dependent gain (1/G[k']) yields
[ ]
( ) [ ]
( ) [ ]
[ ]
[ ]
[ ]
=
+ +
+ +
|
|
\
|
+
=
1
0
,
2
, '
2
'
' 2
1
] ' [
'
1 1 1
N
k
l k
L L N l
f
f
j
s
l k
L L N l
f
f
j
k G
k G
k k M x e
f
f
N
j
x e k o
k G N A
m
s
m
s
Ignoring the common phase term
( ) [ ] L L N l
f
f
j
m
s
e
+ +
2
we observe that only for f = 0 the data symbol
x
k',l
is recovered exactly. With frequency offset f there will be always some cross talk and all data
symbols contribute to this. Moreover cross talk increases with the number of sub-carriers.
31.03.2008
michael.biester@googlemail.com
18/22
4 A simple simulator
4.1 scope
Demonstrate basic principle of a time discrete OFDM transmission system.
As a first step a simulation program will be written using Python + some extension modules. Once this
approach works similar programs will be written in MATLAB and SCILAB .
4.2 simulation parameters
N................................. number of subcarriers ; for numeric efficiency N should be a power of 2
L................................. length of cyclic prefix
N_OFDM...................... number of OFDM symbols used in simulation
channel_imp........... vector of complex samples of the channel impulse response
f_offset_n............. normalised frequency offset
s
f
f
4.3 QAM source
A Python module QAMSources.py provides several QAM data generators. Currently supported
modulation methods are :
1. 4-QAM Source4QAM(block_len)
2. 16-QAM Source16QAM(block_len)
3. 32-QAM Source32QAM(block_len)
4. 64-QAM Source64QAM(block_len)
5. 128-QAM Source128QAM(block_len)
6. 256-QAM Source256QAM(block_len)
example:
qam_vec = Source4QAM(block_len)
block_len .................... number of 4-QAM symbols
qam_vec......................... complex numpy array of randomly generated 4-QAM symbols ;
len(qam_vec) = block_len
4.4 OFDM modulator
4.4.1 IFFT block
Let the l'th QAM data vector be represented by a complex vector x
k,l
with k [0, N-1]. The IFFT block
of the OFDM modulator processes the elements of vector into a new complex vector y
k,l
using
equation.
31.03.2008
michael.biester@googlemail.com
19/22
=
=
1
0
2
, ,
N
k
m k
N
j
l k l m
e x A y
This is just the inverse discrete Fourier transform scaled by a factor A . In Python (module numpy) as
in MATLAB the inverse FFT functions ifft() provide the operation
=
1
0
2
,
1
N
k
m k
N
j
l k
e x
N
To correct for the scaling factor (1/N) introduced by the ifft() function we multiply by N .
example
y_vec = N*numpy.fft.ifft(qam_vec) # Python + numpy module
4.4.2 obtaining and adding the cyclic prefix
y_vec is a complex vector with N elements
y_vec[0], y_vec[1], , y_vec[N-2], y_vec[N-1]
The last L elements of y_vec make up the samples of the cyclic prefix .
cyclic_prefix = [y_vec[N-L], , y_vec[N-2], y_vec[N-1]]
In Python cyclic_prefix is obtained through a slicing operation of the vector y_vec (MATLAB
and SCILAB have similar indexing operations) .
cyclic_prefix = y_vec[N-L:]
The cyclic prefix is prepended to vector y_vec. The extended vector is denoted ofdm_vec . In Python
this is achieved using
ofdm_vec = numpy.concatenate( (cyclic_prefix, y_vec) )
or directly without explicitly creating vector cyclic_prefix
ofdm_vec = numpy.concatenate( (y_vec[N-L:], y_vec) )
4.5 time discrete channel
Complex samples of the channel impulse response are stored in a vector g_channel_imp . We
assume a length of M samples. To make the organisation of program flow simpler the restriction
M < N
is imposed. But this is really not much of a restriction since for successful operation (no intersymbol
interference of adjacent OFDM symbols no ISI ) we require
M < L < N
Stated in a different way: The length M of the channel impulse response shall be less than the length L
of the cyclic prefix.
31.03.2008
michael.biester@googlemail.com
20/22
The time discrete channel performs aperiodic convolution as defined by equation
[ ]
=
=
P
p
p k h p i k r
0
] [ ] [
i[] ...................... samples of the input sequence
h[] ..................... samples of the channel impulse response
r[k].................... samples of the output sequence channel output
In the specific case of this simulation program sequence i[] are the samples of ofdm_vec . Hence
index p is in [0, N+L-1] .
Impulse response h[] are the samples of g_channel_imp .
The resulting sequence r[] has a length of (N+L+M-1)
r[0], r[1], , r[N+L-1], r[N+L], , r[N+L+M-2]
The last (M-1) samples of r[] overlap with first (M-1) samples of the consecutive filtered OFDM symbol.
Filtering an OFDM symbols therefore requires several signal processing steps:
# the channel ...
r_vec = num.convolve(ofdm_vec, g_channel_impulse)
# split into vectors r1_vec, r2_vec
r1_vec = r_vec[0:N+L]
r2_vec = r_vec[N+L:]
# correct for channel output of last OFDM-symbol
r1_vec[0:M-1] = r1_vec[0:M-1] + overlap_old
# save overlap part of current OFDM symbol for next symbol
overlap_old = r2_vec
4.6 frequency offset
To apply a frequency offset to array r1_vec we first create a vector fo_vec of (N+L) samples
1 ) ( 0
2
+
|
|
\
|
L N m e
m
f
f
j
s
# frequency offset of receiver
fo_vec = num.exp(2.j *num.pi * f_offset_n * num.arange(N+L))
multiplying array r1_vec by fo_vec yields the OFDM symbol r1_vec_fo with frequency offset.
# apply frequency offset
r1_vec_fo = r1_vec * fo_vec
31.03.2008
michael.biester@googlemail.com
21/22
4.7 discard cyclic prefix
The first L samples are the cyclic prefic possibly garbled by ISI. So the receiver discards this part of
the array r1_vec_fo. The remaining part is stored in an array ofdm_rec of length N .
# discard cyclic prefix part
ofdm_rec = r1_vec_fo[L:]
ofdm_rec is equivalent to sequence r[r'] in section 2.3.3 .
4.8 retrieving the data vector
Getting back to the transmitted data symbols x
k,l
is a two step procedure.
1. application of FFT (In case of a transparent channel we are done. The FFT yields the
sequence of samples x
k,l
.)
2. frequency dependent gain correction due to the channel's impulse response
We already derived an equation for the recovered data :
[ ] [ ]
=
= =
1
0 '
' '
2
, '
] ' [
1
'
1 1
] ' [
1
'
1 1
N
r
r k
N
j
l k
e r r
N k G A
k o
N k G A
x
The part
1
0 '
' '
2
] ' [
N
r
r k
N
j
e r r
is accomplished applying the fft() function available in Pyton/Numpy or MATLAB . Additionally a
correction factor (1/N) must be applied. And in case there was a scaling factor of A 1 there must be a
gain correction (1/A) for this.
Samples of frequency dependent channel gain G[k'] are obtained from the FFT of the discrete channel
impulse response. The values of the impulse response are stored in array h . Using
G = num.fft.fft(h, N)
just provides the samples G[k'] as array G . In our simplistic simulator the impulse response is fixed.
Hence we only need to compute it once. The same channel applies to all transmitted OFDM symbols.
data_rec = (1/N)*num.fft.fft(ofdm_rec) / G
If all went well data_rec is the sequence of transmitted data symbols x
k,l
. These data blocks can be
further processed to obtain information such as
bit error rate
signal constellation diagrams of individual sub-carriers
etc.
Some examples are provided in the next sub-chapters.
31.03.2008
michael.biester@googlemail.com
22/22
4.9 post processing
Currently the simulation tool only supports display of the constellation diagram (I-/Q plot).
4.9.1 plot constellation diagram of subcarriers