Forums

FM Demodulation Woes

Started by Paul Solomon October 20, 2005
Hi All,

I have been working for some time now on making a multichannel FM demod / 
remod, and I have finally gotten my hands on some test equipment to put this 
design through its paces and have found that I have a strange problem.

To start with I will outline the design that I am using..

I undersample the FM signal at 80MSPS using a 12bit ADC, this signal is then 
mixed down to baseband with a NCO that generated a sin and cos output to 
give me an I and Q. The I and Q then go through a CIC decimation filter in 
which I decimate by 16 and then a 300kHz wide FIR filter to get rid of any 
adjacent channels and decimate by another 4. The I and Q now contains my 
signal of interest at a sampling rate of 1.25MSPS, this is fed into a cordic 
ATAN2 function and then I differentiate the output by subtracting the 
previous sample (and I phase unwrap by looking for changes greater than pi 
and adding or subtracting 2*pi as appropriate). The output here is then my 
FM multiplex output which should contain L+R, 19kHz stero pilot, L-R DSBSC 
at 38kHz etc and on a spectrum analyser I can tune to a station and see all 
this, and when I output to speakers it sounds good.

Now for my problem, with this test equipment I have been able to create a FM 
carrier that is has a deviation of 75kHz and a modulation tone of 1kHz. When 
I feed this into my demod, I can hear the 1kHz tone on the speakers and it 
sounds ok. However when I look at this output on a spectrum analyser, there 
is not only my 1kHz tone, but what appears to be an FM modulated version of 
the 1kHz tone on my output at about 40dB down. This basically raises the 
noise floor in the 0-75kHz region of the FM MPX output and has an upwards 
slope to the noise floor in the same shape that the 1kHz tone FM modulated 
would look like. Interestingly if I change the level of my modulating tone, 
the BW of the noise gets narrower and wider as you would expect an FM 
carrier to (i.e. the deviation decreases and increases). And if I change the 
tone frequency, the look of the noise changes as the FM spectrum would 
change, so at 19kHz I have the familiar 3 - 4 spikes in the noise floor that 
the FM shape of a 19kHz tone looks like.

At first I thought that I was getting some of the signal that I am 
demodulating leaking through to the output somehow however I have done some 
tests in which I vary the level of the incomming FM signal level by 40dB and 
this has no effect on the level of the noise on the output of the FM MPX, it 
is a constant -40dBC.

I have no idea what could be causing this, but it is quite frustrating, as 
although the audio sounds fine, it wipes out the RDS carrier and thus makes 
this system unuseable. I am am starting to suspect it may be a side effect 
of my method of demodulation (i.e.CORDIC atan2 followed by difference of 
current sample and last) but I have no idea why this would cause a FM 
modulation of the output.

To summarise, I am getting a FM modulated version of my FM multiplex 
outputted on top of my FM multiplex output but it as about 40dB down from 
the actual FM Multiplex signal and I dont know why!

Any ideas??

Regards,

Paul Solomon


"Paul Solomon" <psolomon@tpg.com.au> wrote in message 
news:43574fa0$1@dnews.tpgi.com.au...
> Hi All, > > I have been working for some time now on making a multichannel FM demod / > remod, and I have finally gotten my hands on some test equipment to put > this design through its paces and have found that I have a strange > problem. > > To start with I will outline the design that I am using.. > > I undersample the FM signal at 80MSPS using a 12bit ADC, this signal is > then mixed down to baseband with a NCO that generated a sin and cos output > to give me an I and Q. The I and Q then go through a CIC decimation filter > in which I decimate by 16 and then a 300kHz wide FIR filter to get rid of > any adjacent channels and decimate by another 4. The I and Q now contains > my signal of interest at a sampling rate of 1.25MSPS, this is fed into a > cordic ATAN2 function and then I differentiate the output by subtracting > the previous sample (and I phase unwrap by looking for changes greater > than pi and adding or subtracting 2*pi as appropriate). The output here is > then my FM multiplex output which should contain L+R, 19kHz stero pilot, > L-R DSBSC at 38kHz etc and on a spectrum analyser I can tune to a station > and see all this, and when I output to speakers it sounds good. > > Now for my problem, with this test equipment I have been able to create a > FM carrier that is has a deviation of 75kHz and a modulation tone of 1kHz. > When I feed this into my demod, I can hear the 1kHz tone on the speakers > and it sounds ok. However when I look at this output on a spectrum > analyser, there is not only my 1kHz tone, but what appears to be an FM > modulated version of the 1kHz tone on my output at about 40dB down. This > basically raises the noise floor in the 0-75kHz region of the FM MPX > output and has an upwards slope to the noise floor in the same shape that > the 1kHz tone FM modulated would look like. Interestingly if I change the > level of my modulating tone, the BW of the noise gets narrower and wider > as you would expect an FM carrier to (i.e. the deviation decreases and > increases). And if I change the tone frequency, the look of the noise > changes as the FM spectrum would change, so at 19kHz I have the familiar > 3 - 4 spikes in the noise floor that the FM shape of a 19kHz tone looks > like. > > At first I thought that I was getting some of the signal that I am > demodulating leaking through to the output somehow however I have done > some tests in which I vary the level of the incomming FM signal level by > 40dB and this has no effect on the level of the noise on the output of the > FM MPX, it is a constant -40dBC. > > I have no idea what could be causing this, but it is quite frustrating, as > although the audio sounds fine, it wipes out the RDS carrier and thus > makes this system unuseable. I am am starting to suspect it may be a side > effect of my method of demodulation (i.e.CORDIC atan2 followed by > difference of current sample and last) but I have no idea why this would > cause a FM modulation of the output. > > To summarise, I am getting a FM modulated version of my FM multiplex > outputted on top of my FM multiplex output but it as about 40dB down from > the actual FM Multiplex signal and I dont know why! > > Any ideas?? > > Regards, > > Paul Solomon > >
Hi All, I have done another stack of work on this today and although I am still unsure why I am getting this problem, I think I have found out how to fix it. I have been using a decimation factor of 64 in the design taking me down to a sampling rate of 1.25MSPS for the cordic demod, I have found that if I decimate by 32 instead and run the cordic demod at 2.5MSPS the problem goes away. I am yet to understand why this is, it could be the fact that I am using the difference instead of differentiating the phase to generate the instantaneous frequency but I do not know yet.. Regards, Paul Solomon
"Paul Solomon" <psolomon@tpg.com.au> wrote in message 
news:4358a2ec@dnews.tpgi.com.au...
> > Hi All, > > I have done another stack of work on this today and although I am still > unsure why I am getting this problem, I think I have found out how to fix > it. I have been using a decimation factor of 64 in the design taking me > down to a sampling rate of 1.25MSPS for the cordic demod, I have found > that if I decimate by 32 instead and run the cordic demod at 2.5MSPS the > problem goes away. I am yet to understand why this is, it could be the > fact that I am using the difference instead of differentiating the phase > to generate the instantaneous frequency but I do not know yet.. > >
Hello Paul, I was wondering if your differencing was the problem. Technically you need a true derivative. The way I've done FM demod totally avoids the atan completely. Just do the (I dQ - Q dI) / (I^2 + Q^2) method. All you need is a couple of FIR differentiators and one division. If your AGC is good, this division can be replaced with an expansion about the nomimal gain. Clay
"Clay S. Turner" <Physics@Bellsouth.net> wrote in message 
news:2l66f.20$8e7.8@bignews7.bellsouth.net...
> > "Paul Solomon" <psolomon@tpg.com.au> wrote in message > news:4358a2ec@dnews.tpgi.com.au... >> >> Hi All, >> >> I have done another stack of work on this today and although I am still >> unsure why I am getting this problem, I think I have found out how to fix >> it. I have been using a decimation factor of 64 in the design taking me >> down to a sampling rate of 1.25MSPS for the cordic demod, I have found >> that if I decimate by 32 instead and run the cordic demod at 2.5MSPS the >> problem goes away. I am yet to understand why this is, it could be the >> fact that I am using the difference instead of differentiating the phase >> to generate the instantaneous frequency but I do not know yet.. >> >> > > Hello Paul, > > I was wondering if your differencing was the problem. Technically you need > a true derivative. The way I've done FM demod totally avoids the atan > completely. Just do the (I dQ - Q dI) / (I^2 + Q^2) method. All you need > is a couple of FIR differentiators and one division. If your AGC is good, > this division can be replaced with an expansion about the nomimal gain. > > Clay > > >
Hi Clay, This has been brought up a few times and the thing that has stopped me going down this road each time is that with all mt googleing, I have still not been able to work out how to differentiate with an FIR filter. I understand that a FIR filter with the co-eff's [1, -1] is effectively what I am doing at the moment for my differentiator, but I have not been able to find a concise reference that says to approximate differentiation do this. If anyone could explain to me how to do this FIR approximation of differentiation, I would greatly appreciate it. I have Matlab at my dispoal if there is a magic command available to auto generate the co-efficients.I also have a copy of Ricks Understanding DSP, but I have not seen any reference to this there (unless I have missed it?) Also if there is any mathematical relationship between the number of co-efficients and the error in the differentiation approximation then I would be interested in that also. Regards, Paul Solomon
"Paul Solomon" <psolomon@tpg.com.au> wrote in message 
news:43596fac$1@dnews.tpgi.com.au...
>> > Hi Clay, > > This has been brought up a few times and the thing that has stopped me > going down this road each time is that with all mt googleing, I have still > not been able to work out how to differentiate with an FIR filter. I > understand that a FIR filter with the co-eff's [1, -1] is effectively what > I am doing at the moment for my differentiator, but I have not been able > to find a concise reference that says to approximate differentiation do > this. > > If anyone could explain to me how to do this FIR approximation of > differentiation, I would greatly appreciate it. I have Matlab at my > dispoal if there is a magic command available to auto generate the > co-efficients.I also have a copy of Ricks Understanding DSP, but I have > not seen any reference to this there (unless I have missed it?) > > Also if there is any mathematical relationship between the number of > co-efficients and the error in the differentiation approximation then I > would be interested in that also. >
Hello Paul, I use a program I wrote (based on the Park McClellan version) to make my FIR filters. Matlab should be able to do this. But I'm not a Matlab guy, so I'm unable to give you exact details. But with a PM design, you do get the approximation error, so you can figure out the rest. A link to my program is below. It is a DOS application, so it will run on pretty much any windows machine. When you start it, tell it you want a differentiator. Pick a value like 11 for an initial filter order (number of taps). Enter your sampling rate. And for the frequency bands enter 0.0 for the low value and something a little less than 0.5*sampling rate for the high value. Adjust your filter order (up or down) until the error is small enough. The displayed frequencies are digital frequencies (relative to the sampling rate) To save the FIR coefs, just use "calculate filter coefs" menu option to compute the coefs (answer no to both the quantize and 56000 mode questions), and the program will write the results into a file called fil.dat. The format is text and this will look like a c file matrix. Sorry about the scant instructions - I've been too lazy to write a users manual. But the price is right and I give permission for all to use. I can do this since I wrote it. http://personal.atl.bellsouth.net/p/h/physics/FIR.Zip Enjoy, Clay p.s. I'll be away from my computer this weekend, so if you post any questions, I'll be able to get to them Sunday night.
Clay S. Turner wrote:
> "Paul Solomon" <psolomon@tpg.com.au> wrote in message > news:43596fac$1@dnews.tpgi.com.au... >> Hi Clay, >> >> This has been brought up a few times and the thing that has stopped me >> going down this road each time is that with all mt googleing, I have still >> not been able to work out how to differentiate with an FIR filter. I >> understand that a FIR filter with the co-eff's [1, -1] is effectively what >> I am doing at the moment for my differentiator, but I have not been able >> to find a concise reference that says to approximate differentiation do >> this. >> >> If anyone could explain to me how to do this FIR approximation of >> differentiation, I would greatly appreciate it. I have Matlab at my >> dispoal if there is a magic command available to auto generate the >> co-efficients.I also have a copy of Ricks Understanding DSP, but I have >> not seen any reference to this there (unless I have missed it?) >> >> Also if there is any mathematical relationship between the number of >> co-efficients and the error in the differentiation approximation then I >> would be interested in that also. >> > > Hello Paul, > > I use a program I wrote (based on the Park McClellan version) to make my FIR > filters. Matlab should be able to do this. But I'm not a Matlab guy, so I'm > unable to give you exact details. But with a PM design, you do get the > approximation error, so you can figure out the rest.
Very nice of you to give away your hard work with that program. In regards to the MATLAB stuff, MATLAB has a function called remez which can calculate linear phase FIR filter coefficients. It's parameters are remez(N, F, A) where N is the filter order F is the array of frequencies A is the array of amplitudes (which should be equal in number to frequencies obviously) This uses the Parks-McClellan method. The other option is the fir1 function, which uses the windowing method.
in article Hfh6f.1863$S24.130146@news.xtra.co.nz, Bevan Weiss at
kaizen__@NOSPAMhotmail.com wrote on 10/21/2005 22:14:

> > In regards to the MATLAB stuff, MATLAB has a function called remez which > can calculate linear phase FIR filter coefficients. > > It's parameters are > remez(N, F, A) > where N is the filter order > F is the array of frequencies > A is the array of amplitudes (which should be equal in number to > frequencies obviously) > > This uses the Parks-McClellan method. > The other option is the fir1 function, which uses the windowing method.
and the other, other option is firls() which is just like remez but uses a Euclidian norm to measure error, rather than the minmax norm. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
"robert bristow-johnson" <rbj@audioimagination.com> wrote in message 
news:BF7F1C9D.B6B7%rbj@audioimagination.com...
> in article Hfh6f.1863$S24.130146@news.xtra.co.nz, Bevan Weiss at > kaizen__@NOSPAMhotmail.com wrote on 10/21/2005 22:14: > >> >> In regards to the MATLAB stuff, MATLAB has a function called remez which >> can calculate linear phase FIR filter coefficients. >> >> It's parameters are >> remez(N, F, A) >> where N is the filter order >> F is the array of frequencies >> A is the array of amplitudes (which should be equal in number to >> frequencies obviously) >> >> This uses the Parks-McClellan method. >> The other option is the fir1 function, which uses the windowing method. > > and the other, other option is firls() which is just like remez but uses a > Euclidian norm to measure error, rather than the minmax norm. > > -- > > r b-j rbj@audioimagination.com > > "Imagination is more important than knowledge." > >
Ok, I have played with matlab a bit and I have made several low pass FIR filters for my design already. The part that I do not understand is what makes the FIR a differentiator, and if I use these functions remez etc, what should I be putting in as the shape of the filter that I want, i.e. the arrays of freq and amp. I have no idea what filter shape makes a differentiator and/or why? What I am trying to achieve is: inst freq = d(inst phase)/dt with a sampling rate = 1.25MSPS in one instance and 2.5MSPS in another. could someone explain the what type of filter approximates this, and perhaps more importantly why? If there are any web references that you can just point me in then that would be fine also. Regards, Paul Solomon
Paul Solomon wrote:
> "robert bristow-johnson" <rbj@audioimagination.com> wrote in message > news:BF7F1C9D.B6B7%rbj@audioimagination.com... >> in article Hfh6f.1863$S24.130146@news.xtra.co.nz, Bevan Weiss at >> kaizen__@NOSPAMhotmail.com wrote on 10/21/2005 22:14: >> >>> In regards to the MATLAB stuff, MATLAB has a function called remez which >>> can calculate linear phase FIR filter coefficients. >>> >>> It's parameters are >>> remez(N, F, A) >>> where N is the filter order >>> F is the array of frequencies >>> A is the array of amplitudes (which should be equal in number to >>> frequencies obviously) >>> >>> This uses the Parks-McClellan method. >>> The other option is the fir1 function, which uses the windowing method. >> and the other, other option is firls() which is just like remez but uses a >> Euclidian norm to measure error, rather than the minmax norm. >> >> -- >> >> r b-j rbj@audioimagination.com >> >> "Imagination is more important than knowledge." >> >> > > Ok, I have played with matlab a bit and I have made several low pass FIR > filters for my design already. The part that I do not understand is what > makes the FIR a differentiator, and if I use these functions remez etc, what > should I be putting in as the shape of the filter that I want, i.e. the > arrays of freq and amp. I have no idea what filter shape makes a > differentiator and/or why? > > What I am trying to achieve is: > > inst freq = d(inst phase)/dt > > with a sampling rate = 1.25MSPS in one instance and 2.5MSPS in another. > > could someone explain the what type of filter approximates this, and perhaps > more importantly why? If there are any web references that you can just > point me in then that would be fine also. > > > Regards, > > Paul Solomon
Ahh right, ok well I think the best way I can explain this is to consider a sine wave. If you differentiate the sine wave then you get a cosine with a linear frequency dependent factor ie d/dt(sin(wt)) ~ w*cos(wt) This suggests that a differentiator will have a high pass frequency response. ie it will actually amplify the high frequencies. The easiest would probably be to construct it using a z-transform though normally you'd already have some idea of the coefficients you'd want, and which delayed data you'd want to use ie y(n) = x(n) - 0.5x(n-1) - 0.5x(n-2) So you'd already have your coefficients right there. If you want to think in terms of frequency response, then you'd just go to z-transforms and then relate in that manner.
Paul,

As rbj recommended, see matlab help ('help remez', if older MATLAB,
'help firpm', if newer MATLAB)

.....
.....
  B=FIRPM(N,F,A,'differentiator') and B=FIRPM(N,F,A,W,'differentiator')
  also design filters with odd symmetry, but with a special weighting
  scheme for non-zero amplitude bands. The weight is assumed to be
  equal to the inverse of frequency times the weight W. Thus the filter
  has a much better fit at low frequency than at high frequency. This
  designs FIR differentiators.

.....
.....

  % Example of a low-pass differentiator:  % 45 taps
	h=firpm(44,[0 .3 .4 1],[0 .2 0 0],'differentiator');

.....
.....

Paul, try a couple designs, look at the spectra (use linear magnitude
scale for expected linear magnitude response), understand the
parameters.

   plot(abs(fft(h,NFFT))); % For spectal display. NFFT=1024 should
okay.


DON'T FORGET, to use the instantaneous frequency equation with
I,Q,dI/dt,dQ/dt, all of these must be properly time aligned.  If your
differentiator (assuming linear phase FIR) has delay 'nDelay', then the
I and Q must be identically delayed to make the equation work.  If you
are not doing any further processing (filtering, ...) of I and Q, then
you want to be sure 'nDelay' is an integer (equivalently odd symmetric
differentiator filter has an odd number of coefficients) to easily
allow proper alignment.

ALSO, KEEP IN MIND that the instantaneous frequency equation does not
take into account any bandlimiting by the differentiator
implementation, so it is not strictly accurate unless the original
input I and Q signals are bandlimited more than the linear magnitude
response range of the differentiator implementation.

Dirk

> > Ok, I have played with matlab a bit and I have made several low pass FIR > filters for my design already. The part that I do not understand is what > makes the FIR a differentiator, and if I use these functions remez etc, what > should I be putting in as the shape of the filter that I want, i.e. the > arrays of freq and amp. I have no idea what filter shape makes a > differentiator and/or why? > > What I am trying to achieve is: > > inst freq = d(inst phase)/dt > > with a sampling rate = 1.25MSPS in one instance and 2.5MSPS in another. > > could someone explain the what type of filter approximates this, and perhaps > more importantly why? If there are any web references that you can just > point me in then that would be fine also. > > > Regards, > > Paul Solomon