Reply by Ray Andraka January 31, 20072007-01-31
dbell wrote:

> 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 > >
Yes, and by remapping the angle into 2's complement binary angle measures (BAMs) as Vladimir has shown so that 0x8000... is equivalent to -pi and 0x7fff... is equivalent to +pi-delta, adding delta to the the most positive value will take care of the wrap for you. Basically, it is taking advantage of the modularity of the 2's complement number system to perform the mod function for you without an explicit operation.
Reply by Martin Eisenberg January 30, 20072007-01-30
mans-34 wrote:

> 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));
The first 'q' in the denominator should be an 'i'.
> angle=atan(dif);
According to rbj's formula, a better name for this variable might be angledif or something.
> ps: It is not good to attach image files to the posts. Where can > I place them so others can see them?
http://www.google.com/search?q=image+hosting+free Martin -- Quidquid latine scriptum est, altum videtur.
Reply by Jerry Avins January 30, 20072007-01-30
robert bristow-johnson wrote:
> > On Jan 29, 1:54 pm, Jerry Avins <j...@ieee.org> wrote: >> robert bristow-johnson wrote: >> >>> geez, i hate this new Google groups. i used to be able to preview >>> messages to see if they wrapped badly (speaking of wrapping). I recall that there is a way. Do you want me to figure it out again, or >> is that enough? >> > > yeah, could you check that out, Jerry? i can't figger it out. (and > it really is crapping up anything i type in with "ASCII math".)
I did. I went to Googls and nothing was familiar. I posted a reply to that effect, but I see it isn't here. I guess I haven't yet learned how to hit "Send". Jerry -- Engineering is the art of making what you want from things you can get.
Reply by robert bristow-johnson January 30, 20072007-01-30

On Jan 29, 1:54 pm, Jerry Avins <j...@ieee.org> wrote:
> robert bristow-johnson wrote: > > > geez, i hate this new Google groups. i used to be able to preview > > messages to see if they wrapped badly (speaking of wrapping). I recall that there is a way. Do you want me to figure it out again, or > is that enough? >
yeah, could you check that out, Jerry? i can't figger it out. (and it really is crapping up anything i type in with "ASCII math".) r b-j
Reply by robert bristow-johnson January 29, 20072007-01-29

On Jan 29, 3:36 pm, "mans-34" <use_my_name_h...@blueyonder.co.uk> 
wrote:
> > > r b-j Thanks for your suggestion. I tried this technique and unfortunately it is > not working!
hmmm. it is possible that the phase changes by more than pi/2 radians in a single sample?
> 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);
actually, MATLAB has an angle function which they define as angle(z) = imag(log(z)) or angle(z) = atan2(imag(z),real(z)) for complex z. so try it with a different vector name than "angle" since it is a keyword in MATLAB. if it still is a problem, try delta_angle(n) = atan2( (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)) ); if that doesn't do it right, i have no idea what to do.
> ps: It is not good to attach image files to the posts. Where can I place > them so others can see them?
i have no idea. i dunno, maybe upload it to Wikipedia, but it's against policy and they'll eventually delete them if they don't go into an article.
Reply by Jerry Avins January 29, 20072007-01-29
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;
Reply by Vladimir Vassilevsky January 29, 20072007-01-29

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
Reply by Vladimir Vassilevsky January 29, 20072007-01-29

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
Reply by dbell January 29, 20072007-01-29
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
Reply by mans-34 January 29, 20072007-01-29
"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