DSPRelated.com
Forums

FM demodulation phase unwrapping

Started by mans-34 January 29, 2007
<cincydsp@gmail.com> wrote in message 
news:1170097912.875007.109740@v33g2000cwv.googlegroups.com...


On Jan 29, 1:49 pm, Jerry Avins <j...@ieee.org> wrote:
> cincy...@gmail.com wrote: > > > On Jan 29, 11:43 am, Jerry Avins <j...@ieee.org> wrote: > >> cincy...@gmail.com wrote: ... > > >>> You shouldn't need to "unwrap" your phase value, as it shouldn't ever > >>> break out of the [-pi, pi] interval. ...Doesn't that depend on the > >>> amount of modulation? I know of nothing > >> inherent in FM (PM, actually) that limits the modulation to any > >> particular range. > > >> Jerry > >> -- > >> Engineering is the art of making what you want from things you can get. > >> ??????????????????????????????????????????????????????????????????????? > > > My message was misleading; I should have said that the *frequency* > > value (or the output of the differentiator after you extract the > > phase) shouldn't need to be unwrapped, as it shouldn't ever exceed +/- > > pi; otherwise, you experience aliasing, and you might be observing a > > different frequency than what's actually there, messing up the > > magnitude of the frequency detector output. Sure, your deviation can > > be whatever you want, but what's important is the deviation to sample > > rate ratio, which, for properly sampled signals, will always lie in > > the [-pi, pi] interval. > > > Now that I think about it, the interval should probably be (-pi, pi) > > instead, but it's close enough.Yes. The difference of phase between > > successive sample times is limited. > Is that what the OP is calculating? > > Jerry > -- > Engineering is the art of making what you want from things you can get. > &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
He indicated that he was using the atan() + differentiator method of demodulating the signal, so yes, I think it is what he is calculating. I just pointed out that he shouldn't need to unwrap the phase at all, if he is getting the phase information from an arctangent function. Jason But if I am not unwrapping, the signal has some discontinuity. I am using atan2 in matlab. Here is a sample code: ( In matlab) angle=atan2(i_data,q_data); % unwrap unwrap_angle=unwrap(angle); % diff 1 for n=3:length(angle) dif(n)=-unwrap_angle(n)+unwrap_angle(n-1); end but the dif signal has a lot of discontinuity (even when I unwrap it). Best regards
Jason,

Even if the phase change between samples is very small, if you use=20
atan2 on the I and Q terms (not the ratio with two I and Q terms)=20
there is nothing to prevent a phase discontinuity. For example if the=20
phase progresses from pi-epslon to pi+eplson (the usual small epslon)=20
in one sample the second phase is returned as -pi+epslon and the=20
difference is close to 2*pi, not 2*epslon as desired.

Dirk



On Jan 29, 2:11 pm, cincy...@gmail.com wrote:
> On Jan 29, 1:49 pm, Jerry Avins <j...@ieee.org> wrote: > > > > > > > cincy...@gmail.com wrote: > > > > On Jan 29, 11:43 am, Jerry Avins <j...@ieee.org> wrote: > > >> cincy...@gmail.com wrote: ... > > > >>> You shouldn't need to "unwrap" your phase value, as it shouldn't ev=
er
> > >>> break out of the [-pi, pi] interval. ...Doesn't that depend on the =
amount of modulation? I know of nothing
> > >> inherent in FM (PM, actually) that limits the modulation to any > > >> particular range. > > > >> Jerry > > >> -- > > >> Engineering is the art of making what you want from things you can g=
et.
> > >> ????????????????????????????????????????????????????????????????????=
???
> > > > My message was misleading; I should have said that the *frequency* > > > value (or the output of the differentiator after you extract the > > > phase) shouldn't need to be unwrapped, as it shouldn't ever exceed +/- > > > pi; otherwise, you experience aliasing, and you might be observing a > > > different frequency than what's actually there, messing up the > > > magnitude of the frequency detector output. Sure, your deviation can > > > be whatever you want, but what's important is the deviation to sample > > > rate ratio, which, for properly sampled signals, will always lie in > > > the [-pi, pi] interval. > > > > Now that I think about it, the interval should probably be (-pi, pi) > > > instead, but it's close enough.Yes. The difference of phase between s=
uccessive sample times is limited.
> > Is that what the OP is calculating? > > > Jerry > > -- > > Engineering is the art of making what you want from things you can get. > > =AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=
=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF= =AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AFHe ind= icated that he was using the atan() + differentiator method of
> demodulating the signal, so yes, I think it is what he is calculating. > I just pointed out that he shouldn't need to unwrap the phase at all, > if he is getting the phase information from an arctangent function. > > Jason- Hide quoted text -- Show quoted text -

dbell wrote:

> Jason, > > Even if the phase change between samples is very small, if you use > atan2 on the I and Q terms (not the ratio with two I and Q terms) > there is nothing to prevent a phase discontinuity. For example if the > phase progresses from pi-epslon to pi+eplson (the usual small epslon) > in one sample the second phase is returned as -pi+epslon and the > difference is close to 2*pi, not 2*epslon as desired.
The simplest fix to this is using the integers. I.e. representing (-PI...PI) as 0x800000000...0x7FFFFFFF. The phase wrapping around zero is taken care off automatically. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
"robert bristow-johnson" <rbj@audioimagination.com> wrote in message 
news:1170094852.137998.286470@k78g2000cwa.googlegroups.com...
> > > geez, i hate this new Google groups. i used to be able to preview > messages to see if they wrapped badly (speaking of wrapping). and it > doesn't allow modifying the Subject: header in an existing thread. > talk about lame. Google is getting worse. (are they learning from > the Redmond boys? i sure hope not.) > > what i meant to say is: > > unwrapped phase: > > arg{x[n+1]} = arg{x[n]} + > > arctan( (Im{x[n+1]}*Re{x[n]} - Re{x[n+1]}*Im{x[n]}) / > (Re{x[n+1]}*Re{x[n]} + Im{x[n+1]}*Im{x[n]}) ) > > where x[n] is your complex IF signal. > > the instantaneous frequency deviation (radians per sample) is simply > > f[n] = arg{x[n+1]} - arg{x[n]} > > = arctan( (Im{x[n+1]}*Re{x[n]} - Re{x[n+1]}*Im{x[n]}) / > (Re{x[n+1]}*Re{x[n]} + Im{x[n+1]}*Im{x[n]}) ) > > > the bastards. > > r b-j > >
Thanks for your suggestion. I tried this technique and unfortunately it is not working! The code that I used is as follow: (In matlab) for n=1:length(i_data)-1 dif(n)=(q_data(n+1)*i_data(n) - i_data(n+1)*q_data(n)) / (i_data(n+1) * q_data(n) + q_data(n+1)*q_data(n)); end angle=atan(dif); i_data and Q_data are real and imaginary part of input signal. The output is full of spikes and even using the following command didn't solve the problem: unwrap_angle=unwrap(angle); regards ps: It is not good to attach image files to the posts. Where can I place them so others can see them?

On Jan 29, 3:14 pm, Vladimir Vassilevsky <antispam_bo...@hotmail.com> 
wrote:
> dbell wrote: > > Jason, > > > Even if the phase change between samples is very small, if you use > > atan2 on the I and Q terms (not the ratio with two I and Q terms) > > there is nothing to prevent a phase discontinuity. For example if the > > phase progresses from pi-epslon to pi+eplson (the usual small epslon) > > in one sample the second phase is returned as -pi+epslon and the > > difference is close to 2*pi, not 2*epslon as desired.The simplest fix to this is using the integers. I.e. representing > (-PI...PI) as 0x800000000...0x7FFFFFFF. The phase wrapping around zero > is taken care off automatically. > > Vladimir Vassilevsky > > DSP and Mixed Signal Design Consultant > > http://www.abvolt.com
Yes, there is a modulo-2*pi step that has to be taken into account; the receiver has to be smart enough to recognize that 2*pi and 0 are the same angle and so on. I envisioned a fixed-point system where the angle will be represented by an integer; Vladimir's solution, or any other like it where the highest-allowed angle value is a power of 2 minus 1, lets the numbers take care of it for you, with only some bitmasking required if your wordlength is greater than the number of bits you're actually using for the angle. Jason
"Vladimir Vassilevsky" <antispam_bogus@hotmail.com> wrote in message 
news:FAsvh.23530$yC5.18562@newssvr27.news.prodigy.net...
> > > dbell wrote: > >> Jason, >> >> Even if the phase change between samples is very small, if you use atan2 >> on the I and Q terms (not the ratio with two I and Q terms) there is >> nothing to prevent a phase discontinuity. For example if the phase >> progresses from pi-epslon to pi+eplson (the usual small epslon) in one >> sample the second phase is returned as -pi+epslon and the difference is >> close to 2*pi, not 2*epslon as desired. > > The simplest fix to this is using the integers. I.e. representing > (-PI...PI) as 0x800000000...0x7FFFFFFF. The phase wrapping around zero is > taken care off automatically. > > Vladimir Vassilevsky > > DSP and Mixed Signal Design Consultant > > http://www.abvolt.com
Thanks Vladimir, Your technique is very interesting but I can not think of any way to implement it in software. any suggestion? Regards
Vladimir,

The phase wrapping is not around 0, it is around pi and -pi.

Dirk


On Jan 29, 3:14 pm, Vladimir Vassilevsky <antispam_bo...@hotmail.com> 
wrote:
> dbell wrote: > > Jason, > > > Even if the phase change between samples is very small, if you use > > atan2 on the I and Q terms (not the ratio with two I and Q terms) > > there is nothing to prevent a phase discontinuity. For example if the > > phase progresses from pi-epslon to pi+eplson (the usual small epslon) > > in one sample the second phase is returned as -pi+epslon and the > > difference is close to 2*pi, not 2*epslon as desired.The simplest fix to this is using the integers. I.e. representing > (-PI...PI) as 0x800000000...0x7FFFFFFF. The phase wrapping around zero > is taken care off automatically. > > Vladimir Vassilevsky > > DSP and Mixed Signal Design Consultant > > http://www.abvolt.com

mans-34 wrote:

>>The simplest fix to this is using the integers. I.e. representing >>(-PI...PI) as 0x800000000...0x7FFFFFFF. The phase wrapping around zero is >>taken care off automatically. >> > Thanks Vladimir, > Your technique is very interesting but I can not think of any way to > implement it in software. any suggestion?
const s32 MAX_S32 = 0x7FFFFFFF; const f32 PI = 3.141592653; const f32 radians_to_int = MAX_S32/PI; { ... static s32 prev_fi; f32 fi = atan2(Q,I); s32 fi_int = (s32)(fi*radians_to_int); s32 d_fi = fi_int - prev_fi_int; prev_fi_int = fi_int; So on, so forth... Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com

dbell wrote:

 >>(-PI...PI) as 0x800000000...0x7FFFFFFF. The phase wrapping around zero
 >>is taken care off automatically.
> > The phase wrapping is not around 0, it is around pi and -pi.
It doesn't matter. The integer math takes care of that. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
Fitlike Min wrote:
> "mans-34" <use_my_name_here@blueyonder.co.uk> wrote in message > news:bMnvh.170727$QY6.3423@fe1.news.blueyonder.co.uk... >> Hello, >> >> I did some simulation to develop an FM demodulator. I used Simulink > for >> modeling. >> >> >> >> I create a 40 MHZ carrier signal modulated with 1K data signal and sampled >> at 102.4 M sample per cycle. >> >> The signal is then feed into a FIR filter to make IQ signal. >> >> I used Atan and unwrap and differentiator to demodulate the signal and I > was >> able to successfully demodulate it. >> >> >> >> Now I want to see what the effect is if I down sample the signal. >> >> To do this I down sampled the signal IQ signal by 102 to get approximately > a >> signal that is sampled by 1MHZ. I was again success full in demodulation. >> >> >> >> I down sampled by 2048 to make the sampling rate 50KHz. Now it seems that >> the "unwrap" doesn't function properly. >> >> >> >> How sampling rate effecting unwrapping and how I can solve it? >> >> >> >> Best regards >> >> > > If you have I and Q you don't need atan at all. Use > > (IQ'-QI')/(I^2+Q^2) where ' is differentiate.
Be sure to refer everything -- I, Q, I', and Q' -- to the same instant. Jerry -- Engineering is the art of making what you want from things you can get. &macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;