# Re: Phase demodulation

**URL:** <https://www.ruby-forum.com/t/re-phase-demodulation/212577>\
**Category:** GNU Radio\
**Created:** [October 6, 2011, 8:35pm UTC](https://www.ruby-forum.com/t/re-phase-demodulation/212577 "2011-10-06T20:35:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [October 6, 2011, 8:35pm UTC](https://www.ruby-forum.com/t/re-phase-demodulation/212577/1 "2011-10-06T20:35:11Z")

</div>

arctan (imag(out)/real(out)) plus some filtering to remove out of band  
noise (it would be nice also to make sure you avoid discontinuities  
inherent in the arctan function)…

Achilleas

---

<div class="post-metadata">

**Author:** ![Achilleas\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/74df32/32.png) [@Achilleas\_A](https://www.ruby-forum.com/u/Achilleas_A)\
**Post date:** [October 7, 2011, 11:41am UTC](https://www.ruby-forum.com/t/re-phase-demodulation/212577/2 "2011-10-07T11:41:38Z")

</div>

Achilleas A. wrote:

> arctan (imag(out)/real(out)) plus some filtering to remove out of band  
> noise (it would be nice also to make sure you avoid discontinuities  
> inherent in the arctan function)…

I would like to add that you should use four quadrant arctan, i.e. add  
or subtract pi to the above if the real part is negative.

Regards  
/Mikael Olofsson  
Universitetslektor (Associate Professor)  
Linkpings universitet

---

<div class="post-metadata">

**Author:** ![Achilleas\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/74df32/32.png) [@Achilleas\_A](https://www.ruby-forum.com/u/Achilleas_A)\
**Post date:** [October 7, 2011, 4:09pm UTC](https://www.ruby-forum.com/t/re-phase-demodulation/212577/3 "2011-10-07T16:09:00Z")

</div>

Just to make a note on the more theoretical aspect of this problem:

If you want to avoid all complications arising from the discontinuous  
arctan, you can (and technically/theoretically you should)  
work with the actual incoming signal r(t)=exp(j theta(t)) + n(t)  
and its hypothesized estimate s\_hat(t) = exp(j theta\_hat(t)),  
and minimize their Euclidean distance (over a horizon T) under the  
constraints (bandwidth) of your signal theta\_hat(t).  
What this boils down to is:

find theta\_hat(t) satisfying the BW constraints that maximizes  
the quantity sum\_{t=1}^T |r(t)| cos[arg(r(t))-theta\_hat(t)].

BTW, the fine point above is that you cannot set theta\_hat(t)=arg(r(t)),  
because this assignment does NOT satisfy the BW constraints of your  
initial signal theta(t) or theta\_hat(t).

This maximization problem is solved APPROXIMATELY using a PLL which is  
implemented in gnuradio in various forms.

Also the algorithms suggested earlier (evaluate arctan() and smooth it)  
can be thought of as approximate solutions of the above problem.

Achilleas

---

<div class="post-metadata">

**Author:** ![Achilleas\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/74df32/32.png) [@Achilleas\_A](https://www.ruby-forum.com/u/Achilleas_A)\
**Post date:** [October 10, 2011, 10:25am UTC](https://www.ruby-forum.com/t/re-phase-demodulation/212577/4 "2011-10-10T10:25:52Z")

</div>

Which, of course is completely true.

/Mikael

---

<div class="post-metadata">

**Author:** ![Achilleas\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/74df32/32.png) [@Achilleas\_A](https://www.ruby-forum.com/u/Achilleas_A)\
**Post date:** [October 11, 2011, 3:48pm UTC](https://www.ruby-forum.com/t/re-phase-demodulation/212577/5 "2011-10-11T15:48:37Z")

</div>

Could you elaborate on this statement?

BTW, the fine point above is that you cannot set theta\_hat(t)=arg(r(t)),

> because this assignment does NOT satisfy the BW constraints of your initial  
> signal theta(t) or theta\_hat(t).

Are you saying that theta\_hat(t) should be quantized, and therefore not  
set  
directly to arg(r(t))? Thanks.  
-William

On Fri, Oct 7, 2011 at 10:08 AM, Achilleas A.  
\<[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
