DSPRelated.com
Forums

A Stupid FM Demod Question?

Started by Randy Yates April 3, 2007
If you scale the phase to the full width of your data word, i.e. Pi = 32767
for 16-bit, then the subtraction is automatically modulo Pi and there is no
issue. For example,

x(0) = -.9Pi
x(1)  = .9Pi

then x(1)-x(0) = 1.8Pi which is -.2Pi because of the overflow.

-Clark



Randy Yates wrote:

>>The straightforward way would be not to use the phase >>representation. Work with the complex derivatives directly: >> >>IdQ/dt - QdI/dt >>--------------- >>I^2 + Q^2 > > > I guess the key advantage is that you don't have to implement an > arctan function?
Atan is not that big of a deal. What is bad is that you have to do the costly division no matter if you are using atan() or not. What is good is that with I' and Q' there is no phase wrapping problem.
> Would you use an FIR differentiator to get Q' and I', making sure > they're properly time-aligned with the I and Q values?
Almost certainly. It is the matter of the sample rate and the accuracy required. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
Randy Yates wrote:
> "robert bristow-johnson" <rbj@audioimagination.com> writes: > > > > > omega[n] = arg{ I[n] + j*Q[n] } - arg{ I[n-1] + j*Q[n-1] } > > > > = arctan( Q[n]/I[n] ) - arctan( Q[n-1]/I[n-1] ) > > > > = arctan( (Q[n]*I[n-1] - I[n]*Q[n-1]) > > / (I[n]*I[n-1] + Q[n]*Q[n-1]) ) > > How did you get from the second line to the third?
there is some trig identity, i think it's tan(x-y) = (tan(x) - tan(y))/(1 + tan(x)*tan(y)) you can arctan() both sides and get x - y = arctan( (tan(x) - tan(y))/(1 + tan(x)*tan(y)) ) define u = tan(x) v = tan(y) arctan(u) - arctan(v) = arctan( (u - v)/(1 + u*v) ) all this is only guaranteed for when all of the angles are between +/- pi/2, but another way to look at it is: omega[n] = arg{ I[n] + j*Q[n] } - arg{ I[n-1] + j*Q[n-1] } = arg{ (I[n] + j*Q[n]) / (I[n-1] + j*Q[n-1]) } and you can blast it out from there. and here the only assumption you need to make is that this arg{} is between +/- pi/2 which is actually quite reasonable. it means your FM instantaneous frequency is less than 1/2 Nyquist which is something i think should be done since FM generates a lot of frequency components that can fold over unless you make the instantaneous frequency much lower than Nyquist.
> > the measure omega[n] is simple that of how much the phase of I + j*Q > > has advanced from the phase of the previous sample. isn't that what > > frequency is? how much (in a given period of time) the phase angle > > advances? > > I always thought that frequency is the derivative of phase, f = dtheta/dt. > That's the gist of my question. Do I need to perform a full derivative > or is theta2 - theta1 perfect or good enough?
well, if omega[n] is constant, then both are equivalent. but you're probably right. the theta[n] - theta[n-1] thing *does* represent the instantaneous frequency somewhere between samples n and n-1.
> Seems like, going back to first semester calculus, theta2-theta1 > is the average slope in the period t1 to t2, and that the true > instantaneous slope would be dtheta/dt.
it's just a matter of how small t2-t1 is and/or how small omega is r b-j
On Apr 4, 9:03 am, "cpope" <cep...@nc.rr.com> wrote:
> If you scale the phase to the full width of your data word, i.e. Pi = 32767 > for 16-bit, then the subtraction is automatically modulo Pi and there is no > issue. For example, > > x(0) = -.9Pi > x(1) = .9Pi > > then x(1)-x(0) = 1.8Pi which is -.2Pi because of the overflow. > > -Clark
BINGO!!!!!
"robert bristow-johnson" <rbj@audioimagination.com> writes:
> [...] > well, if omega[n] is constant, then both are equivalent. but you're > probably right. the theta[n] - theta[n-1] thing *does* represent the > instantaneous frequency somewhere between samples n and n-1.
Rolle's mean value theorem? -- % Randy Yates % "Remember the good old 1980's, when %% Fuquay-Varina, NC % things were so uncomplicated?" %%% 919-577-9882 % 'Ticket To The Moon' %%%% <yates@ieee.org> % *Time*, Electric Light Orchestra http://home.earthlink.net/~yatescr
On Tue, 03 Apr 2007 20:21:50 -0400, Randy Yates <yates@ieee.org>
wrote:

>Hi Folks, > >If you want to extract the frequency from a complex signal that >contains a single, time-varying frequency component, then the >straightforward method would be to determine the phase of the >input signal and then run that phase into a differentiator. I'm >thinking of a full-blown FIR differentiator with, say, 32 or >more taps. > >The problem is, the phase has those bothersome discontinuities >around +/- pi. You could unwrap it, but in fixed-point, you >can only unwrap so far (think of what a single high-frequency >sinusoid would result in phase-wise) before wrapping around >the two's complement number. > >So, how to do? How do you get a phase input that's unwrapped >for each M-1 previous samples into the FIR differentiator? > >This seems like a simple and common problem, but I'm coming >up with zero. Maybe it's an off-night for me. >-- >% Randy Yates % "Bird, on the wing,
Hi Randy, For the discrete differentiators to work at well, the lowpass input signal must be a low frequency relative to the Fs sample rate. In this case I don't think phase wrapping will be a problem. Just in case it's of some use to you, you might take a quick look at a discrete differentiator described on the following web site. http://www.elecdesign.com/Articles/Index.cfm?AD=1&AD=1&ArticleID=13358 That article describes the standard "first-difference differentiator", the "central-difference differentiator", and a novel computationally-efficient differentiator. See Ya', [-Rick-]
Randy,

What is the carrier freq and signal bandwidth relative to the sample
frequency?

Dirk


On Apr 3, 8:21 pm, Randy Yates <y...@ieee.org> wrote:
> Hi Folks, > > If you want to extract the frequency from a complex signal that > contains a single, time-varying frequency component, then the > straightforward method would be to determine the phase of the > input signal and then run that phase into a differentiator. I'm > thinking of a full-blown FIR differentiator with, say, 32 or > more taps. > > The problem is, the phase has those bothersome discontinuities > around +/- pi. You could unwrap it, but in fixed-point, you > can only unwrap so far (think of what a single high-frequency > sinusoid would result in phase-wise) before wrapping around > the two's complement number. > > So, how to do? How do you get a phase input that's unwrapped > for each M-1 previous samples into the FIR differentiator? > > This seems like a simple and common problem, but I'm coming > up with zero. Maybe it's an off-night for me. > -- > % Randy Yates % "Bird, on the wing, > %% Fuquay-Varina, NC % goes floating by > %%% 919-577-9882 % but there's a teardrop in his eye..." > %%%% <y...@ieee.org> % 'One Summer Dream', *Face The Music*, ELOhttp://home.earthlink.net/~yatescr
"Rick Lyons" <R.Lyons@_BOGUS_ieee.org> wrote in message 
news:4613ba3a.404901453@news.sf.sbcglobal.net...
> On Tue, 03 Apr 2007 20:21:50 -0400, Randy Yates <yates@ieee.org> > wrote: > Just in case it's of some use to you, you might take > a quick look at a discrete differentiator described > on the following web site. > > http://www.elecdesign.com/Articles/Index.cfm?AD=1&AD=1&ArticleID=13358 > > That article describes the standard "first-difference > differentiator", the "central-difference differentiator", > and a novel computationally-efficient differentiator.
A long time ago, in a different thread, there was a discussion about using the arcsin function. Here is what I wrote then in a response to Rick, and perhaps it might solve Randy's problem here.... The instantaneous phases at time t = 0 and t = 1 are arctan(Q0/I0) and arctan (Q1/I1) respectively. Thus, the derivative of the instantaneous phase (i.e. the instantaneous frequency) that we seek is arctan(Q1/I1) - arctan(Q0/I0) But, arctan(x) - arctan(y) = arctan([x-y]/[1+xy]) and thus what we want to find is arctan([Q1/I1 - Q0/I0]/[1 + Q1*Q0/I1*I0]) = arctan([Q1*I0 - Q0*I1]/[I1*I0 + Q1*Q0]) But, the angle whose tangent is a/b also happens to be the angle whose sine is a/sqrt(a^2 + b^2) and whose cosine is b/sqrt(a^2 + b^2). Hence, arctan([Q1*I0 - Q0*I1]/[I1*I0 + Q1*Q0]) = arcsin([Q1*I0 - Q0*I1]/sqrt((Q1*I0-Q0*I1)^2 + (I1*I0+Q1*Q0])^2) = arcsin([Q1*I0 - Q0*I1]/sqrt(I0^2+Q0^2)*sqrt(I1^2+Q1^2) = arcsin(q1*i0 - q0*i1) where i0, i1, q0, q1 are the "normalized" values produced in the block diagram shown in the original post......
"dbell" <bellda2005@cox.net> writes:

> Randy, > > What is the carrier freq and signal bandwidth relative to the sample > frequency?
Dirk, the carrier frequency is about 15 kHz, the bandwidth is 20 kHz (+/- 10 kHz about the carrier), and the sample rate is 64 kHz. --randy
> > Dirk > > > On Apr 3, 8:21 pm, Randy Yates <y...@ieee.org> wrote: >> Hi Folks, >> >> If you want to extract the frequency from a complex signal that >> contains a single, time-varying frequency component, then the >> straightforward method would be to determine the phase of the >> input signal and then run that phase into a differentiator. I'm >> thinking of a full-blown FIR differentiator with, say, 32 or >> more taps. >> >> The problem is, the phase has those bothersome discontinuities >> around +/- pi. You could unwrap it, but in fixed-point, you >> can only unwrap so far (think of what a single high-frequency >> sinusoid would result in phase-wise) before wrapping around >> the two's complement number. >> >> So, how to do? How do you get a phase input that's unwrapped >> for each M-1 previous samples into the FIR differentiator? >> >> This seems like a simple and common problem, but I'm coming >> up with zero. Maybe it's an off-night for me. >> -- >> % Randy Yates % "Bird, on the wing, >> %% Fuquay-Varina, NC % goes floating by >> %%% 919-577-9882 % but there's a teardrop in his eye..." >> %%%% <y...@ieee.org> % 'One Summer Dream', *Face The Music*, ELOhttp://home.earthlink.net/~yatescr > >
-- % Randy Yates % "So now it's getting late, %% Fuquay-Varina, NC % and those who hesitate %%% 919-577-9882 % got no one..." %%%% <yates@ieee.org> % 'Waterfall', *Face The Music*, ELO http://home.earthlink.net/~yatescr
On Apr 4, 3:39 pm, Randy Yates <y...@ieee.org> wrote:
> "dbell" <bellda2...@cox.net> writes: > > Randy, > > > What is the carrier freq and signal bandwidth relative to the sample > > frequency? > > Dirk, the carrier frequency is about 15 kHz, the bandwidth is 20 kHz > (+/- 10 kHz about the carrier), and the sample rate is 64 kHz. > > --randy > > > > > > > > > Dirk > > > On Apr 3, 8:21 pm, Randy Yates <y...@ieee.org> wrote: > >> Hi Folks, > > >> If you want to extract the frequency from a complex signal that > >> contains a single, time-varying frequency component, then the > >> straightforward method would be to determine the phase of the > >> input signal and then run that phase into a differentiator. I'm > >> thinking of a full-blown FIR differentiator with, say, 32 or > >> more taps. > > >> The problem is, the phase has those bothersome discontinuities > >> around +/- pi. You could unwrap it, but in fixed-point, you > >> can only unwrap so far (think of what a single high-frequency > >> sinusoid would result in phase-wise) before wrapping around > >> the two's complement number. > > >> So, how to do? How do you get a phase input that's unwrapped > >> for each M-1 previous samples into the FIR differentiator? > > >> This seems like a simple and common problem, but I'm coming > >> up with zero. Maybe it's an off-night for me. > >> -- > >> % Randy Yates % "Bird, on the wing, > >> %% Fuquay-Varina, NC % goes floating by > >> %%% 919-577-9882 % but there's a teardrop in his eye..." > >> %%%% <y...@ieee.org> % 'One Summer Dream', *Face The Music*, ELOhttp://home.earthlink.net/~yatescr > > -- > % Randy Yates % "So now it's getting late, > %% Fuquay-Varina, NC % and those who hesitate > %%% 919-577-9882 % got no one..." > %%%% <y...@ieee.org> % 'Waterfall', *Face The Music*, ELOhttp://home.earthlink.net/~yatescr- Hide quoted text - > > - Show quoted text -
Randy, If you mix the carrier down to DC (or really close) in the process of creating the IQ signals, then the signal bandwidth would be about 10 kHz, sampled at a 64kHz sample rate (reasonably oversampled). If the signal is bandlimited well, it seems like that would make the signal phase difference wrap extremely unlikely (impossible?). Have you verified that you actually have a problem? BTW, you can complex mix the carrier to -1kHz (mixing with -16kHz at 64kHz rate) without any multiplies/ additions/ rounding. In that case, you can combine the mixing with the filtering for a very efficient complex mixer/filter implementation. Dirk