DSPRelated.com
Forums

Polyphase filter questions

Started by Unknown March 12, 2007
<redpathdu@yahoo.co.uk> wrote in message 
news:1173895735.550673.64050@e1g2000hsg.googlegroups.com...
>I just wanted to clarify some decimation issues with you in regards to > the polyphase decimator I created. As stated earlier, my specification > is as follows > > Lowpass filter > Cut off freq = 1KHz > Stop freq = 2KHz > Fsample = 100KHz > No of samples = 360 > > and I want to downsample by 10 to 10 KHz > > My input signal is a composite of 500Hz + 1800Hz + 3KHz and I see them > correctly on the analyzer when sampling at 100 KHz. At the output of > the filter, I would expect to see the 500 Hz signal while the 1.8KHz > and 3KHz would be attenuated. > > Here are a few questions. I just want to verify my understanding is > correct. > > If I downsample by 10.... > > 1...Will the cut off freq be 100 Hz and Stop freq 200 Hz ? > 2...Will the input signal now be 50Hz + 180Hz + 300Hz > > My understanding is that fcut and fstop will remain 1 Khz and 2 KHz > respectively and that the input signal spectrum shouldn't change, but > I am no expert.
Duncan, What happens is this: You have a signal that conceptually occupies the full bandwidth up to fs/2 or, for your immediate case, 50kHz. You want to decimate it to a new fs'=fs/10=10kHz. When you're done, you want a signal that has effectively unnoticeable aliasing. Because the sample rate will be 10kHz, this means that the signal to be sampled at 10kHz must have no appreciable content above 5kHz. The process goes like this: - Start with a conceptual signal with content up to 50kHz. - Lowpass filter this signal (at the original sample rate of 100kHz) with the stopband beginning at 5kHz or less. - Now you have a conceptual signal, sampled at 100kHz, that has content up to 5kHz. - Because it is effectively bandlimited to 5kHz, you can safely sample it at 10kHz. - Sample it at 10kHz..... which just means decimating by a factor of 10. Does this make sense to you? So, to directly answer your questions: Q: Will the cut off freq be 100 Hz and Stop freq 200 Hz ? A: The cutoff frequency of any filter is relative to the sample rate you're using. The *fractional* cutoff frequency is the constant. So, a 2kHz cutoff at a sample rate of 100kHz is 2% of fs. Then, if you change fs to 80kHz, the cutoff will be 0.02*80=1.6kHz .... and so on. In your case, the cutoff freuency is as you designed it to be. Polyphase has nothing to do with it. Q: Will the input signal now be 50Hz + 180Hz + 300Hz A: No. For the reasons given above. The signal content remains the same (subject to the attenuation below fs'/2 that you mention that is intentional). All the filter does is remove anything that's above fs'/2. Corollary 1: If you are working with a synthetic signal and you *know* there are no components above 3kHz then there's no reason to filter at all. You could say that the signal is "oversampled" at 100kHz. So, you could simply decimate the sequence of samples, with *no* filter, and be done with it. I caution that this is a theoretical observation and may not be appropriate in many practical situations. Corollary 2: If you consider the original signal before it was sampled then could it have been sampled at 10kHz? Yes - because the Nyquist criterion is satisfied - (no energy at or above fs/2). So, decimating the 100kHz sequence (i.e. ignoring 9 out of 10 samples) is exactly the same thing as having sampled at 10kHz in the first place. Fred
Hi Fred,

Thanks for that...that clarifies what I thought. The reason I'm asking
is that I see some peaks that I don't expect. I've check the
coefficients and they are the same as for a filter sampled at 100 KHz,
which works fine.

One other question regarding gain. For an Upsampler, the gain is N
times lower, as I'm only using the Nth sample..is it the opposite for
downsampled signals?

I could use a standard FIR either with an original sampling frequency
of 10KHz as there is no signals above 5KHz  and I suppose I could
sample at 100 KHz and then throw away 9 out of the 10 samples
effectively downsampling to 10 KHz, but I wanted to prove this
polyphase method.

Thanks to all for their replies. I'll figure it out, and I'll let you
all know what silly mistake I was making.

Duncan






<redpathdu@yahoo.co.uk> wrote in message 
news:1173957011.647491.49710@o5g2000hsb.googlegroups.com...
> Hi Fred, > > Thanks for that...that clarifies what I thought. The reason I'm asking > is that I see some peaks that I don't expect. I've check the > coefficients and they are the same as for a filter sampled at 100 KHz, > which works fine. > > One other question regarding gain. For an Upsampler, the gain is N > times lower, as I'm only using the Nth sample..is it the opposite for > downsampled signals? > > I could use a standard FIR either with an original sampling frequency > of 10KHz as there is no signals above 5KHz and I suppose I could > sample at 100 KHz and then throw away 9 out of the 10 samples > effectively downsampling to 10 KHz, but I wanted to prove this > polyphase method. > > Thanks to all for their replies. I'll figure it out, and I'll let you > all know what silly mistake I was making. > > Duncan
Duncan, Once more, polyphase is an implementation detail and the results should be the same as for a directly implemented FIR. The polyphase trick is in recognizing that only certain coefficients are "active" in the sum at each output - thus, only those need be applied. Then, the use of coefficients rotates through the entire set in some regular way. You say: "I checked the coefficients and they are the same as for a filter that operates at 100kHz." Hmmmmm.... just like the FIR, the polyphase filter has to operate at 100kHz for this case (input rate and output rate). Now, each *path* in the polyphase operates with larger delays but each path generally has different coefficients - so *not* (each) the same as for a filter that operates at 100kHz. There are a few different ways to do it so I can't comment more specifically. I hope this clarifies rather than confuses. I suspect you meant the same thing but I thought it good to check because you seem to be having trouble with polyphase implementation. Do the unit sample results between the FIR and the polyphase look identical? They should. Fred
> > Once more, polyphase is an implementation detail and the results should be > the same as for a directly implemented FIR. The polyphase trick is in > recognizing that only certain coefficients are "active" in the sum at each > output - thus, only those need be applied. Then, the use of coefficients > rotates through the entire set in some regular way.
Understand that
> > You say: > "I checked the coefficients and they are the same as for a filter that > operates at 100kHz." > > Hmmmmm.... just like the FIR, the polyphase filter has to operate at 100kHz > for this case (input rate and output rate). Now, each *path* in the > polyphase operates with larger delays but each path generally has different > coefficients - so *not* (each) the same as for a filter that operates at > 100kHz. There are a few different ways to do it so I can't comment more > specifically. I hope this clarifies rather than confuses. I suspect you > meant the same thing but I thought it good to check because you seem to be > having trouble with polyphase implementation.
The individual filter coefficients are different. They are organised as for the polyphase structure h0, h10, h20 ; h9, h19, h29 etc
> > Do the unit sample results between the FIR and the polyphase look identical? > They should.
Not sure what you mean here..
> > Fred- Hide quoted text - > > - Show quoted text -
<redpathdu@yahoo.co.uk> wrote in message 
news:1173981792.528090.5440@d57g2000hsg.googlegroups.com...
> > > The individual filter coefficients are different. They are organised > as for the polyphase structure > h0, h10, h20 > ; > h9, h19, h29 > > etc
OK - that settles that.
>> Do the unit sample results between the FIR and the polyphase look >> identical? >> They should. > > Not sure what you mean here.. >>
I understood that you had a FIR filter that was supposed to do the same thing (had the same coefficients). Using that filter for comparison, if you input a "unit sample": [ ......0 0 0 0 0 0 0 0 0 0 0 0 *1* 0 0 0 0 0 0 0 0 0 0 0 0......] (with the * * added for emphasis) the output from the FIR filter should look the same as the output from the polyphase filter. And, since it's a fairly narrow lowpass, the result is going to look something like a fairly broad sinx/x. If they don't compare well then there's likely something wrong with the polyphase implementation. If the polyphase filter also does the decimation as part of its implementation then you have to apply this test by comparing the decimated output of the FIR to the output of the polyphase filter (decimated) . Fred
Hi Fred,

That shed some light on it. I applied a unit sample to the standard
FIR and looked at it on the spectrum analyzer...fine, polyphase
interpolator...fine, polyphase decimator...not fine at all. Now
looking at the code. Will keep you posted.

Cheers
Duncan

<redpathdu@yahoo.co.uk> wrote in message 
news:1174085261.719268.134920@l77g2000hsb.googlegroups.com...
> Hi Fred, > > That shed some light on it. I applied a unit sample to the standard > FIR and looked at it on the spectrum analyzer...fine, polyphase > interpolator...fine, polyphase decimator...not fine at all. Now > looking at the code. Will keep you posted. > > Cheers > Duncan
I might rather have looked at the sample sequence or the output on an oscilloscope (i.e. vs. time). Looking at the output of a spectrum analyzer might obscure things a bit. But, if you can interpret it, then fine. Fred
Hi Fred,

Looked at the results both on scope and spec analyzer. One thing I
need to ask you about is when you apply the unit sample to the
polyphase decimator. I apply the data at the input via a commutator
arrangement. However, the unit sample only gets applied to filter5.
The rest of the filters are filled with zeros. Therefore the output of
the whole polyphase filter is just based on the convolution of the
unit sample with the coefficients of filter5. The rest of the filters
in the structure have no effect because their outputs are always zero.
Is this correct?

Duncan


<redpathdu@yahoo.co.uk> wrote in message 
news:1174320586.873587.206550@p15g2000hsd.googlegroups.com...
> Hi Fred, > > Looked at the results both on scope and spec analyzer. One thing I > need to ask you about is when you apply the unit sample to the > polyphase decimator. I apply the data at the input via a commutator > arrangement. However, the unit sample only gets applied to filter5. > The rest of the filters are filled with zeros. Therefore the output of > the whole polyphase filter is just based on the convolution of the > unit sample with the coefficients of filter5. The rest of the filters > in the structure have no effect because their outputs are always zero. > Is this correct? > > Duncan
Duncan, I was afraid of that! In fact, why should it be filter5 instead of any other? Only the phase of the commutator seems would determine that - or the absolute temporal placement of the unit sample. This works better (to visualize) *before* the decimation. After all, the timing of the decimation is arbitrary isn't it? So, the unit sample response out of the filter/decimated should be just that.... Let's see now.... it causes one to ask: "what is the unit sample response after decimation?" The answer should be that it remains a sinc-shaped response so that it coincides with being lowpassed. Is that what you see? Yes! because the sinc shape is quite broad for a narrow lowpass and resampling it (decimating it) should cause the shape to remain. Depending on the phase of the sampling/decimation, you may or may not hit the sinc peak is all. Fred
Hi Fred,

Finally got it fixed. Output waveforms look good, except for one
thing...the output, though spectrally correct is very low compared to
the input...there is a great deal of attenuation. Can this attenuation
be quantified?

Duncan