DSPRelated.com
Forums

A Stupid FM Demod Question?

Started by Randy Yates April 3, 2007
"dbell" <bellda2005@cox.net> writes:

> 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).
How so? The spectrum of an FM signal is not Hermitian-symmetric, is it? That means that if you mix to DC, the (non-redundant) spectrum is -10 kHz to + 10 kHz - i.e., bandwidth is still 20 kHz because you have a complex signal. Perhaps I misunderstand your use of the term "bandwidth." Also, I should have mentioned that the signal is also already complex (I and Q) at the 15 kHz center frequency.
> If the signal is bandlimited well, it seems like that would make the > signal phase difference wrap extremely unlikely (impossible?).
I'm losing you, here. Do you mean the phase of "d[n] = theta[n] - theta[n-1]" would likely not wrap? d[n] will wrap no matter how oversampled the signal is. It's just a matter of time.
> Have you verified that you actually have a problem?
Can't answer until I understand you better.
> 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.
I assume you're referring to the alternating sign trick? I don't think I can use this since, as I said, it's already analytic. Plus, if care is taken in the FM demod, it seems that it doesn't really matter. FYI, I'm really leaning toward Vladimir's solution (Q'I - I'Q / (I^2 + Q^2)) since 1) it doesn't require an arctan approximation 2) it is "perfect" 3) a division has to be done somewhere one way or the other 4) the differentiator is not a big deal 5) I can easily remove the systematic DC error due to the uncentered spectrum. --Randy -- % Randy Yates % "She tells me that she likes me very much, %% Fuquay-Varina, NC % but when I try to touch, she makes it %%% 919-577-9882 % all too clear." %%%% <yates@ieee.org> % 'Yours Truly, 2095', *Time*, ELO http://home.earthlink.net/~yatescr
Hi Rick,

Thanks for your hints. I have a questions/comments below.

R.Lyons@_BOGUS_ieee.org (Rick Lyons) writes:

> 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.
Both you and Dirk have said this. Mebbe (as Robert says) I'm being thick, but I'm not sure what you mean. If there's ANY systematic DC offset at all, then you WILL phase wrap. It may be once every 1000 seconds, but if it happens even once it's unacceptable due to the nastiness of the result. And, depending on where you're "riding" on the phase signal, a little noise spike here or there and WHAM: a wrap. Is this not correct?
> > 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.
That's another cool trick. *IF* (as you say) you have a relatively lowpass signal AND you don't mind a bit of error in the response. Perhaps the coolest thing in your article is that last architecture: Wow! only one multiply! That's certainly damned efficient! But in my case, I think I want less response error, and I believe using the Vladimir approach the spectral offset is benign. It doesn't have to be THAT efficient, and trading some inefficiency for accuracy is reasonable in this application (a BTSC SAP decoder, BTW). -- % 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
Randy Yates wrote:
> "robert bristow-johnson" <rbj@audioimagination.com> writes: > >> Randy Yates wrote: >>> Vladimir Vassilevsky <antispam_bogus@hotmail.com> writes: >>>> Randy Yates wrote: >>>> >>>>> 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. >>>> 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? >>> >>> Would you use an FIR differentiator to get Q' and I', making sure >>> they're properly time-aligned with the I and Q values? >> actually Randy, you *do* have to implement an arctan() function for >> small angles, but you *don't* have to compute a derivative explicitly >> from these discrete samples (using some big FIR). >> >> 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? > >> 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? > > 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.
Not only does [theta(n) - theta(n-1)] represent a secant through the continuous frequency curve passing through theta(n-1) and theta(n), it has a half sample delay. It is a pretty darn good match to the tangent at the midway point if the frequency slope is slow enough not to generate significant sidebands. (Yeah: that's a tautology that hinges on "significant".) I suspect you can sleep easy. 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;
On Apr 4, 8:13 pm, Randy Yates <y...@ieee.org> wrote:
> "dbell" <bellda2...@cox.net> writes: > > 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). > > How so? The spectrum of an FM signal is not Hermitian-symmetric, > is it? That means that if you mix to DC, the (non-redundant) > spectrum is -10 kHz to + 10 kHz - i.e., bandwidth is still 20 kHz > because you have a complex signal. > > Perhaps I misunderstand your use of the term "bandwidth." > > Also, I should have mentioned that the signal is also already complex > (I and Q) at the 15 kHz center frequency. > > > If the signal is bandlimited well, it seems like that would make the > > signal phase difference wrap extremely unlikely (impossible?). > > I'm losing you, here. Do you mean the phase of "d[n] = theta[n] - theta[n-1]" > would likely not wrap? d[n] will wrap no matter how oversampled the > signal is. It's just a matter of time. > > > Have you verified that you actually have a problem? > > Can't answer until I understand you better. > > > 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. > > I assume you're referring to the alternating sign trick? I don't think > I can use this since, as I said, it's already analytic. Plus, if care > is taken in the FM demod, it seems that it doesn't really matter. > > FYI, I'm really leaning toward Vladimir's solution (Q'I - I'Q / (I^2 + Q^2)) > since > > 1) it doesn't require an arctan approximation > > 2) it is "perfect" > > 3) a division has to be done somewhere one way or the other > > 4) the differentiator is not a big deal > > 5) I can easily remove the systematic DC error due to the uncentered > spectrum. > > --Randy > > -- > % Randy Yates % "She tells me that she likes me very much, > %% Fuquay-Varina, NC % but when I try to touch, she makes it > %%% 919-577-9882 % all too clear." > %%%% <y...@ieee.org> % 'Yours Truly, 2095', *Time*, ELO http://home.earthlink.net/~yatescr- Hide quoted text - > > - Show quoted text -
Randy, Ignore my last post. I should not try to whip out a post when I am heavily involved in something else. We successfully implemented the solution you are proposing to use in a high-performance UHF/VHF radio in the mid-90's. Frerking's book says it will not perform well; I think we used a better differentiator than he did. It worked great. A couple of things worth mentioning are: a) make sure you put the same delay in the I and Q signals that you do in the I' and Q' signals (from the differentiator). If you use an even number of taps in the differentiator, you need an integer plus half sample delay in the I and Q in the equation (after derivatives obtained). b) make sure your differentiator performance is okay in the frequency range of the signal you are demodulating. People often suggest that using [1 0 -1] as a differentiator solves the delay problem. It does. But keep in mind that [1 0 -1] is the 2-tap 'differentiator' [1 -1] further convolved with a 2-tap 'lowpass' [1 1]. The 3-point differentiator isn't very good as a differentiator (worse than [1 -1]); both work best close to DC. If your differentiator works better closer to DC, you may still want to complex mix your already complex IQ signal centered at 15 kHz down closer to DC before you apply the differentiators (possibly with the Fs/4 'no cost' mixer, mentioned in the posting I just asked you to ignore). c)in the equation you are going to use for instantaneous frequency, there is an assumption that I,Q, and I',Q' have the same frequency spectrum other than the linear frequency response of the differentiator in the range of the signal. Keep that in mind. Note: One way to impart the extra half-sample offset to I and Q is, after differentiating the I and Q at the original rate, resample I and Q to twice the rate, delay one sample, then decimate by 2 to get an integer and 1/2 sample delayed I and Q (could be done more efficiently than described) . The delay and response of the resampling filters has to be taken into account. Other approaches possible. I hope this is a little helpful. I also hope I didn't whip out this post too fast... really I do... Dirk
"dbell" <bellda2005@cox.net> writes:
> [...] > I hope this is a little helpful.
Yes, VERY helpful! You addressed several new questions I was having. Thanks much, Dirk! -- % Randy Yates % "How's life on earth? %% Fuquay-Varina, NC % ... What is it worth?" %%% 919-577-9882 % 'Mission (A World Record)', %%%% <yates@ieee.org> % *A New World Record*, ELO http://home.earthlink.net/~yatescr
Randy Yates 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, I recently had to grapple with the same thing where I was working with an LMS decoder for an PCMFM/SOQPSK demodulator. In this application, the phase deviation per symbol is on the order of pi/3, so we will see phase wraps frequently for all but the most contrived data sequences. Normally for FM, you can get away with a simple difference on the phase and depend on the modulo property of the 2's complement system to make the wrapping a non-issue (assuming you scale the phase so that the MSB is weighted -pi). However, if you are running the wrapped phase through a multi-tap filter you run into a problem because the filter sees the wraps as a phase discontinuity. So, in order to put it into a filter, you do indeed have to unwrap the phase. That one can get complicated quick. Here's how I dealt with it: You must use an FIR filter, not an IIR filter, so that the number of samples in the filter is bounded. The filter should be in direct form so that the delay line is on the input side. You unwrap the data to two extra MSBs, and then use duplicate delay queues for the filter, one with the unwrapped data, and the other with the unwrapped data offset by a multiple of 2pi. You keep track of where the wraps occur in the unwrapped phase sequence, and if there is a wrap within the filter use the offset delay queue as inputs to the multipliers instead of the straight unwrapped queue for the interval where the wrap-around exists in the filter delay queue. If there is a possibility of more than one wrap in the filter length, you need to unwrap more bits before the filter, but the same technique still works. At the filter output, you discard the integer MSBs to get back to wrapped phase (you will have discontinuities in the filter output due to switching the delay queues, but those will be multiples of 2pi). This technique also allows you to use a Farrow resampler to resample wrapped phase.
Vladimir Vassilevsky 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.
I guess I've always just used delta(atan(Q/I)) for this. Even if the data representation doesn't automatically handle the phase wrapping, handling it specially is less computation than doing all the arithmetic above. Coincidentally, one of the very first DSP designs I ever did, circa 1985, was a hardware implementation of the above, using now-seemingly-gigantic DIP parts such as a look-up EPROM, adder, etc. =g2 _____________________________________________________________________ Grant R. Griffin Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com See http://www.iowegian.com/img/contact.gif for e-mail address
> FYI, I'm really leaning toward Vladimir's solution (Q'I - I'Q / (I^2 + Q^2)) > since > > 1) it doesn't require an arctan approximation > > 2) it is "perfect" > > 3) a division has to be done somewhere one way or the other > > 4) the differentiator is not a big deal > > 5) I can easily remove the systematic DC error due to the uncentered > spectrum. > > --Randy
Randy, This technique is named the "cross-correlator receiver" in some papers. It is posted in many discussions on FM demod, but references are usually not provided. One of the earliest papers to propose it is: "An FM Detector for Low S/N" by John Park, IEEE Trans on Comm, 1970 and the analytical performance derivation has been done in: "Performance of the Cross-Correlator Receiver for Binary Digital Frequency Modulation" by Kevin Farrell et. al, IEEE Trans on Comm, 1997. It is shown to have performance comparable to the Limiter- Discriminator receiver. So even though you would not have to worry about phase wrapping issues, the performance will suffer below threshold due to click noise. By the way, what modulation index are you using?
On Apr 6, 10:00 am, Grant Griffin <nos...@yahoo.com> wrote:
> Vladimir Vassilevsky 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.
especially when you know that the argument to it is small.
> > 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. > > I guess I've always just used delta(atan(Q/I)) for this. Even if the > data representation doesn't automatically handle the phase wrapping, > handling it specially is less computation than doing all the arithmetic > above.
well, if-then statements (needed for explicit phase unwrapping) are sorta costly and ugly in DSP code, me thinks. this is why i liked: 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]) } = arctan( (Q[n]*I[n-1] - I[n]*Q[n-1]) / (I[n]*I[n-1] + Q[n]*Q[n-1]) ) but it does (or *might*) require a division. if you are confident that the denominator I[n]*I[n-1] + Q[n]*Q[n-1] is close enough to I[n]*I[n] + Q[n]*Q[n] and that is constant, you can skip the division. even if not, you can compute the *new* denominator, multiply it by the previous reciprocal and use the difference of that from 1 in a sorta servo feedback loop to skip the division. also the arctan() might be able to be tossed if you know that the change in angle is small for each sample. then you get omega[n] = Constant*( Q[n]*I[n-1] - I[n]*Q[n-1] ) and that's about as simple as it can get.
> Coincidentally, one of the very first DSP designs I ever did, circa > 1985, was a hardware implementation of the above, using > now-seemingly-gigantic DIP parts such as a look-up EPROM, adder, etc. > > =g2 > _____________________________________________________________________ > > Grant R. Griffin > Publisher of dspGuru http://www.dspguru.com > Iowegian International Corporation http://www.iowegian.com > Seehttp://www.iowegian.com/img/contact.giffor e-mail address
it's nice to see this sig again. r b-j
"Ahmed" <ahsenahmed@hotmail.com> writes:

>> FYI, I'm really leaning toward Vladimir's solution (Q'I - I'Q / (I^2 + Q^2)) >> since >> >> 1) it doesn't require an arctan approximation >> >> 2) it is "perfect" >> >> 3) a division has to be done somewhere one way or the other >> >> 4) the differentiator is not a big deal >> >> 5) I can easily remove the systematic DC error due to the uncentered >> spectrum. >> >> --Randy > > Randy, > > This technique is named the "cross-correlator receiver" in some > papers. It is posted in many discussions on FM demod, but references > are usually not provided. One of the earliest papers to propose it is: > > "An FM Detector for Low S/N" by John Park, IEEE Trans on Comm, 1970 > > and the analytical performance derivation has been done in: > > "Performance of the Cross-Correlator Receiver for Binary Digital > Frequency Modulation" by Kevin Farrell et. al, IEEE Trans on Comm, > 1997.
Thanks very much, Ahmed!
> It is shown to have performance comparable to the Limiter- > Discriminator receiver. So even though you would not have to worry > about phase wrapping issues, the performance will suffer below > threshold due to click noise.
Yes, I was afraid of that.
> By the way, what modulation index are you using?
beta = 1. This is the SAP on a BTSC signal. So it's neither narrow-band nor wideband, according to [schwartzcomm]. --Randy @book{schwartzcomm, title = "Information Transmission, Modulation, and Noise", author = "{Mischa~Schwartz}", publisher = "McGraw-Hill", edition = "fourth", year = "1990"} -- % Randy Yates % "Rollin' and riding and slippin' and %% Fuquay-Varina, NC % sliding, it's magic." %%% 919-577-9882 % %%%% <yates@ieee.org> % 'Living' Thing', *A New World Record*, ELO http://home.earthlink.net/~yatescr