DSPRelated.com
Forums

Shifting FIR frequency centre

Started by kaz April 13, 2012
On Fri, 13 Apr 2012 13:49:01 -0400, robert bristow-johnson wrote:

> On 4/13/12 1:11 PM, Tim Wescott wrote: >> On Fri, 13 Apr 2012 11:56:40 -0400, robert bristow-johnson wrote: >> >>> On 4/13/12 4:26 AM, kaz wrote: >>>> You design a linear FIR(symmetrical real coefficients) then you >>>> decide to move its frequency centre. >>> >>> how are you doing that? by redesigning it (with all design parameters >>> except one that are unchanged)? >>> >>> if you had an FIR, h[n], and you wanted to simply adjust the >>> coefficients to bump up or down the whole frequency response, you can >>> do something with the Hilbert transform and analytic signal (the same >>> thing we do to make a "frequency shifter"), but there are all sorts of >>> other things that happen in the chain, and it doesn't preserve phase >>> linearity. >> >> I'm not sure what you're thinking, but you can easily shift a lowpass >> FIR's response in frequency by multiplying it by a sinusoid. If you >> keep it real and multiply, then the result responds to both positive >> and negative frequencies; if you allow it to be complex and multiply by >> an inphase and quadrature component, then it'll just respond to one >> frequency. >> >> > it's close to what i am thinking. but, to keep it real, how are you > gonna just shift it up or just shift it down? multiplying by cos(wt) > shifts it in both directions (and adds the two). > > we *are* gonna be multiplying by e^(jwt) (where w or "omega" can be > positive to upshift or negative to downshift). but to turn this into a > realizable filter with real coefficients, how're you gonna do that > without the analytic signal (and how're you gonna get one of them > without help from Hilbert)?
To turn it into a realizable filter I shall rename the imaginary part as 'quadrature'. And to get a signal without help from Hilbert, I shall either defer the signal acquisition to another day, or I shall use an I/Q down-converter, neither of which methods require any Hilbert transforms. -- My liberal friends think I'm a conservative kook. My conservative friends think I'm a liberal kook. Why am I not happy that they have found common ground? Tim Wescott, Communications, Control, Circuits & Software http://www.wescottdesign.com
>On Fri, 13 Apr 2012 13:49:01 -0400, robert bristow-johnson wrote: > >> On 4/13/12 1:11 PM, Tim Wescott wrote: >>> On Fri, 13 Apr 2012 11:56:40 -0400, robert bristow-johnson wrote: >>> >>>> On 4/13/12 4:26 AM, kaz wrote: >>>>> You design a linear FIR(symmetrical real coefficients) then you >>>>> decide to move its frequency centre. >>>> >>>> how are you doing that? by redesigning it (with all design
parameters
>>>> except one that are unchanged)? >>>> >>>> if you had an FIR, h[n], and you wanted to simply adjust the >>>> coefficients to bump up or down the whole frequency response, you can >>>> do something with the Hilbert transform and analytic signal (the same >>>> thing we do to make a "frequency shifter"), but there are all sorts
of
>>>> other things that happen in the chain, and it doesn't preserve phase >>>> linearity. >>> >>> I'm not sure what you're thinking, but you can easily shift a lowpass >>> FIR's response in frequency by multiplying it by a sinusoid. If you >>> keep it real and multiply, then the result responds to both positive >>> and negative frequencies; if you allow it to be complex and multiply
by
>>> an inphase and quadrature component, then it'll just respond to one >>> frequency. >>> >>> >> it's close to what i am thinking. but, to keep it real, how are you >> gonna just shift it up or just shift it down? multiplying by cos(wt) >> shifts it in both directions (and adds the two). >> >> we *are* gonna be multiplying by e^(jwt) (where w or "omega" can be >> positive to upshift or negative to downshift). but to turn this into a >> realizable filter with real coefficients, how're you gonna do that >> without the analytic signal (and how're you gonna get one of them >> without help from Hilbert)? > >To turn it into a realizable filter I shall rename the imaginary part as >'quadrature'. And to get a signal without help from Hilbert, I shall >either defer the signal acquisition to another day, or I shall use an I/Q
>down-converter, neither of which methods require any Hilbert transforms. > >-- >My liberal friends think I'm a conservative kook. >My conservative friends think I'm a liberal kook. >Why am I not happy that they have found common ground? > >Tim Wescott, Communications, Control, Circuits & Software >http://www.wescottdesign.com >
I am only used to shifting FIR by multiplying it with a complex sinusoid and in Matlab e.g.: h1 = fir1(30,.1); h2 = h1 .* exp(j*2*pi*(0:30)*.13); % shift to .13 of Fs My point is about this approach specifically. h2 loses symmetry. I see its group delay stays 15 but with unexplained spikes. I doubt these to be true spikes and believe phase stays linear. If I am wrong then how do we frequency translate to preserve FIR quality? Kadhiem
On Fri, 13 Apr 2012 13:52:56 -0500, "kaz"
<kadhiem_ayob@n_o_s_p_a_m.yahoo.co.uk> wrote:

>>On Fri, 13 Apr 2012 13:49:01 -0400, robert bristow-johnson wrote: >> >>> On 4/13/12 1:11 PM, Tim Wescott wrote: >>>> On Fri, 13 Apr 2012 11:56:40 -0400, robert bristow-johnson wrote: >>>> >>>>> On 4/13/12 4:26 AM, kaz wrote: >>>>>> You design a linear FIR(symmetrical real coefficients) then you >>>>>> decide to move its frequency centre. >>>>> >>>>> how are you doing that? by redesigning it (with all design >parameters >>>>> except one that are unchanged)? >>>>> >>>>> if you had an FIR, h[n], and you wanted to simply adjust the >>>>> coefficients to bump up or down the whole frequency response, you can >>>>> do something with the Hilbert transform and analytic signal (the same >>>>> thing we do to make a "frequency shifter"), but there are all sorts >of >>>>> other things that happen in the chain, and it doesn't preserve phase >>>>> linearity. >>>> >>>> I'm not sure what you're thinking, but you can easily shift a lowpass >>>> FIR's response in frequency by multiplying it by a sinusoid. If you >>>> keep it real and multiply, then the result responds to both positive >>>> and negative frequencies; if you allow it to be complex and multiply >by >>>> an inphase and quadrature component, then it'll just respond to one >>>> frequency. >>>> >>>> >>> it's close to what i am thinking. but, to keep it real, how are you >>> gonna just shift it up or just shift it down? multiplying by cos(wt) >>> shifts it in both directions (and adds the two). >>> >>> we *are* gonna be multiplying by e^(jwt) (where w or "omega" can be >>> positive to upshift or negative to downshift). but to turn this into a >>> realizable filter with real coefficients, how're you gonna do that >>> without the analytic signal (and how're you gonna get one of them >>> without help from Hilbert)? >> >>To turn it into a realizable filter I shall rename the imaginary part as >>'quadrature'. And to get a signal without help from Hilbert, I shall >>either defer the signal acquisition to another day, or I shall use an I/Q > >>down-converter, neither of which methods require any Hilbert transforms. >> >>-- >>My liberal friends think I'm a conservative kook. >>My conservative friends think I'm a liberal kook. >>Why am I not happy that they have found common ground? >> >>Tim Wescott, Communications, Control, Circuits & Software >>http://www.wescottdesign.com >> > >I am only used to shifting FIR by multiplying it with a complex sinusoid >and in Matlab e.g.: > >h1 = fir1(30,.1); >h2 = h1 .* exp(j*2*pi*(0:30)*.13); % shift to .13 of Fs > >My point is about this approach specifically. >h2 loses symmetry. I see its group delay stays 15 but with unexplained >spikes. I doubt these to be true spikes and believe phase stays linear. > >If I am wrong then how do we frequency translate to preserve FIR quality? > >Kadhiem >
Here's a thought experiment for you that may help. Remember that linear operations are commutative. You want to apply a bandpass filter just as it would be applied at baseband, correct? There are two ways: 1. Translate the filter (by multiplying by either a real or complex reference oscillator) as Tim has described. 2. Translate the signal to baseband (by multiplying by either a real or complex reference oscillator), filter the signal, translate it back to where it was in frequency. My understanding is that you want to make the two operations equivalent, correct? If so, you can rearrange the order of linear operations however you want. Complex mixes can be treated as linear for frequency translation and real-valued mixes can be (very carefully) treated as linear if one pays attention to steering clear of image products, other nonlinearities, etc. Eric Jacobsen Anchor Hill Communications www.anchorhill.com
> >Here's a thought experiment for you that may help. Remember that >linear operations are commutative. > >You want to apply a bandpass filter just as it would be applied at >baseband, correct? There are two ways: > >1. Translate the filter (by multiplying by either a real or complex >reference oscillator) as Tim has described. > >2. Translate the signal to baseband (by multiplying by either a real >or complex reference oscillator), filter the signal, translate it back >to where it was in frequency. > >My understanding is that you want to make the two operations >equivalent, correct? If so, you can rearrange the order of linear >operations however you want. Complex mixes can be treated as linear >for frequency translation and real-valued mixes can be (very >carefully) treated as linear if one pays attention to steering clear >of image products, other nonlinearities, etc. >
That makes sense but I want the FIR to be complex(without mirrored response) and we already have systems based on that. Thus I want to keep the imaginary term. Do you think then we might have lost phase linearity? Kadhiem
> >Eric Jacobsen >Anchor Hill Communications >www.anchorhill.com >
On 4/13/12 2:12 PM, Eric Jacobsen wrote:
> > Tim described this already. If you let the filter coefficients be > complex (and the OP mentioned this as well), then it already has the > analytic part and no Hilbert transformations are needed.
is the OPs *original* FIR a complex FIR that has zero frequency response for "negative" frequency (it's really the latter half of the DFT)? was that the given case, because if it were, that got by me.
> If you keep > only the real portions of the coefficients then there'll be an image > reflected across zero.
yup, we know that. now my question again is *how* do you get that analytic signal without either doing: h[n] + j * Hilbert{ h[n] } or its equivalent in the frequency domain: DFT{ h[n] } * 2 * rect((n - N/4)/(N/2)) ?? from an operational POV, where all of our numbers are eventually real numbers, if you're shifting something in *one* direction (either up or down, but not both), i still do not see how Hilbert (or his counterpart in the frequency domain) is avoided. On 4/13/12 2:52 PM, kaz wrote:
>> >> To turn it into a realizable filter I shall rename the imaginary part as >> 'quadrature'.
call it what you want, how're you getting it?
>> And to get a signal without help from Hilbert, I shall >> either defer the signal acquisition to another day,
that helps a lot.
>> or I shall use an I/Q >> down-converter, neither of which methods require any Hilbert transforms.
okay, so here is the kernel: please teach me, starting from a real-valued bandpass (meaning the spectrum is zero around the baseband, as if it were DSB-AM) signal x[n] to a I/Q without the *equivalent* of the H.T.? (very sharp filters that kill one sideband without touching the other is the frequency-domain equivalent.)
> I am only used to shifting FIR by multiplying it with a complex sinusoid > and in Matlab e.g.: > > h1 = fir1(30,.1); > h2 = h1 .* exp(j*2*pi*(0:30)*.13); % shift to .13 of Fs > > My point is about this approach specifically. > h2 loses symmetry.
it also loses its "realness". h1 is real, h2 is complex. my responses have been about ultimately keeping it real. and the reason you need some sorta Hilbert thing going on here, is that besides shifting the positive frequency components of h1 up by 0.13*Fs, you also shifted the negative frequency components up (in the positive direction) by 0.13*Fs, including those components below 0.13*Fs which crossed over zero and became new positive frequency components. did you want to do that (fold those components about DC)? the only way to avoid it is to kill all the negative frequency components and you can do that in the frequency domain by multiplying by zero, or you do it in the time domain by deriving the analytic signal of h1 which uses the MATLAB function called "hilbert()".
> I see its group delay stays 15 but with unexplained > spikes. I doubt these to be true spikes and believe phase stays linear.
Tim and Eric do communications for a living, i think. but i am convinced that i am correct that, if you *do* truly shift the whole frequency response of h1 up by anything non-zero, you are at least *equivalently* doing that thing with the hilbert transform of h1 that i outline. and while a purely even-symmetry part will stay even, and while the purely odd-symmetry part (which gets multiplied by zero, when h1 is unshifted) will stay odd (and both are phase linear), adding any non-zero combination will kill *both* the even and odd symmetrical properties (and your result is not phase linear in any sense).
> If I am wrong then how do we frequency translate to preserve FIR quality?
by "FIR quality", you mean the linear phase property of your *specific* FIR, right? i will say it again, you need to redesign the FIR (using whatever, firpm() or firls() or some windowed technique) to get both, the shifted frequency response *and* the linear phase property. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
On Fri, 13 Apr 2012 13:52:56 -0500, kaz wrote:

>>On Fri, 13 Apr 2012 13:49:01 -0400, robert bristow-johnson wrote: >> >>> On 4/13/12 1:11 PM, Tim Wescott wrote: >>>> On Fri, 13 Apr 2012 11:56:40 -0400, robert bristow-johnson wrote: >>>> >>>>> On 4/13/12 4:26 AM, kaz wrote: >>>>>> You design a linear FIR(symmetrical real coefficients) then you >>>>>> decide to move its frequency centre. >>>>> >>>>> how are you doing that? by redesigning it (with all design > parameters >>>>> except one that are unchanged)? >>>>> >>>>> if you had an FIR, h[n], and you wanted to simply adjust the >>>>> coefficients to bump up or down the whole frequency response, you >>>>> can do something with the Hilbert transform and analytic signal (the >>>>> same thing we do to make a "frequency shifter"), but there are all >>>>> sorts > of >>>>> other things that happen in the chain, and it doesn't preserve phase >>>>> linearity. >>>> >>>> I'm not sure what you're thinking, but you can easily shift a lowpass >>>> FIR's response in frequency by multiplying it by a sinusoid. If you >>>> keep it real and multiply, then the result responds to both positive >>>> and negative frequencies; if you allow it to be complex and multiply > by >>>> an inphase and quadrature component, then it'll just respond to one >>>> frequency. >>>> >>>> >>> it's close to what i am thinking. but, to keep it real, how are you >>> gonna just shift it up or just shift it down? multiplying by cos(wt) >>> shifts it in both directions (and adds the two). >>> >>> we *are* gonna be multiplying by e^(jwt) (where w or "omega" can be >>> positive to upshift or negative to downshift). but to turn this into >>> a realizable filter with real coefficients, how're you gonna do that >>> without the analytic signal (and how're you gonna get one of them >>> without help from Hilbert)? >> >>To turn it into a realizable filter I shall rename the imaginary part as >>'quadrature'. And to get a signal without help from Hilbert, I shall >>either defer the signal acquisition to another day, or I shall use an >>I/Q > >>down-converter, neither of which methods require any Hilbert transforms. >> >>-- >>My liberal friends think I'm a conservative kook. My conservative >>friends think I'm a liberal kook. Why am I not happy that they have >>found common ground? >> >>Tim Wescott, Communications, Control, Circuits & Software >>http://www.wescottdesign.com >> >> > I am only used to shifting FIR by multiplying it with a complex sinusoid > and in Matlab e.g.: > > h1 = fir1(30,.1); > h2 = h1 .* exp(j*2*pi*(0:30)*.13); % shift to .13 of Fs > > My point is about this approach specifically. h2 loses symmetry. I see > its group delay stays 15 but with unexplained spikes. I doubt these to > be true spikes and believe phase stays linear. > > If I am wrong then how do we frequency translate to preserve FIR > quality?
h1 is symmetrical around its center point -- yes? And you are multiplying it by something that is not symmetrical around its center point -- yes? Try multiplying by exp(j*2*pi*(-15:15)*.13) instead of exp(j*2*pi* (0:30)*.13). Assuming that you're starting with a filter that has even symmetry around the middle, that will make your resulting filter even- symmetric in the inphase and odd-symmetric in the quadrature, which should make the phase delay constant. I'd be able to reel of my reasoning, but it's buried in a non-verbal part of my brain right now, and I'm not even sure if I'm right -- so try it, then backfill the math on your own or start a new thread asking why. -- My liberal friends think I'm a conservative kook. My conservative friends think I'm a liberal kook. Why am I not happy that they have found common ground? Tim Wescott, Communications, Control, Circuits & Software http://www.wescottdesign.com
On Fri, 13 Apr 2012 15:42:48 -0400, robert bristow-johnson wrote:

> On 4/13/12 2:12 PM, Eric Jacobsen wrote: >> >> Tim described this already. If you let the filter coefficients be >> complex (and the OP mentioned this as well), then it already has the >> analytic part and no Hilbert transformations are needed. > > is the OPs *original* FIR a complex FIR that has zero frequency response > for "negative" frequency (it's really the latter half of the DFT)? was > that the given case, because if it were, that got by me. > >> If you keep >> only the real portions of the coefficients then there'll be an image >> reflected across zero. > > yup, we know that. now my question again is *how* do you get that > analytic signal without either doing: > > h[n] + j * Hilbert{ h[n] } > > or its equivalent in the frequency domain: > > DFT{ h[n] } * 2 * rect((n - N/4)/(N/2)) > > ?? > > from an operational POV, where all of our numbers are eventually real > numbers, if you're shifting something in *one* direction (either up or > down, but not both), i still do not see how Hilbert (or his counterpart > in the frequency domain) is avoided. > > On 4/13/12 2:52 PM, kaz wrote: >>> >>> To turn it into a realizable filter I shall rename the imaginary part >>> as 'quadrature'. > > call it what you want, how're you getting it? > >>> And to get a signal without help from Hilbert, I shall >>> either defer the signal acquisition to another day, > > that helps a lot. > >>> or I shall use an I/Q >>> down-converter, neither of which methods require any Hilbert >>> transforms. > > okay, so here is the kernel: please teach me, starting from a > real-valued bandpass (meaning the spectrum is zero around the baseband, > as if it were DSB-AM) signal x[n] to a I/Q without the *equivalent* of > the H.T.? (very sharp filters that kill one sideband without touching > the other is the frequency-domain equivalent.)
You ask the wrong question, and a different one from which Kaz asked. The one that Kaz asked was how do you start with a real-valued LOWpass prototype, and make it BANDpass. And that's the question that Eric and I answered. You are asking how you start with a real-valued BANDpass filter (which responds to both positive and negative frequencies) and make it into a complex-valued BANDpass filter which responds to just positive (or negative) frequencies. That, does, indeed, require a Hilbert transform or similar. But it's not the question at hand.
>> I am only used to shifting FIR by multiplying it with a complex >> sinusoid and in Matlab e.g.: >> >> h1 = fir1(30,.1); >> h2 = h1 .* exp(j*2*pi*(0:30)*.13); % shift to .13 of Fs >> >> My point is about this approach specifically. h2 loses symmetry. > > it also loses its "realness". h1 is real, h2 is complex. my responses > have been about ultimately keeping it real.
Why? Why do you need to? There are plenty of useful "complex valued" (quadrature valued if you must be a stickler, but I prefer complex valued myself) filters out there, happily operating in comms equipment that turns the signal into quadrature early on in the processing chain -- perhaps even before things are converted to digital.
> and the reason you need some sorta Hilbert thing going on here, is that > besides shifting the positive frequency components of h1 up by 0.13*Fs, > you also shifted the negative frequency components up (in the positive > direction) by 0.13*Fs, including those components below 0.13*Fs which > crossed over zero and became new positive frequency components. > > did you want to do that (fold those components about DC)? the only way > to avoid it is to kill all the negative frequency components and you can > do that in the frequency domain by multiplying by zero, or you do it in > the time domain by deriving the analytic signal of h1 which uses the > MATLAB function called "hilbert()".
Or you can do it in the time domain with a quadrature sampler. Really.
>> I see its group delay stays 15 but with unexplained spikes. I doubt >> these to be true spikes and believe phase stays linear.
I think the spikes come along for real, because of a book-keeping error in the generation of h2 -- see my post.
> Tim and Eric do communications for a living, i think. but i am > convinced that i am correct that, if you *do* truly shift the whole > frequency response of h1 up by anything non-zero, you are at least > *equivalently* doing that thing with the hilbert transform of h1 that i > outline. and while a purely even-symmetry part will stay even, and > while the purely odd-symmetry part (which gets multiplied by zero, when > h1 is unshifted) will stay odd (and both are phase linear), adding any > non-zero combination will kill *both* the even and odd symmetrical > properties (and your result is not phase linear in any sense).
You misunderstand -- I think because you are assuming that Kaz is starting with a bandpass filter, where he is starting with a lowpass. Taking the filter response in the frequency domain and shifting it up in frequency is mathematically the same as convolving it with an impulse at the desired frequency shift. Convolution in the frequency domain is equivalent to multiplication in the time domain. Kaz is multiplying his desired (but unshifted) prototype filter response by a complex sinusoid, which is an impulse in the frequency domain -- so he's getting his desired frequency shift.
>> If I am wrong then how do we frequency translate to preserve FIR >> quality? > > by "FIR quality", you mean the linear phase property of your *specific* > FIR, right? i will say it again, you need to redesign the FIR (using > whatever, firpm() or firls() or some windowed technique) to get both, > the shifted frequency response *and* the linear phase property.
Nope nope nope. Kaz is almost doing exactly the right thing. -- My liberal friends think I'm a conservative kook. My conservative friends think I'm a liberal kook. Why am I not happy that they have found common ground? Tim Wescott, Communications, Control, Circuits & Software http://www.wescottdesign.com
>Try multiplying by exp(j*2*pi*(-15:15)*.13) instead of exp(j*2*pi* >(0:30)*.13). Assuming that you're starting with a filter that has even >symmetry around the middle, that will make your resulting filter even- >symmetric in the inphase and odd-symmetric in the quadrature, which >should make the phase delay constant. > >Tim Wescott, Communications, Control, Circuits & Software >http://www.wescottdesign.com >
Thanks for that. Indeed that is what I found out now. Kadhiem
On 4/13/12 4:48 PM, Tim Wescott wrote:
> On Fri, 13 Apr 2012 15:42:48 -0400, robert bristow-johnson wrote: > >> okay, so here is the kernel: please teach me, starting from a >> real-valued bandpass (meaning the spectrum is zero around the baseband, >> as if it were DSB-AM) signal x[n] to a I/Q without the *equivalent* of >> the H.T.? (very sharp filters that kill one sideband without touching >> the other is the frequency-domain equivalent.) > > You ask the wrong question, and a different one from which Kaz asked. > > The one that Kaz asked was how do you start with a real-valued LOWpass > prototype, and make it BANDpass. And that's the question that Eric and I > answered.
well, i'll concede that you connected to Kaz's problem (as he said so), but i looked again and nowhere did i find him/her writing that he/she needed to shift the frequency "centre" from DC to something else. the words that i read was that he/she needed to move the center frequency of an FIR filter. (as if he/she was starting with an FIR filter with a center frequency that needed to be shifted.) never read "lowpass" anywhere.
> You are asking how you start with a real-valued BANDpass filter (which > responds to both positive and negative frequencies) and make it into a > complex-valued BANDpass filter which responds to just positive (or > negative) frequencies. > > That, does, indeed, require a Hilbert transform or similar. But it's not > the question at hand.
yeah, if you're mapping an LPF to a BPF, multiply the real impulse response by 2*cos(w*n). and, as you pointed out, with the symmetry of the cos() function centered at the same place the FIR is centered at. continuing to be a life-long student... -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
On 4/13/2012 2:20 PM, kaz wrote:
>> Try multiplying by exp(j*2*pi*(-15:15)*.13) instead of exp(j*2*pi* >> (0:30)*.13). Assuming that you're starting with a filter that has even >> symmetry around the middle, that will make your resulting filter even- >> symmetric in the inphase and odd-symmetric in the quadrature, which >> should make the phase delay constant. >> >> Tim Wescott, Communications, Control, Circuits& Software >> http://www.wescottdesign.com >> > > Thanks for that. Indeed that is what I found out now. > > Kadhiem
What's the purpose here? r b-j mentioned redesign. That's cheap, fast and effective. Why not? Or is this an exercise in math? Fred