# FM Demodulation to extract Doppler Shift

Started by October 22, 2010
```Good morning,

as part of a masters project I'm currently working on I need to extract the
doppler shift from a digital signal in a DSP.

So far I'm successfully sampling the signal, which is centered at 4.88kHz
with a Doppler shift of about +/- 1.5kHz.

Previously I extracted the Doppler Shift using Matlab's "demod" function
(FM demodulation) which worked quite well. I now implemented a quadrature
mixer and mixed demodulator as described in [1, p57ff] however I can't get
the FM demodulation to work, my outputs just settle at -4001 (Q15) or
-0.1221 (decimal). The DSP I'm using is fixed point only, so I can't go the
"easier" route of implementing this is floating point algebra.

Now instead of spending a lot of time trying to analyse where I'm going
wrong I was wondering what other, possibly easier, methods of simply
extracting the Doppler shift you'd suggest ?

I though about doing an FFT on the data and extracting the Doppler shift
from the FFT. Is this sensible in any way? I'm only interested in "Doppler
shift vs time" for this application.

I'd be really grateful for any pointers towards a simple implementation of
extracting the Doppler shift.

Thanks

Chris

[1]
http://www.medialab.ch/archiv/pdf_studien_diplomarbeiten/da01/da2001-089_FmDemodulator.pdf

```
```This doesn't answer your question about alternative methods but have
you implemented your current algorithm on a PC with perhaps simulated
data? (Both in floating point and fixed point math?)

The idea is that it would be much easier to debug your code on a PC
than on a DSP chip.

Chris
```
```I didn't read the reference so I don't know if this will help. But if
you sum your I and Q channels over some period, and then take
arctan(Q_sum/I_sum) it will produce the average difference in phase of
the sampled signal (-pi/2,pi/2) and the reference signal during that
period. Take the derivative of the phase values over the integration
period and you will get the doppler shift. The integration period will
determine the maximum doppler shift you can detect. From memory I
think it's 1/2T, where T is the integration period.
```
```On 10/22/2010 07:50 AM, Chris Maryan wrote:
> you implemented your current algorithm on a PC with perhaps simulated
> data? (Both in floating point and fixed point math?)
>
> The idea is that it would be much easier to debug your code on a PC
> than on a DSP chip.

Indeed.  Depending on how much of the code you want to keep, you could
do this in Matlab by using a fixed-point type or by quantizing at all
the critical steps (either one would be a pain, with Matlab it may be
easier to do the quantization -- but I'm not a Matlab user).

Doing it in C would work, too, but be aware of integer size differences
if your DSP is a 16 bit machine.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Do you need to implement control loops in software?
"Applied Control Theory for Embedded Systems" was written for you.
See details at http://www.wescottdesign.com/actfes/actfes.html
```
```On 10/22/2010 07:36 AM, Chris87 wrote:
> Good morning,
>
> as part of a masters project I'm currently working on I need to extract the
> doppler shift from a digital signal in a DSP.
>
> So far I'm successfully sampling the signal, which is centered at 4.88kHz
> with a Doppler shift of about +/- 1.5kHz.
>
> Previously I extracted the Doppler Shift using Matlab's "demod" function
> (FM demodulation) which worked quite well. I now implemented a quadrature
> mixer and mixed demodulator as described in [1, p57ff] however I can't get
> the FM demodulation to work, my outputs just settle at -4001 (Q15) or
> -0.1221 (decimal). The DSP I'm using is fixed point only, so I can't go the
> "easier" route of implementing this is floating point algebra.
>
> Now instead of spending a lot of time trying to analyse where I'm going
> wrong I was wondering what other, possibly easier, methods of simply
> extracting the Doppler shift you'd suggest ?
>
> I though about doing an FFT on the data and extracting the Doppler shift
> from the FFT. Is this sensible in any way? I'm only interested in "Doppler
> shift vs time" for this application.
>
> I'd be really grateful for any pointers towards a simple implementation of
> extracting the Doppler shift.
>
> Thanks
>
> Chris
>
> [1]
> http://www.medialab.ch/archiv/pdf_studien_diplomarbeiten/da01/da2001-089_FmDemodulator.pdf

Proposing to do this with an FFT is akin to saying that your bicycle
tire is flat, so you want to get a semi truck and trailer to get from
your dorm to class.  Yes, you can do that, but fixing the problem with
what you have is probably easier.

I'd suggest that you start by writing your own FM demodulator in Matlab,
using floating point.  Use it instead of "demod".  This will make sure
you know how to make the algorithm itself work.

Save a copy of that away in case you need it later, then modify your
working copy to do the same thing in fixed point, in a way that
simulates the action of the data type that you're using on your DSP.

Once you're sure that works, then translate that algorithm to the DSP.
Because you already know the algorithm works, you only have to worry

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Do you need to implement control loops in software?
"Applied Control Theory for Embedded Systems" was written for you.
See details at http://www.wescottdesign.com/actfes/actfes.html
```
```On 10/22/2010 08:57 AM, Brian wrote:
> I didn't read the reference so I don't know if this will help. But if
> you sum your I and Q channels over some period, and then take
> arctan(Q_sum/I_sum) it will produce the average difference in phase of
> the sampled signal (-pi/2,pi/2) and the reference signal during that
> period. Take the derivative of the phase values over the integration
> period and you will get the doppler shift. The integration period will
> determine the maximum doppler shift you can detect. From memory I
> think it's 1/2T, where T is the integration period.

In skimming the reference I found a number of different ways to do this.
I'm not sure if yours was included, but most of the other popular ways
were.

I think the OP's biggest problem is just getting it implemented in fixed
point.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Do you need to implement control loops in software?
"Applied Control Theory for Embedded Systems" was written for you.
See details at http://www.wescottdesign.com/actfes/actfes.html
```
```FM at 4.8kHz ? A 8 bit microcontroller would do.

VLV

Tim Wescott wrote:

> On 10/22/2010 07:36 AM, Chris87 wrote:
>
>> Good morning,
>>
>> as part of a masters project I'm currently working on I need to
>> extract the
>> doppler shift from a digital signal in a DSP.
>>
>> So far I'm successfully sampling the signal, which is centered at 4.88kHz
>> with a Doppler shift of about +/- 1.5kHz.
>>
>> Previously I extracted the Doppler Shift using Matlab's "demod" function
>> (FM demodulation) which worked quite well. I now implemented a quadrature
>> mixer and mixed demodulator as described in [1, p57ff] however I can't
>> get
>> the FM demodulation to work, my outputs just settle at -4001 (Q15) or
>> -0.1221 (decimal). The DSP I'm using is fixed point only, so I can't
>> go the
>> "easier" route of implementing this is floating point algebra.
>>
>> Now instead of spending a lot of time trying to analyse where I'm going
>> wrong I was wondering what other, possibly easier, methods of simply
>> extracting the Doppler shift you'd suggest ?
>>
>> I though about doing an FFT on the data and extracting the Doppler shift
>> from the FFT. Is this sensible in any way? I'm only interested in
>> "Doppler
>> shift vs time" for this application.
>>
>> I'd be really grateful for any pointers towards a simple
>> implementation of
>> extracting the Doppler shift.
>>
>> Thanks
>>
>> Chris
>>
>> [1]
>> http://www.medialab.ch/archiv/pdf_studien_diplomarbeiten/da01/da2001-089_FmDemodulator.pdf
>>
>
>
> Proposing to do this with an FFT is akin to saying that your bicycle
> tire is flat, so you want to get a semi truck and trailer to get from
> your dorm to class.  Yes, you can do that, but fixing the problem with
> what you have is probably easier.
>
> I'd suggest that you start by writing your own FM demodulator in Matlab,
> using floating point.  Use it instead of "demod".  This will make sure
> you know how to make the algorithm itself work.
>
> Save a copy of that away in case you need it later, then modify your
> working copy to do the same thing in fixed point, in a way that
> simulates the action of the data type that you're using on your DSP.
>
> Once you're sure that works, then translate that algorithm to the DSP.
> Because you already know the algorithm works, you only have to worry
>
```
```On 10/22/2010 09:38 AM, Vladimir Vassilevsky wrote:
(top post fixed)
>
>
> Tim Wescott wrote:
>
>> On 10/22/2010 07:36 AM, Chris87 wrote:
>>
>>> Good morning,
>>>
>>> as part of a masters project I'm currently working on I need to
>>> extract the
>>> doppler shift from a digital signal in a DSP.
>>>
>>> So far I'm successfully sampling the signal, which is centered at
>>> 4.88kHz
>>> with a Doppler shift of about +/- 1.5kHz.
>>>
>>> Previously I extracted the Doppler Shift using Matlab's "demod" function
>>> (FM demodulation) which worked quite well. I now implemented a
>>> mixer and mixed demodulator as described in [1, p57ff] however I
>>> can't get
>>> the FM demodulation to work, my outputs just settle at -4001 (Q15) or
>>> -0.1221 (decimal). The DSP I'm using is fixed point only, so I can't
>>> go the
>>> "easier" route of implementing this is floating point algebra.
>>>
>>> Now instead of spending a lot of time trying to analyse where I'm going
>>> wrong I was wondering what other, possibly easier, methods of simply
>>> extracting the Doppler shift you'd suggest ?
>>>
>>> I though about doing an FFT on the data and extracting the Doppler shift
>>> from the FFT. Is this sensible in any way? I'm only interested in
>>> "Doppler
>>> shift vs time" for this application.
>>>
>>> I'd be really grateful for any pointers towards a simple
>>> implementation of
>>> extracting the Doppler shift.
>>>
>>> Thanks
>>>
>>> Chris
>>>
>>> [1]
>>> http://www.medialab.ch/archiv/pdf_studien_diplomarbeiten/da01/da2001-089_FmDemodulator.pdf
>>>
>>
>>
>> Proposing to do this with an FFT is akin to saying that your bicycle
>> tire is flat, so you want to get a semi truck and trailer to get from
>> your dorm to class. Yes, you can do that, but fixing the problem with
>> what you have is probably easier.
>>
>> I'd suggest that you start by writing your own FM demodulator in
>> Matlab, using floating point. Use it instead of "demod". This will
>> make sure you know how to make the algorithm itself work.
>>
>> Save a copy of that away in case you need it later, then modify your
>> working copy to do the same thing in fixed point, in a way that
>> simulates the action of the data type that you're using on your DSP.
>>
>> Once you're sure that works, then translate that algorithm to the DSP.
>> Because you already know the algorithm works, you only have to worry
>>
>
> FM at 4.8kHz ? A 8 bit microcontroller would do.
>
> VLV
>

Good point -- I should have _thought_ about what the frequency implied.
And if an 8-bit micro will do, then one can easily do this with
floating point in a DSP.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Do you need to implement control loops in software?
"Applied Control Theory for Embedded Systems" was written for you.
See details at http://www.wescottdesign.com/actfes/actfes.html
```
```
Tim Wescott wrote:

> On 10/22/2010 09:38 AM, Vladimir Vassilevsky wrote:

>  > FM at 4.8kHz ? A 8 bit microcontroller would do.

> Good point -- I should have _thought_ about what the frequency implied.
>  And if an 8-bit micro will do, then one can easily do this with
> floating point in a DSP.

No. A 8-bit microcontroller would do in the floating point.

VLV

```
```On 10/22/2010 10:40 AM, Vladimir Vassilevsky wrote:
>
>
> Tim Wescott wrote:
>
>> On 10/22/2010 09:38 AM, Vladimir Vassilevsky wrote:
>
>> > FM at 4.8kHz ? A 8 bit microcontroller would do.
>
>> Good point -- I should have _thought_ about what the frequency
>> implied. And if an 8-bit micro will do, then one can easily do this
>> with floating point in a DSP.
>
> No. A 8-bit microcontroller would do in the floating point.

I didn't say it wouldn't, although it'd have to be a new one:
shoe-horning it into the 0.5MIPS machines that were available when I

Trying to do the job using the FFT, as the OP proposed, may bring it out
of the 8-bit class and firmly into DSP territory, however.

The OP's post has "senior project" written all over it, in which case
one of his customer (i.e. advisor) requirements could well be "use this
here eval board".

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Do you need to implement control loops in software?
"Applied Control Theory for Embedded Systems" was written for you.
See details at http://www.wescottdesign.com/actfes/actfes.html
```