Forums

RE: FM Demodulation problem (Lyons Ch. 13.22)

Started by Jerry W. August 25, 2005
Rune -- what was the final result of this thread (posted Sep 19-22
2004)?  Was your MATLAB implementation of the FM demodulator correct,
did you make any changes, or what?  I couldn't find any later posts
about it, and inquiring minds want to know!  Thanks.

cheers,
  jerry

I've been looking more closely at Chap. 13.22 (of Lyons, 2nd. ed.) and
at Rune's MATLAB code, and I have two questions.

  1. In Fig. 13-61a on p. 551, doesn't the lower branch (the inverse of
the magnitude) need the same Delay as the i(n) and q(n), to keep it
time-aligned with the Differentiator outputs?

  2. In Rune's MATLAB implementation (in the original Sep 19 2004
posting), do the 3-point differentiating filter() calls have zero delay
or perhaps a 1-point delay?  (I'm not sufficiently conversant with
MATLAB's filter(), so I'm asking.)
    - if zero delay, then the implementation appears consistent.
    - but if there's a nonzero delay, it seems to me that the combining
of the xi, xr, dxi, dxr, and inverse-magnitude terms would be wrong
without allowing for it.

cheers,
  jerry

"Jerry W." <sl_jerry1@hotmail.com> wrote in message 
news:1125004136.323371.215040@g14g2000cwa.googlegroups.com...
> I've been looking more closely at Chap. 13.22 (of Lyons, 2nd. ed.) and > at Rune's MATLAB code, and I have two questions. > > 1. In Fig. 13-61a on p. 551, doesn't the lower branch (the inverse of > the magnitude) need the same Delay as the i(n) and q(n), to keep it > time-aligned with the Differentiator outputs?
Yes, this needs to be done. Usually a 2nd pointer is used on the diff. data to pull out delayed data.
> > 2. In Rune's MATLAB implementation (in the original Sep 19 2004 > posting), do the 3-point differentiating filter() calls have zero delay > or perhaps a 1-point delay? (I'm not sufficiently conversant with > MATLAB's filter(), so I'm asking.) > - if zero delay, then the implementation appears consistent. > - but if there's a nonzero delay, it seems to me that the combining > of the xi, xr, dxi, dxr, and inverse-magnitude terms would be wrong > without allowing for it.
A 3 pt FIR (with definite parity) has a delay of 1 sample. I'm not a MatLab guy, so I can't speak for the code. Clay
Jerry W. wrote:
> I've been looking more closely at Chap. 13.22 (of Lyons, 2nd. ed.) and > at Rune's MATLAB code, and I have two questions. > > 1. In Fig. 13-61a on p. 551, doesn't the lower branch (the inverse of > the magnitude) need the same Delay as the i(n) and q(n), to keep it > time-aligned with the Differentiator outputs?
Where is Rick when we need him... ;)
> 2. In Rune's MATLAB implementation (in the original Sep 19 2004 > posting), do the 3-point differentiating filter() calls have zero delay > or perhaps a 1-point delay? (I'm not sufficiently conversant with > MATLAB's filter(), so I'm asking.) > - if zero delay, then the implementation appears consistent. > - but if there's a nonzero delay, it seems to me that the combining > of the xi, xr, dxi, dxr, and inverse-magnitude terms would be wrong > without allowing for it.
The FILTER command in matlab is causal, according to the matlab documentation:
>> help filter
FILTER One-dimensional digital filter. Y = FILTER(B,A,X) filters the data in vector X with the filter described by vectors A and B to create the filtered data Y. The filter is a "Direct Form II Transposed" implementation of the standard difference equation: a(1)*y(n) = b(1)*x(n) + b(2)*x(n-1) + ... + b(nb+1)*x(n-nb) - a(2)*y(n-1) - ... - a(na+1)*y(n-na) So there would be some delay involved when applying this filter. As for the differentiating filter [1 0 -1] it is an antisymmetric FIR filter, which means it has a delay of 1 sample... plus a 90 degree phase lag? Never go on usenet at 5 AM... There is a non-causal filter, FILTFILT, available in matlab, that works by running the filter first in the forward and then in the reverse direction:
>> help filtfilt
FILTFILT Zero-phase forward and reverse digital filtering. Y = FILTFILT(B, A, X) filters the data in vector X with the filter described by vectors A and B to create the filtered data Y. The filter is described by the difference equation: y(n) = b(1)*x(n) + b(2)*x(n-1) + ... + b(nb+1)*x(n-nb) - a(2)*y(n-1) - ... - a(na+1)*y(n-na) After filtering in the forward direction, the filtered sequence is then reversed and run back through the filter; Y is the time reverse of the output of the second filtering operation. The result has precisely zero phase distortion and magnitude modified by the square of the filter's magnitude response. Care is taken to minimize startup and ending transients by matching initial conditions. [ BTW, does anybody know how one can match inital conditions to reduce end transients? That particular claim has puzzled me since I first saw it... ] As for the FM demod thing, I didn't do much more than is apparent from that thread. I understood there was something going on that I did not understand, and since this was more of a hobby project, it was never pursued further. Rune
Rune Allnor wrote:

   ...

> There is a non-causal filter, FILTFILT, available in matlab,
By "non-causal", I don't suppose you mean that the output appears before the input is applied. If I'm right, what do you mean? ... Jerry -- Engineering is the art of making what you want from things you can get. &#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;
Jerry Avins wrote:
> Rune Allnor wrote: > > ... > > > There is a non-causal filter, FILTFILT, available in matlab, > > By "non-causal", I don't suppose you mean that the output appears before > the input is applied. If I'm right, what do you mean?
By "non-causal" I mean the following: Assume a signal y[n] = x[n](*)h[n] defined for integer index n=1 to N, as usual when matlab is involved, and where (*) means convolution. The whole data sequence x[n] is available in memory at the start of the filtering operation. To keep it simple, we are talking about zero-mean signals, to avoid some splitting of hairs over systems with DC offset. If a delayed unit impulse d[n-k], [0 0 0 ... 0 1 0 ... 0] where the '1' appears at the sample with index k, is applied as input to the filter, the impulse response of the filter can be non-zero for n < k as well as for n > k. In a causal filter the impulse response is strictly 0 for n < k. I am sure you understand what I mean. Please feel free to help me express it more unequivocally. Rune
Rune Allnor wrote:

(snip regarding MATLAB and FILTER)

> magnitude response. Care is taken to minimize startup and ending > transients by matching initial conditions.
> [ BTW, does anybody know how one can match inital conditions to > reduce end transients? That particular claim has puzzled me > since I first saw it... ]
I can guess ... you set all higher derivatives to zero. If you start a filter with all variables zero, including those that represent data before t=0, you might get a large transient. That transient would be represented by large values for many high order derivatives that shouldn't be large, or even non-zero. So find the values that set the appropriate derivatives to zero. -- glen
glen herrmannsfeldt wrote:
> Rune Allnor wrote: > > (snip regarding MATLAB and FILTER) > > > magnitude response. Care is taken to minimize startup and ending > > transients by matching initial conditions. > > > [ BTW, does anybody know how one can match inital conditions to > > reduce end transients? That particular claim has puzzled me > > since I first saw it... ] > > I can guess ... you set all higher derivatives to zero. > > If you start a filter with all variables zero, including those that > represent data before t=0, you might get a large transient. > That transient would be represented by large values for many high > order derivatives that shouldn't be large, or even non-zero. > So find the values that set the appropriate derivatives to zero.
OK... I guess these values could be computed from the filter coefficients and possibly the first sample... but how does one reduce the end transients? These are generic filters, IIR or FIR. Wouldn't "reducing the end transient" mean that one somehow gets rid of the tail of the IIR filter? Rune
Rune Allnor wrote:
> Jerry Avins wrote: > >>Rune Allnor wrote: >> >> ... >> >> >>>There is a non-causal filter, FILTFILT, available in matlab, >> >>By "non-causal", I don't suppose you mean that the output appears before >>the input is applied. If I'm right, what do you mean? > > > By "non-causal" I mean the following: > > Assume a signal y[n] = x[n](*)h[n] defined for integer index n=1 to N, > as usual when matlab is involved, and where (*) means convolution. > The whole data sequence x[n] is available in memory at the start of > the filtering operation. To keep it simple, we are talking about > zero-mean signals, to avoid some splitting of hairs over systems > with DC offset. > > If a delayed unit impulse d[n-k], [0 0 0 ... 0 1 0 ... 0] where > the '1' appears at the sample with index k, is applied as input to > the filter, the impulse response of the filter can be non-zero for > n < k as well as for n > k. In a causal filter the impulse response > is strictly 0 for n < k. > > I am sure you understand what I mean. Please feel free to help me > express it more unequivocally.
I think I know what you mean; after all, this was discussed only recently. Still, I can be sure only about what you wrote. Actually, my knowing what you mean is not important. Someone who doesn't know and who looks it up fill find useless definitions like adjective 1 : of, relating to, or constituting a cause <causal negligence> 2 : involving causation or a cause <no causal relationship between driving without insurance and the accident &#2013266071;National Law Journal> <a causal link exists between the deceptive act and the injury &#2013266071;National Law Journal> 3 : arising from a cause In circuit theory, def(3) is extended to mean that no output appears before the input which causes it. Any other use isn't strictly correct, and while we sling those other uses around, that can cause great confusion among readers who assume we mean what we write. I would describe filtfilt an an off-line process rather than an acausal one. Since all of the data must be known before the second pass begins, causality simply doesn't apply. Jerry -- Engineering is the art of making what you want from things you can get. &#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;
Jerry Avins wrote:
> Rune Allnor wrote: > > Jerry Avins wrote: > > > >>Rune Allnor wrote: > >> > >> ... > >> > >> > >>>There is a non-causal filter, FILTFILT, available in matlab, > >> > >>By "non-causal", I don't suppose you mean that the output appears before > >>the input is applied. If I'm right, what do you mean? > > > > > > By "non-causal" I mean the following: > > > > Assume a signal y[n] = x[n](*)h[n] defined for integer index n=1 to N, > > as usual when matlab is involved, and where (*) means convolution. > > The whole data sequence x[n] is available in memory at the start of > > the filtering operation. To keep it simple, we are talking about > > zero-mean signals, to avoid some splitting of hairs over systems > > with DC offset. > > > > If a delayed unit impulse d[n-k], [0 0 0 ... 0 1 0 ... 0] where > > the '1' appears at the sample with index k, is applied as input to > > the filter, the impulse response of the filter can be non-zero for > > n < k as well as for n > k. In a causal filter the impulse response > > is strictly 0 for n < k. > > > > I am sure you understand what I mean. Please feel free to help me > > express it more unequivocally. > > I think I know what you mean; after all, this was discussed only > recently. Still, I can be sure only about what you wrote. Actually, my > knowing what you mean is not important. Someone who doesn't know and who > looks it up fill find useless definitions like > > adjective > 1 : of, relating to, or constituting a cause <causal negligence> > 2 : involving causation or a cause <no causal relationship between > driving without insurance and the accident -National Law Journal> > <a causal link exists between the deceptive act and the injury > -National Law Journal> > 3 : arising from a cause > > In circuit theory, def(3) is extended to mean that no output appears > before the input which causes it. Any other use isn't strictly correct, > and while we sling those other uses around, that can cause great > confusion among readers who assume we mean what we write. > > I would describe filtfilt an an off-line process
Yep. It only works off-line. But that's a practical matter and has nothing to do with whether it is causal or not. You could choose to work with a causal filter even in off-line applications. So "causal" and "on-line" are not synonyms, with the obvious extension to "noncausal" and "off-line".
> rather than an acausal > one. Since all of the data must be known before the second pass begins, > causality simply doesn't apply.
Sorry, I beg to differ. Leaving the subtleties of professional jargon aside (we discussed this a couple of years ago, see http://groups.google.com/group/comp.dsp/browse_frm/thread/46174ccbd583b5bb/84aae22860faae18?q=author:allnor@tele.ntnu.no+trancedental+imaginary+magic&rnum=1#84aae22860faae18 ) If one rejects the terms causal/anticausal/noncausal just because one works off-line, one can remove the terms completely since the only would serve to obfuscate communications. The terms stay, since they express properties of the systems regardless of whether they are used on-line or off-line. As you know, a non-causal system can not be implemented on-line, so the term serves a purpose in deciding what could be a suitable system for a given application. The term "causality" is, in the context of DSP, defined as "There is no reaction at the output of a system for n < k, when the system is excited by a Kronecker delta signal d[n-k]" where the d[n-k] signal was defined in my previous post. The only thing that matters, is the order of the samples, not whether the samples are available or not. Note that the index n is a tool to sort the samples of the data series in "proper" order, and that causality is defined in terms of this order. Physical time has nothing to do with it, from a mathematical point of view. Only in real-time applications does it become important, simply because we only have available samples for n > k to work with. The terms "causal" and "non-causal" remain, even for problems that do not involve physical time. Rune