# Quadrature demodulation of FM

**URL:** <https://www.ruby-forum.com/t/quadrature-demodulation-of-fm/133116>\
**Category:** GNU Radio\
**Created:** [March 28, 2008, 12:59am UTC](https://www.ruby-forum.com/t/quadrature-demodulation-of-fm/133116 "2008-03-28T00:59:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonathon\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8e7dd6/32.png) [@Jonathon\_P](https://www.ruby-forum.com/u/Jonathon_P)\
**Post date:** [March 28, 2008, 12:59am UTC](https://www.ruby-forum.com/t/quadrature-demodulation-of-fm/133116/1 "2008-03-28T00:59:48Z")

</div>

Before I ask my question, I’d like to thank everyone that’s been helping  
me  
out. I (and my peers at Purdue) are just starting out with the USRP and  
really appreciate the support.

On to my question, I wrote a demodulation block for FM that uses a  
method  
different than the provided quadrature\_demod\_cf block. Here is a block  
diagram of what I’m attempting:  
[http://pico.iis.u-tokyo.ac.jp/media/9/20060626-SQD-princ.jpg](http://pico.iis.u-tokyo.ac.jp/media/9/20060626-SQD-princ.jpg). I can  
record  
data from the USRP and successfully demodulate FM radio in MATLAB using  
this  
technique. However, I cannot accomplish this with my signal processing  
block  
I wrote. To test my block, I use the example wideband FM receiver code,  
usrp\_wfm\_rcv.py, and basically insert my demodulation block in place of  
the  
provided demodulation block.

Here is the work code I made, note it is just a small modification of  
quadrature\_demod\_cf.cc:

int gr\_quad\_demod\_baseband::work (int noutput\_items,  
gr\_vector\_const\_void\_star &input\_items,  
gr\_vector\_void\_star &output\_items)  
{  
gr\_complex \*in = (gr\_complex \*) input\_items[0];  
float \*out = (float \*) output\_items[0];  
in++; // ensure that in[-1] is valid

```
for (int i = 0; i < noutput_items; i++){
    float I_1 = real(in[i-1]);
    float I_2 = real(in[i]);
    float Q_1 = imag(in[i-1]);
    float Q_2 = imag(in[i]);

    float dI = I_1 - I_2;
    float dQ = Q_1 - Q_2;

    float dQxI = dQ*I_1;
    float dIxQ = dI*Q_1;

    out[i] = d_gain*(dIxQ - dQxI);
}

return noutput_items;

```

}

The demodulation is really simple and if you do not get it at first,  
please  
check out the link to the block diagram. On a final note, my block is  
also  
running very slowly. I continuously get overrun notifications (I believe  
that is the meaning of uO). I think I am quite close to the answer, I  
just  
need a little guidance. Anyone have any suggestions? Thanks in advance!

Jon Pendlum  
Purdue University Undergraduate Student

---

<div class="post-metadata">

**Author:** ![Jonathon\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8e7dd6/32.png) [@Jonathon\_P](https://www.ruby-forum.com/u/Jonathon_P)\
**Post date:** [March 29, 2008, 2:16pm UTC](https://www.ruby-forum.com/t/quadrature-demodulation-of-fm/133116/2 "2008-03-29T14:16:51Z")

</div>

I think you want to look at Richard Lyon’s book on DSP, Fig 13-61(b).  
The book should be on the recommended reading list for GNU Radio. I  
think this is an implementation of the algorithm you are trying to  
implement.

I’ve used this method successfully with the OSSIE SCA code from VT.  
Unfortunately that code is behind a silly click through system, but  
I’m copying this code to an open repository next week. If you have  
more questions, email me next week.

Philip
