Rune Allnor wrote:> tanmay.zargar@gmail.com wrote: > >>Hello, >> >>I have two filters, one designed for a sampling frequency of 16kHz > > and > >>the other for a sampling frequency of 8kHz. The type and kind of >>filters (FIR/IIR, HP/LP/Notch) is irrelevant. I need to plot the >>overall transfer function of this cascaded pair. What changes do I > > have > >>to make (in the 8kHz filter, I am assuming), if any at all, in order > > to > >>cascade the two filters? > > > Hmmmm.... I don't like this question at all. You don't mention > whether the filters are interrelated in any way, so I must assume > they are not. > > In time domain: The 16 kHz filter is sampled twice as fast as the > 8 kHz filter. How do you convolve the impulse responses? > I don't know. > > In frequency domain: The sampling and nyquist frequencies are > different. Unless explicitly stated that this can not happen, > the below combination of frequency responses are troublesome > [use fixed-width font]: > > ^ > | > | ______________ H2 ______________ > | | | | | > | | | | | > | __|_ H1 _|_ __|_ _|_ > | / | \ / | \ / | \ / | \ > |/ | \ / | \|/ | \ / | \ > +-----------------------+-----------------------+-----> > 8 kHz 16 kHz > > wher H1 is the spectrum magnitude response of the 8 kHz filter > and H2 is the spectrum magnitude response of the 16 kHz filter. > I am not very happy with this rather peculiar interaction > between the baseband of the 16 kHz filetr and the repeated, > mirrored band of the 8 kHz filter. > > In short, I think the question is ill posed. > > >>Pointers to any literature that deals with such issues will be > > greatly > >>appreciated. > > > You have to specify some relation between the filters, like a > multirate filter bank or subband filters, or something like that. > As the question is posed, I don't like it. > > RuneIt's a homework problem with a red herring: two filters, one designed for one sampling frequency, another for twice that sampling frequency, are cascaded as designed, with no modification. What is the overall response? Cascading is the red herring. The pith of the question is "a filter designed to have a response f1(z) at one sampling frequency is fed a signal sampled at half that. What will the response f2(z) be for the same z? It's intuitive that f2(z) = f1(z^2). Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Cascading filters with different sampling frequencies.
Started by ●April 27, 2005
Reply by ●April 28, 20052005-04-28
Reply by ●April 28, 20052005-04-28
"Michael" <michael.numminen@comhem.se> wrote in message news:3T8ce.135797$dP1.479004@newsc.telia.net...> Dear all! > > I have following the discussion below. Assume that we want cascade two > filters n1(n) and h2(n) together where the last one operates on a higher > sampling frequency, i.e h2(n) = h1(2n). Shouldn't it be possible transform > these two two filter into frequency domain by N-points DFT > > H2(w) = DFT{h2(n)} > > and > > H1(w) = DFT{h1(n)} > > and then perfom a block-wise processing including IDFT (add and save or > some else) for the following > > y(n) = IDFT{H1(w)H2(w)X(w)}. > > In my mind we don't need to have different sampling frequencies becaus of > the periodicity properities for the h2(n) in the frequency domain. > > Is that correct? > > Thanks all and all the best, > Michael N.Michael, I think you have the right idea but the expression leaves out a few, possibly important, details. You say: h1(n)=h2(2n) which implies that the filter coefficients or unit sample responses are identical. I'm not sure that's what you meant to say because it seems curious. But, if that's what you meant, OK. When you say:> H2(w) = DFT{h2(n)} > > and > > H1(w) = DFT{h1(n)} > > and then perfom a block-wise processing including IDFT (add and save or > some else) for the following > > y(n) = IDFT{H1(w)H2(w)X(w)}. >You should somehow account for the difference in sampling rate - and these expressions don't do that. The "w" for H1 and the "w" for H2 are on different scales as originally presented. But then you say:> In my mind we don't need to have different sampling frequencies becaus of > the periodicity properities for the h2(n) in the frequency domain.So, it seems that you understand that H2, if plotted on the same w scale as H1 will repeat (i.e. "the periodicity properties for the h2(n) in the frequency domain"). But, how to express that? You start out by saying that the sampling frequencies are different and then conclude that "we don't need to have different sampling frequencies". It seems you contradict yourself. It's much better to express the situation this way: I have filter h1 with unit sample response h1(m); m=0,1,2,3,4, ..... M I have filter h2 with unit sample response h2(n); n= 0,1,2,3,4, ..... N And, for reasons important to my situation (the way the filters were designed or the way they are implemented or for purposes of classroom study), the sample interval for which h1 was designed and/or implemented is 1/2 the sample interval for which h2 was designed and/or implemented. Perhaps that could be expressed by saying h1(n)=h1(2m)| m=0,1,2,3,4, ..... M and h1(n)=0;n=1,3,5.... h2(n); for all: n= 0,1,2,3,4, ..... N Now you have two sequences that are on the same time scale and can be transformed to be dealt with on the same frequency scale. Or, as you suggest, one might say: H1(w) has a period of w=0 > K which we will call H(W) H2(w) has a period of w=0>K/2 So, the two can be dealt with over the largest of the two intervals which is w=0>K Accordingly H2(w) is constructed with: H2(W) for W=0>K/2 = H2(w) w=0>K/2 and H2(W) for W=K/2>K = H2(w) W=0>K/2 or, more concisely if the notation is understood, H2 is "doubled": H2(W)=[H2(w),H2(w)] But, I think this isn't the normal way to discuss these things and makes it harder to understand. Fred
Reply by ●April 29, 20052005-04-29
Phew, those were some really loaded replies. Anyways, I seek to make matters simpler and state my issues more plainly, simply because, since then, I have gained some insight into them, thanks mainly to the replies on this post. Here is what I have done - I have a filter H1(z) = 1 + b1*z^-1 + b2*z^-2 --------------------- 1 + a1*z^-1 + a2*z^-2 (This filter has been designed for a sampling frequency of "Fs" Hz) I plotted the magnitude response of this filter. Now, I went ahead and created a second filter H2(z) which is H1(z^2) H2(z) = 1 + b1*z^-2 + b2*z^-4 --------------------- 1 + a1*z^-2 + a2*z^-4 Now when I went ahead the plotted the magnitude response of this filter, I found that its sampling frequency had halved. I am trying to figure out the mathematical relation that will explain this since it was not intuitive to me. So plainly stated, this is my question. I agree it is very different from what I had originally asked and I apologize for the confusion. However, this now makes me think that if I have to simulate a decimator (say decimation factor is 2) between two filter blocks, say H1(z) and H2(z), here is what I can do -> Design both filters at the same sampling frequency, say Fs. > Then go ahead and replace H2(z) by H2(z^2) (2 can be replaced by thedecimation factor). This effectively halves the sampling frequency for the 2nd filter. In other words, if I have designed a filter at a particular sampling frequency, I can easily extend it to a filter at a different integer-decimated frequency using the method above. No recalculations needed. Inputs, anyone? T. Fred Marshall wrote:> "Michael" <michael.numminen@comhem.se> wrote in message > news:3T8ce.135797$dP1.479004@newsc.telia.net... > > Dear all! > > > > I have following the discussion below. Assume that we want cascadetwo> > filters n1(n) and h2(n) together where the last one operates on ahigher> > sampling frequency, i.e h2(n) = h1(2n). Shouldn't it be possibletransform> > these two two filter into frequency domain by N-points DFT > > > > H2(w) = DFT{h2(n)} > > > > and > > > > H1(w) = DFT{h1(n)} > > > > and then perfom a block-wise processing including IDFT (add andsave or> > some else) for the following > > > > y(n) = IDFT{H1(w)H2(w)X(w)}. > > > > In my mind we don't need to have different sampling frequenciesbecaus of> > the periodicity properities for the h2(n) in the frequency domain. > > > > Is that correct? > > > > Thanks all and all the best, > > Michael N. > > Michael, > > I think you have the right idea but the expression leaves out a few, > possibly important, details. > > You say: h1(n)=h2(2n) which implies that the filter coefficients orunit> sample responses are identical. I'm not sure that's what you meantto say> because it seems curious. But, if that's what you meant, OK. > > When you say: > > H2(w) = DFT{h2(n)} > > > > and > > > > H1(w) = DFT{h1(n)} > > > > and then perfom a block-wise processing including IDFT (add andsave or> > some else) for the following > > > > y(n) = IDFT{H1(w)H2(w)X(w)}. > > > > > You should somehow account for the difference in sampling rate - andthese> expressions don't do that. The "w" for H1 and the "w" for H2 are on > different scales as originally presented. > > But then you say: > > In my mind we don't need to have different sampling frequenciesbecaus of> > the periodicity properities for the h2(n) in the frequency domain. > > So, it seems that you understand that H2, if plotted on the same wscale as> H1 will repeat (i.e. "the periodicity properties for the h2(n) in the> frequency domain"). > > But, how to express that? You start out by saying that the sampling > frequencies are different and then conclude that "we don't need tohave> different sampling frequencies". It seems you contradict yourself. > > It's much better to express the situation this way: > > I have filter h1 with unit sample response h1(m); m=0,1,2,3,4, .....M> I have filter h2 with unit sample response h2(n); n= 0,1,2,3,4, .....N> And, for reasons important to my situation (the way the filters were > designed or the way they are implemented or for purposes of classroom> study), the sample interval for which h1 was designed and/orimplemented is> 1/2 the sample interval for which h2 was designed and/or implemented. > > Perhaps that could be expressed by saying > h1(n)=h1(2m)| m=0,1,2,3,4, ..... M > and > h1(n)=0;n=1,3,5.... > h2(n); > for all: n= 0,1,2,3,4, ..... N > > Now you have two sequences that are on the same time scale and can be> transformed to be dealt with on the same frequency scale. > > Or, as you suggest, one might say: > H1(w) has a period of w=0 > K which we will call H(W) > H2(w) has a period of w=0>K/2 > So, the two can be dealt with over the largest of the two intervalswhich is> w=0>K > Accordingly H2(w) is constructed with: > H2(W) for W=0>K/2 = H2(w) w=0>K/2 > and > H2(W) for W=K/2>K = H2(w) W=0>K/2 > or, more concisely if the notation is understood, H2 is "doubled": > H2(W)=[H2(w),H2(w)] > > But, I think this isn't the normal way to discuss these things andmakes it> harder to understand. > > Fred
Reply by ●April 29, 20052005-04-29
<tanmay.zargar@gmail.com> wrote in message news:1114794057.803896.226250@l41g2000cwc.googlegroups.com...> Phew, those were some really loaded replies. > > Anyways, I seek to make matters simpler and state my issues more > plainly, simply because, since then, I have gained some insight into > them, thanks mainly to the replies on this post. > > Here is what I have done - > > I have a filter > > H1(z) = 1 + b1*z^-1 + b2*z^-2 > --------------------- > 1 + a1*z^-1 + a2*z^-2 > > (This filter has been designed for a sampling frequency of "Fs" Hz) > > I plotted the magnitude response of this filter. > > Now, I went ahead and created a second filter H2(z) which is H1(z^2) > > H2(z) = 1 + b1*z^-2 + b2*z^-4 > --------------------- > 1 + a1*z^-2 + a2*z^-4 > > Now when I went ahead the plotted the magnitude response of this > filter, I found that its sampling frequency had halved. > > I am trying to figure out the mathematical relation that will explain > this since it was not intuitive to me. So plainly stated, this is my > question. I agree it is very different from what I had originally asked > and I apologize for the confusion. > > However, this now makes me think that if I have to simulate a decimator > (say decimation factor is 2) between two filter blocks, say H1(z) and > H2(z), here is what I can do - > >> Design both filters at the same sampling frequency, say Fs. >> Then go ahead and replace H2(z) by H2(z^2) (2 can be replaced by the > decimation factor). This effectively halves the sampling frequency for > the 2nd filter. > > In other words, if I have designed a filter at a particular sampling > frequency, I can easily extend it to a filter at a different > integer-decimated frequency using the method above. No recalculations > needed. > > Inputs, anyone? > > T.Tanmay, What I tried to say and perhaps failed: It is best to think that digital filters are not designed with a sampling frequency stated. They are designed assuming a unit delay or unit sampling frequency - i.e. they are normalized to time and frequency. Such a design might have a sample interval of 1 and a sample frequency of 1 or 2*pi radians per second. Then fs/2=0.5 "design" means: "determine the coefficients" and perhaps "determine the topology". A lowpass filter might be so "designed" with a cutoff frequency of 0.15fs. So, you see?, the cutoff frequency is *not* specified (yet) as something like 1200Hz. It is only when the sample frequency is 8kHz, that the cutoff might be 1200Hz. If the sample frequency is 16kHz, then the same filter's cutoff is 2400Hz. This is a fundamental difference in how one may look at digital filters. It is mostly implementation independent. If you look at it only the other way then there is bound to be confusion. It is only in implementation that a filter would be tied to a particular sample rate. Software implementations may not be sample rate "aware" at all! Just chunk through the samples as they are presented..... It is good that you made the second filter a function of z^-2 in some respects. Your statement "I found that its sampling frequency had halved" is really not "correct". What you have is a filter with sampling frequency related directly related to z which is the same for both filters. What you have is a filter that has a frequency response that *repeats* in the context of the z you have chosen. Either this is what you want or it isn't. I suspect you want a filter that doesn't repeat but, rather, one that filters the same frequencies the same way in *absolute* frequnecy terms as if the sample rate were halved. To do this you might want to redesign the lower-rate filter so that the frequency response is what you want at the rate of the higher-rate filter.>> Design both filters at the same sampling frequency, say Fs. >> Then go ahead and replace H2(z) by H2(z^2) (2 can be replaced by the > decimation factor). This effectively halves the sampling frequency for > the 2nd filter.I don't understand what you're doing here. If you design both filters at the same frequency then isn't the problem solved? I don't understand the motivation to "then go ahead and replace H2(z) by H2(z2)" Or, is your motivation to filter at a lower rate in one stage? That's not clear at all.> > In other words, if I have designed a filter at a particular sampling > frequency, I can easily extend it to a filter at a different > integer-decimated frequency using the method above. No recalculations > needed.No and yes. If you have designed a filter assuming a particular sampling frequency (which you need not do if things are normalized) then you can easily apply it to an application at a different sampling frequency - *as long as* you are willing to accept the same fractional band edge values like 0.15fs, 0.24fs, etc. So, if you design a lowpass filter for 0.15fs cutoff for *any* sample rate then when you use *any* sample rate the cutoff will remain 0.15fs. However, if you design a lowpass filter for 1200Hz cutoff at 8kHz sample rate then you can't "easily extend it" to a lowpass filter for 1200Hz cutoff at 16kHz sample rate. There is an exception to this that is done all the time in order to achieve decimation: Design *one* lowpass filter to cutoff at 0.2fs. Apply samples at some fs1 to this filter. Decimate the output by 2. Because the energy from 0.25fs1 to 0.75fs1 is close to zero, there will be no significant aliasing in doing this. The output is at sample rate fs2=fs1/2. Now, apply the decimated output to the *same* filter (at the new sample rate of fs2). Since the filter doesn't have a "sample rate", the new cutoff frequency is now 0.2fs2=0.1fs1. I hope this is clear. I don't comprehend a "method" in what you describe above. I don't comprehend what you're doing overall. I see decimation mentioned one place. I see replacing z by z^2 another..... It's very confusing and I have the sense that it's confusing you as well. Maybe *you* make a block diagram and we'll understand better. Keep asking and we'll get there! Fred
Reply by ●May 2, 20052005-05-02
Fred, I do understand that you cannot tie a sampling frequency to a filter when you are designing it. Essentially, the filter is normalized as in the sampling frequency corresponds to PI radians (or 1, in some cases). Depending on the sampling frequency you then use, the filter (I mean the cutoff frequency and other singularities) is scaled accordingly. Thanks for making the point clear. I was just trying to make sense of something I came across and have now realized that it did not need that complicated level of analysis. Here I let the matter rest. Thanks for the inputs people. T. Fred Marshall wrote:> <tanmay.zargar@gmail.com> wrote in message > news:1114794057.803896.226250@l41g2000cwc.googlegroups.com... > > Phew, those were some really loaded replies. > > > > Anyways, I seek to make matters simpler and state my issues more > > plainly, simply because, since then, I have gained some insightinto> > them, thanks mainly to the replies on this post. > > > > Here is what I have done - > > > > I have a filter > > > > H1(z) = 1 + b1*z^-1 + b2*z^-2 > > --------------------- > > 1 + a1*z^-1 + a2*z^-2 > > > > (This filter has been designed for a sampling frequency of "Fs" Hz) > > > > I plotted the magnitude response of this filter. > > > > Now, I went ahead and created a second filter H2(z) which isH1(z^2)> > > > H2(z) = 1 + b1*z^-2 + b2*z^-4 > > --------------------- > > 1 + a1*z^-2 + a2*z^-4 > > > > Now when I went ahead the plotted the magnitude response of this > > filter, I found that its sampling frequency had halved. > > > > I am trying to figure out the mathematical relation that willexplain> > this since it was not intuitive to me. So plainly stated, this ismy> > question. I agree it is very different from what I had originallyasked> > and I apologize for the confusion. > > > > However, this now makes me think that if I have to simulate adecimator> > (say decimation factor is 2) between two filter blocks, say H1(z)and> > H2(z), here is what I can do - > > > >> Design both filters at the same sampling frequency, say Fs. > >> Then go ahead and replace H2(z) by H2(z^2) (2 can be replaced bythe> > decimation factor). This effectively halves the sampling frequencyfor> > the 2nd filter. > > > > In other words, if I have designed a filter at a particularsampling> > frequency, I can easily extend it to a filter at a different > > integer-decimated frequency using the method above. Norecalculations> > needed. > > > > Inputs, anyone? > > > > T. > > Tanmay, > > What I tried to say and perhaps failed: > > It is best to think that digital filters are not designed with asampling> frequency stated. They are designed assuming a unit delay or unitsampling> frequency - i.e. they are normalized to time and frequency. Such adesign> might have a sample interval of 1 and a sample frequency of 1 or 2*pi> radians per second. Then fs/2=0.5 > "design" means: "determine the coefficients" and perhaps "determinethe> topology". > > A lowpass filter might be so "designed" with a cutoff frequency of0.15fs.> > So, you see?, the cutoff frequency is *not* specified (yet) assomething> like 1200Hz. > It is only when the sample frequency is 8kHz, that the cutoff mightbe> 1200Hz. > If the sample frequency is 16kHz, then the same filter's cutoff is2400Hz.> > This is a fundamental difference in how one may look at digitalfilters. It> is mostly implementation independent. If you look at it only theother way> then there is bound to be confusion. > > It is only in implementation that a filter would be tied to aparticular> sample rate. > Software implementations may not be sample rate "aware" at all! Justchunk> through the samples as they are presented..... > > It is good that you made the second filter a function of z^-2 in some> respects. > Your statement "I found that its sampling frequency had halved" isreally> not "correct". > What you have is a filter with sampling frequency related directlyrelated> to z which is the same for both filters. > What you have is a filter that has a frequency response that*repeats* in> the context of the z you have chosen. > Either this is what you want or it isn't. > > I suspect you want a filter that doesn't repeat but, rather, one that> filters the same frequencies the same way in *absolute* frequnecyterms as> if the sample rate were halved. > > To do this you might want to redesign the lower-rate filter so thatthe> frequency response is what you want at the rate of the higher-ratefilter.> > >> Design both filters at the same sampling frequency, say Fs. > >> Then go ahead and replace H2(z) by H2(z^2) (2 can be replaced bythe> > decimation factor). This effectively halves the sampling frequencyfor> > the 2nd filter. > > I don't understand what you're doing here. If you design bothfilters at> the same frequency then isn't the problem solved? > I don't understand the motivation to "then go ahead and replace H2(z)by> H2(z2)" > > Or, is your motivation to filter at a lower rate in one stage?That's not> clear at all. > > > > > In other words, if I have designed a filter at a particularsampling> > frequency, I can easily extend it to a filter at a different > > integer-decimated frequency using the method above. Norecalculations> > needed. > > No and yes. If you have designed a filter assuming a particularsampling> frequency (which you need not do if things are normalized) then youcan> easily apply it to an application at a different sampling frequency -*as> long as* you are willing to accept the same fractional band edgevalues like> 0.15fs, 0.24fs, etc. > So, if you design a lowpass filter for 0.15fs cutoff for *any* samplerate> then when you use *any* sample rate the cutoff will remain 0.15fs. > However, if you design a lowpass filter for 1200Hz cutoff at 8kHzsample> rate then you can't "easily extend it" to a lowpass filter for 1200Hzcutoff> at 16kHz sample rate. > > There is an exception to this that is done all the time in order toachieve> decimation: > Design *one* lowpass filter to cutoff at 0.2fs. > Apply samples at some fs1 to this filter. > Decimate the output by 2. Because the energy from 0.25fs1 to 0.75fs1is> close to zero, there will be no significant aliasing in doing this. > The output is at sample rate fs2=fs1/2. > Now, apply the decimated output to the *same* filter (at the newsample rate> of fs2). > Since the filter doesn't have a "sample rate", the new cutofffrequency is> now 0.2fs2=0.1fs1. > > I hope this is clear. > > I don't comprehend a "method" in what you describe above. I don't > comprehend what you're doing overall. I see decimation mentioned oneplace.> I see replacing z by z^2 another..... It's very confusing and I havethe> sense that it's confusing you as well. > > Maybe *you* make a block diagram and we'll understand better. Keepasking> and we'll get there! > > Fred