# OFDM, symbol/phase synchronization, demodulation

Started by September 29, 2011
```Hello,

I recently found myself interested in digital modulation techniques.
For a hobby project I plan to implement modulation and demodulation so
I can later test it using soundcards for transmitting little text
messages via sound between neighbouring laptops. The main goal is to
learn something and have fun -- not to build something useful. I'm
sure some of you could provide valuable suggestens as for how I could
optimize modulation and demodulation.

Basically, what I've implemented so far is an "OFDM symbol generator".
It takes phases and amplitudes for each subcarrier (phases in
reference to some imaginary reference oscillators) and creates a block
of samples via inverse FFT coupled with a bit of cross-fading between
symbols (to keep the spectrum narrow) and copying for the guard
interval. The phases and amplitudes I plan to feed into this OFDM
symbol generator are based on the pi/4-DQPSK modulation. Since I'm
aware of how a channel might include things like echos I know that I
can expect to see different amplitudes and phases at the receiver
side. So, DQPSK seems like the easy way out of that one. But I still
have to do symbol synchronization at the receiver somehow.
Unfortunately, I havn't found much information on how to do OFDM
symbol synchronization. Due to the way I set up the subcarrier
frequencies and the guard interval, I know that the beginning of an
OFDM symbol will match its ending (modulo noise). So, my idea was to
combine two simple "filters":
(1) q[n] = square(s[n] - s[n-FFT_SIZE]) // squared differences
(2) moving average on q with window length = guard interval size
Then, I expect the resulting signal to be a noisy version of a signal
that has many local minima which are spaced FFT_SIZE+guard_interval
samples apart. The pi/4 shift in pi/4-DQPSK should help avoid "false
positives" during this kind of symbol synchronization, I think. These
minima will tell me where the guard interval of the previous symbol
ended and where the next symbol will start (right?) I havn't yet
implemented the demodulation and synchronization but I thought I
should probably start a discussion here before I implement something
that is known to be done much better with a totally different
approach. So, please comment on my current approach and where things
could be done better.

In addition, I would like to know how "phase/amplitude"
synchronization is done. I will probably be interested in increasing
the spectral efficiency by switching to 16-APSK or 64-QAM or something
like this. I just don't see how I can get around phase synchronization
with these kinds of modulation techniques. How is this done in
reality? Is it done on a frame-basis where special phase
synchronization OFDM symbols are introduced as part of a frame and
phase is measured in reference to this symbol? I read something about
a power-4 method but so far, I don't really know how that is supposed
to work. To be able to discriminate between different amplitude levels
I could also compare the frame's remaining OFDM symbols to the same
"reference symbol". But I don't think it's a good idea to rely on that
entirely due to noise or moving senders/receivers. Any hints or
pointers would be much appreciated!

Cheers!
SG
```
```Sebastian <s.gesemann@gmail.com> wrote:
> The phases and amplitudes I plan to feed into this OFDM
> symbol generator are based on the pi/4-DQPSK modulation. Since I'm
> aware of how a channel might include things like echos I know that I
> can expect to see different amplitudes and phases at the receiver
> side. So, DQPSK seems like the easy way out of that one. But I still
> have to do symbol synchronization at the receiver somehow.

The story I remember, from analog modem and PLL days, is that you
filter for twice the symbol rate, and run that into a PLL.  Assuming
sufficient phase changes, the reason for the bit scrambler, there
will be a signal to lock onto.  You should be able to test this by
computing the Fourier transform (or series) for two symbols with
different phases.

-- glen
```
```On 29 Sep, 19:17, Sebastian <s.gesem...@gmail.com> wrote:
> Hello,
>
> I recently found myself interested in digital modulation techniques.
> For a hobby project I plan to implement modulation and demodulation so
> I can later test it using soundcards for transmitting little text
> messages via sound between neighbouring laptops. The main goal is to
> learn something and have fun -- not to build something useful. I'm
> sure some of you could provide valuable suggestens as for how I could
> optimize modulation and demodulation.
>
> Basically, what I've implemented so far is an "OFDM symbol generator".
> It takes phases and amplitudes for each subcarrier (phases in
> reference to some imaginary reference oscillators) and creates a block
> of samples via inverse FFT coupled with a bit of cross-fading between
> symbols (to keep the spectrum narrow) and copying for the guard
> interval. The phases and amplitudes I plan to feed into this OFDM
> symbol generator are based on the pi/4-DQPSK modulation. Since I'm
> aware of how a channel might include things like echos I know that I
> can expect to see different amplitudes and phases at the receiver
> side. So, DQPSK seems like the easy way out of that one. But I still
> have to do symbol synchronization at the receiver somehow.
> Unfortunately, I havn't found much information on how to do OFDM
> symbol synchronization. Due to the way I set up the subcarrier
> frequencies and the guard interval, I know that the beginning of an
> OFDM symbol will match its ending (modulo noise). So, my idea was to
> combine two simple "filters":
> (1) q[n] = square(s[n] - s[n-FFT_SIZE]) // squared differences
> (2) moving average on q with window length = guard interval size
> Then, I expect the resulting signal to be a noisy version of a signal
> that has many local minima which are spaced FFT_SIZE+guard_interval
> samples apart. The pi/4 shift in pi/4-DQPSK should help avoid "false
> positives" during this kind of symbol synchronization, I think. These
> minima will tell me where the guard interval of the previous symbol
> ended and where the next symbol will start (right?) I havn't yet
> implemented the demodulation and synchronization but I thought I
> should probably start a discussion here before I implement something
> that is known to be done much better with a totally different
> approach. So, please comment on my current approach and where things
> could be done better.
>
> In addition, I would like to know how "phase/amplitude"
> synchronization is done. I will probably be interested in increasing
> the spectral efficiency by switching to 16-APSK or 64-QAM or something
> like this. I just don't see how I can get around phase synchronization
> with these kinds of modulation techniques. How is this done in
> reality? Is it done on a frame-basis where special phase
> synchronization OFDM symbols are introduced as part of a frame and
> phase is measured in reference to this symbol? I read something about
> a power-4 method but so far, I don't really know how that is supposed
> to work. To be able to discriminate between different amplitude levels
> I could also compare the frame's remaining OFDM symbols to the same
> "reference symbol". But I don't think it's a good idea to rely on that
> entirely due to noise or moving senders/receivers. Any hints or
> pointers would be much appreciated!
>
> Cheers!
> SG

Hi
You're on the right track!
But I would rather try:
(1) q[n] = s[n] * conj(s[n-FFT_SIZE])
(2) As you suggested.
That is, use correlation instead of squared difference.

For burst transmission you normally use both frame synchronization
(to find the transmission) and then symbol synchronize as necessary.

For "phase synchronization" I guess you are meaning a coherent
demodulator. One solution is to use a pilot tone, or a known
sequence. My suggestion is to concentrate on a differential
demodulator and maybe later a coherent version.

--
Good luck
```
```Hi,

basic OFDM in audio is not a good idea, because audio signals are supposed
to have much more energy at low frequencies. This will limit your transmit
power and / or make everybodys' ears ring.
You'll also run soon into multi-path effects from reverberations.

What you can do as a single synchronization scheme is to transmit a known
"pilot symbol" and use a sliding window correlator for initial
synchronization. Then, re-transmit at known intervals, track the timing and
use known / actual pilot symbol for channel estimation purposes. A
conventional (not symbol-synchronized) fft-based filter may be the right
tool, depending on your symbol size.

With consumer audio equipment, frequency error can be quite annoying
("annoying" in a sense that you need to cope with it right from the start
to get -anything- working). This can be avoided by prototyping on -one- PC,
using full-duplex with speaker and microphone, for example using portaudio
library: http://www.dsprelated.com/showcoderequest/29.php
```
```>> single synchronization scheme
doh. make that "simple" synchronization scheme...
```
```Sebastian schrieb:
> Hello,
>
> I recently found myself interested in digital modulation techniques.
> For a hobby project I plan to implement modulation and demodulation so
> I can later test it using soundcards for transmitting little text
> messages via sound between neighbouring laptops. The main goal is to
> learn something and have fun -- not to build something useful. I'm
> sure some of you could provide valuable suggestens as for how I could
> optimize modulation and demodulation.
>
> Basically, what I've implemented so far is an "OFDM symbol generator".
> It takes phases and amplitudes for each subcarrier (phases in
> reference to some imaginary reference oscillators) and creates a block
> of samples via inverse FFT coupled with a bit of cross-fading between
> symbols (to keep the spectrum narrow) and copying for the guard
> interval. The phases and amplitudes I plan to feed into this OFDM
> symbol generator are based on the pi/4-DQPSK modulation. Since I'm
> aware of how a channel might include things like echos I know that I
> can expect to see different amplitudes and phases at the receiver
> side. So, DQPSK seems like the easy way out of that one. But I still
> have to do symbol synchronization at the receiver somehow.
> Unfortunately, I havn't found much information on how to do OFDM
> symbol synchronization. Due to the way I set up the subcarrier
> frequencies and the guard interval, I know that the beginning of an
> OFDM symbol will match its ending (modulo noise). So, my idea was to
> combine two simple "filters":
> (1) q[n] = square(s[n] - s[n-FFT_SIZE]) // squared differences
> (2) moving average on q with window length = guard interval size
> Then, I expect the resulting signal to be a noisy version of a signal
> that has many local minima which are spaced FFT_SIZE+guard_interval
> samples apart. The pi/4 shift in pi/4-DQPSK should help avoid "false
> positives" during this kind of symbol synchronization, I think. These
> minima will tell me where the guard interval of the previous symbol
> ended and where the next symbol will start (right?) I havn't yet
> implemented the demodulation and synchronization but I thought I
> should probably start a discussion here before I implement something
> that is known to be done much better with a totally different
> approach. So, please comment on my current approach and where things
> could be done better.
>
> In addition, I would like to know how "phase/amplitude"
> synchronization is done. I will probably be interested in increasing
> the spectral efficiency by switching to 16-APSK or 64-QAM or something
> like this. I just don't see how I can get around phase synchronization
> with these kinds of modulation techniques. How is this done in
> reality? Is it done on a frame-basis where special phase
> synchronization OFDM symbols are introduced as part of a frame and
> phase is measured in reference to this symbol? I read something about
> a power-4 method but so far, I don't really know how that is supposed
> to work. To be able to discriminate between different amplitude levels
> I could also compare the frame's remaining OFDM symbols to the same
> "reference symbol". But I don't think it's a good idea to rely on that
> entirely due to noise or moving senders/receivers. Any hints or
> pointers would be much appreciated!
>
> Cheers!
> SG

I am not sure if it is the optimal way but the comm standards I have
came across usally use a defined symbol sequence (called preamble google
might have something on that) for synchronization. The idea is that your
data is transmitted in frames and each frame starts with this preamble.
Synchronization is than achieved by correlating the received data
against the expected preamble and synchronizing to the peak in the
time-domain. (Frequency synchronization can also involve preambles but
is more complicated so I can't remember the details)

Greetz,

Sebastian
```
```On Thu, 29 Sep 2011 10:17:05 -0700 (PDT), Sebastian
<s.gesemann@gmail.com> wrote:

>Hello,
>
>I recently found myself interested in digital modulation techniques.
>For a hobby project I plan to implement modulation and demodulation so
>I can later test it using soundcards for transmitting little text
>messages via sound between neighbouring laptops. The main goal is to
>learn something and have fun -- not to build something useful. I'm
>sure some of you could provide valuable suggestens as for how I could
>optimize modulation and demodulation.
>
>Basically, what I've implemented so far is an "OFDM symbol generator".
>It takes phases and amplitudes for each subcarrier (phases in
>reference to some imaginary reference oscillators) and creates a block
>of samples via inverse FFT coupled with a bit of cross-fading between
>symbols (to keep the spectrum narrow) and copying for the guard
>interval. The phases and amplitudes I plan to feed into this OFDM
>symbol generator are based on the pi/4-DQPSK modulation. Since I'm
>aware of how a channel might include things like echos I know that I
>can expect to see different amplitudes and phases at the receiver
>side. So, DQPSK seems like the easy way out of that one. But I still
>have to do symbol synchronization at the receiver somehow.
>Unfortunately, I havn't found much information on how to do OFDM
>symbol synchronization. Due to the way I set up the subcarrier
>frequencies and the guard interval, I know that the beginning of an
>OFDM symbol will match its ending (modulo noise). So, my idea was to
>combine two simple "filters":
>(1) q[n] = square(s[n] - s[n-FFT_SIZE]) // squared differences
>(2) moving average on q with window length = guard interval size
>Then, I expect the resulting signal to be a noisy version of a signal
>that has many local minima which are spaced FFT_SIZE+guard_interval
>samples apart. The pi/4 shift in pi/4-DQPSK should help avoid "false
>positives" during this kind of symbol synchronization, I think. These
>minima will tell me where the guard interval of the previous symbol
>ended and where the next symbol will start (right?) I havn't yet
>implemented the demodulation and synchronization but I thought I
>should probably start a discussion here before I implement something
>that is known to be done much better with a totally different
>approach. So, please comment on my current approach and where things
>could be done better.

As mentioned previously, a correlator works well to match the guard
interval with its copy N sample later.    This is commonly done for
symbol synchronization.   I'm surprised you haven't seen it in a
literature search as it is usually described in basic OFDM tutorials
that describe synchronization.   Regardless, that's a good approach
and should work well enough.

>In addition, I would like to know how "phase/amplitude"
>synchronization is done. I will probably be interested in increasing
>the spectral efficiency by switching to 16-APSK or 64-QAM or something
>like this. I just don't see how I can get around phase synchronization
>with these kinds of modulation techniques. How is this done in
>reality? Is it done on a frame-basis where special phase
>synchronization OFDM symbols are introduced as part of a frame and
>phase is measured in reference to this symbol? I read something about
>a power-4 method but so far, I don't really know how that is supposed
>to work. To be able to discriminate between different amplitude levels
>I could also compare the frame's remaining OFDM symbols to the same
>"reference symbol". But I don't think it's a good idea to rely on that
>entirely due to noise or moving senders/receivers. Any hints or
>pointers would be much appreciated!

Also as previously mentioned, pilot tones work well for this.   The
pilot tones need to be spread around enough that the phase reference
for each subcarrier can be interpolated from them.   Naturally there
are additional things that can be done, like tracking the phase from
previous symbols, using differential modulation as you suggested,
etc., etc.   There are a number of ways to arrange the pilot symbols,
and how dense they need to be may depend on the types of channels you
expect to encounter or want to be able to handle.   Look at references
describing 802.11a/g and DVB-T to see two very different ways of
accomplishing essentially the same thing.

Eric Jacobsen
Anchor Hill Communications
www.anchorhill.com
```
```glen herrmannsfeldt <gah@ugcs.caltech.edu> wrote:

(snip, I wrote)
> The story I remember, from analog modem and PLL days, is that you
> filter for twice the symbol rate, and run that into a PLL.  Assuming
> sufficient phase changes, the reason for the bit scrambler, there
> will be a signal to lock onto.  You should be able to test this by
> computing the Fourier transform (or series) for two symbols with
> different phases.

It think I forgot a step.  You rectify it first (absolute value)
which generates the appropriate second harmonic.  Then filter and PLL.

-- glen
```
```On 30 Sep., 00:21, glen herrmannsfeldt wrote:
> glen herrmannsfeldt <g...@ugcs.caltech.edu> wrote:
>
> (snip, I wrote)
>
> > The story I remember, from analog modem and PLL days, is that you
> > filter for twice the symbol rate, and run that into a PLL. &#2013266080;Assuming
> > sufficient phase changes, the reason for the bit scrambler, there
> > will be a signal to lock onto. &#2013266080;You should be able to test this by
> > computing the Fourier transform (or series) for two symbols with
> > different phases.
>
> It think I forgot a step. &#2013266080;You rectify it first (absolute value)
> which generates the appropriate second harmonic. &#2013266080;Then filter and PLL.

Thanks for sharing. I don't fully understand what you are suggesting,
though. But it does feel like it's not applicable to the OFDM case.

Cheers!
SG
```
```On 29 Sep., 20:57, "mnentwig" wrote:
>
> basic OFDM in audio is not a good idea, because audio signals are supposed
> to have much more energy at low frequencies. This will limit your transmit
> power and / or make everybodys' ears ring.

I can live with that. I don't have to use speakers and microphones.
I'll probably try it first with a cable connecting sound out to sound
in. And before that, I'll test it "offline" on a file basis (*.wav) or
something like that. My goal is to learn something about digital
modulation the way it's applied in radio. From what I can tell, OFDM
is quite popular in this area.

> You'll also run soon into multi-path effects from reverberations.

That's what the OFDM's guard interval is for, is it not? Together with
a differential phase modulation I don't expect to see big problems
there. I havn't yet thought about how much reverberation to expect. I
think I can deal with it later by appropriately selecting OFDM
parameters (guard interval, subcarrier spacing, symbol length).

> What you can do as a simple synchronization scheme is to transmit a known
> "pilot symbol" and use a sliding window correlator for initial
> synchronization.

I'm not sure about whether this is a good idea considering channels
with nonlinear phase response.

> With consumer audio equipment, frequency error can be quite annoying
> ("annoying" in a sense that you need to cope with it right from the start
> to get -anything- working).

Do you mean slightly differing sampling rates between DAC and ADC? I
wouldn't have expected the differences to be so big that OFDM would
require prior adaptive resampling / frequency synchronization in this
case. But I do plan to make it robust against frequency shifts which
-- as far as I understand -- is an issue in radio w.r.t. the doppler
effect or mixers running at slightly different frequencies.

Thank you for responding.

Cheers!
SG
```