Forums

FIR filter with arbitrary and phase responses

Started by klayman December 11, 2011
Hello!

I am working on a project, and I have to design a optimal complex FIR
filter with arbitrary amplitude and phase responses.
I found a MATLAB function 'cfirpm' which looks like a algorithm from this
article:
"Karam, L.J., and J.H. McClellan. "Complex Chebyshev Approximation for FIR
Filter Design." IEEE Trans. on Circuits and Systems II,March 1995.
Pgs.207-216."

But I can't realize how to work there with arbitrary phase..

I think, that is possible to get final filter in convolution of inpulse
responses of two filters - first filter - filter with arbitrary amplitude
response, second - with arbitrary phase.

So question is in design of _optimal_ filter with arbitrary phase.

Give me a hint, please


On 12 Des, 01:16, "klayman" <unklayman@n_o_s_p_a_m.gmail.com> wrote:
> Hello! > > I am working on a project, and I have to design a optimal complex FIR > filter with arbitrary amplitude and phase responses. > I found a MATLAB function 'cfirpm' which looks like a algorithm from this > article: > "Karam, L.J., and J.H. McClellan. "Complex Chebyshev Approximation for FIR > Filter Design." IEEE Trans. on Circuits and Systems II,March 1995. > Pgs.207-216." > > But I can't realize how to work there with arbitrary phase.. > > I think, that is possible to get final filter in convolution of inpulse > responses of two filters - first filter - filter with arbitrary amplitude > response, second - with arbitrary phase. > > So question is in design of _optimal_ filter with arbitrary phase. > > Give me a hint, please
What's the problem? You already have a matlab function. You presumably also have the docs for the same function. I assume you also know how to run matlab? If not, ask in the matlab forum. If you have a question about the article, then ask about the article. Rune
On 12/11/11 7:16 PM, klayman wrote:
> Hello! > > I am working on a project, and I have to design a optimal complex FIR > filter with arbitrary amplitude and phase responses. > I found a MATLAB function 'cfirpm' which looks like a algorithm from this > article: > "Karam, L.J., and J.H. McClellan. "Complex Chebyshev Approximation for FIR > Filter Design." IEEE Trans. on Circuits and Systems II,March 1995. > Pgs.207-216." > > But I can't realize how to work there with arbitrary phase.. > > I think, that is possible to get final filter in convolution of impulse > responses of two filters - first filter - filter with arbitrary amplitude > response, second - with arbitrary phase.
there's no simplicity to be gained in optimally designing a filter with flat amplitude response and arbitrary phase. switching the two around is not so bad, you can use Parks-McClellan to optimally design an FIR filter with arbitrary amplitude response and linear phase (conceptually zero-phase for a non-causal filter with symmetric impulse response about t=0). however a previous incarnation (the Minister of Algorithms) of Eric Jacobsen thought up an interesting trick at http://www.dspguru.com/dsp/tricks/using-parks-mcclellan-to-design-non-linear-phase-fir-filter the idea is to split your amplitude and phase specification into real part and imaginary part. for the real part, which is even symmetry in both the frequency and time domains, use the regular Parks-McClellan for Type 1 (odd length, even symmetry) or Type 2 (even length, even symmetry) FIRs. for the imaginary part, which is odd symmetry in both frequency and time domains, use the Parks-McClellan algorithm but kick on the "Hilbert transformer" mode (which designs a linear-phase filter with a 90 degree offset) for Type 3 (odd length, odd symmetry) or Type 4 (even length, odd symmetry) FIRs. pick the same length (even or odd) design both filters and just add their FIR coefficients. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
On Sun, 11 Dec 2011 18:16:36 -0600, klayman wrote:

> Hello! > > I am working on a project, and I have to design a optimal complex FIR > filter with arbitrary amplitude and phase responses. I found a MATLAB > function 'cfirpm' which looks like a algorithm from this article: > "Karam, L.J., and J.H. McClellan. "Complex Chebyshev Approximation for > FIR Filter Design." IEEE Trans. on Circuits and Systems II,March 1995. > Pgs.207-216." > > But I can't realize how to work there with arbitrary phase.. > > I think, that is possible to get final filter in convolution of inpulse > responses of two filters - first filter - filter with arbitrary > amplitude response, second - with arbitrary phase. > > So question is in design of _optimal_ filter with arbitrary phase. > > Give me a hint, please
If the filter is optimal, then wouldn't the phase of the filter be determined by the problem at hand, thus making it as far from arbitrary as you can get? -- Tim Wescott Control system and signal processing consulting www.wescottdesign.com

klayman wrote:

> Hello! > > I am working on a project, and I have to design a optimal complex FIR > filter with arbitrary amplitude and phase responses.
Define "optimal"
> I found a MATLAB function 'cfirpm' which looks like a algorithm from this > article: > "Karam, L.J., and J.H. McClellan. "Complex Chebyshev Approximation for FIR > Filter Design." IEEE Trans. on Circuits and Systems II,March 1995. > Pgs.207-216."
"MATLAB does all thinking for us" (TM)
> But I can't realize how to work there with arbitrary phase..
There is no easy way to make it "optimal" unless the optimal is meant in the least squares sense.
> I think, that is possible to get final filter in convolution of inpulse > responses of two filters - first filter - filter with arbitrary amplitude > response, second - with arbitrary phase.
That won't be optimal in any sense.
> So question is in design of _optimal_ filter with arbitrary phase. > Give me a hint, please
There is a program called "Meteor" for designing arbitrary FIR filters by direct optimization. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com

robert bristow-johnson wrote:


> http://www.dspguru.com/dsp/tricks/using-parks-mcclellan-to-design-non-linear-phase-fir-filter > > the idea is to split your amplitude and phase specification into real > part and imaginary part.
That would make a filter, but it won't be optimal. A trivial way to get a complex FIR with arbitrary amplitude/phase is by inverse FT. VLV
Hello,

see demo("complex")
http://www.dsprelated.com/showcode/210.php
No guarantees whether or not the result is optimal. It gives the
LMS-optimal solution to an intermediate problem, even though I doubt it
will be far off. At least you get a working filter.

PS: You're not the first one who's unsuccessfully trying to make the
earlier mentioned Matlab function work.
On 12/12/11 12:05 AM, Vladimir Vassilevsky wrote:
> > > robert bristow-johnson wrote: > > >> http://www.dspguru.com/dsp/tricks/using-parks-mcclellan-to-design-non-linear-phase-fir-filter >> >> the idea is to split your amplitude and phase specification into real >> part and imaginary part. > > That would make a filter, but it won't be optimal.
it is in the sense of the minmax norm and if you're measuring error as the max of the real-part error and imag-part error (not a Euclidian norm).
> A trivial way to get a complex FIR with arbitrary amplitude/phase is by > inverse FT.
i think we call that the "windowing method". (maybe the window is the rectangular window, which makes this the most trivial method.) -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
>On 12/11/11 7:16 PM, klayman wrote: >> Hello! >> >> I am working on a project, and I have to design a optimal complex FIR >> filter with arbitrary amplitude and phase responses. >> I found a MATLAB function 'cfirpm' which looks like a algorithm from
this
>> article: >> "Karam, L.J., and J.H. McClellan. "Complex Chebyshev Approximation for
FIR
>> Filter Design." IEEE Trans. on Circuits and Systems II,March 1995. >> Pgs.207-216." >> >> But I can't realize how to work there with arbitrary phase.. >> >> I think, that is possible to get final filter in convolution of impulse >> responses of two filters - first filter - filter with arbitrary
amplitude
>> response, second - with arbitrary phase. > >there's no simplicity to be gained in optimally designing a filter with >flat amplitude response and arbitrary phase. switching the two around >is not so bad, you can use Parks-McClellan to optimally design an FIR >filter with arbitrary amplitude response and linear phase (conceptually >zero-phase for a non-causal filter with symmetric impulse response about >t=0). > >however a previous incarnation (the Minister of Algorithms) of Eric >Jacobsen thought up an interesting trick at > > >http://www.dspguru.com/dsp/tricks/using-parks-mcclellan-to-design-non-linear-phase-fir-filter
> > >the idea is to split your amplitude and phase specification into real >part and imaginary part. > >for the real part, which is even symmetry in both the frequency and time >domains, use the regular Parks-McClellan for Type 1 (odd length, even >symmetry) or Type 2 (even length, even symmetry) FIRs. > >for the imaginary part, which is odd symmetry in both frequency and time >domains, use the Parks-McClellan algorithm but kick on the "Hilbert >transformer" mode (which designs a linear-phase filter with a 90 degree >offset) for Type 3 (odd length, odd symmetry) or Type 4 (even length, >odd symmetry) FIRs. > >pick the same length (even or odd) design both filters and just add >their FIR coefficients. > >-- > >r b-j rbj@audioimagination.com > >"Imagination is more important than knowledge." > >
However, the original post is about complex filter. Above trick implies real filter I think. I have done digital pre-correction for amplitude and phase of RF channel distortion. The task is no easy (the full package of work took 3 months). For coeff generation I tried both cremez(named cfirpm now) but then moved to a Least Squares Method using pseudoinverse matrix computation, as it was slightly better and resulted in smaller dynamic range coeffs. cremez accepts amp/phase (or groupdelay) as inputs while LMS method I used accepted I/Q. The key points were: 1) apply correction to your signal band only. set distortion to null outside your band. 2)remove any linear gradient from phase(or integer time delay from groupdelay) so that you remove the burden of correcting for pure delay. Admittedly, both algorithms (cremez and LMS) worked within narrow range of distortion and were unpredictable if distortion was a bit high. Kadhiem
On 12/18/11 5:04 AM, kaz wrote:
> > However, the original post is about complex filter. Above trick implies > real filter I think.
lessee, what's a complex filter? one with complex voltages going in and coming out? (i would like to get my hands on a voltmeter that would measure the real and imaginary parts of an instantaneous voltage value.) a complex filter is one that has derived or contrived imaginary parts in the input and output signals and, assuming it's LTI, really is 4 real filters: real in to real out summed with imag in to real out, real in to imag out and imag in to imag out (also summed). and the imag out is a label. not a physical thing. now, i think, if that filter behaves appropriately (analytically), the real to real and imag to imag must be the same transfer function (with a real impulse response), and the real to imag and imag to real are the same transfer function (also with a real impulse response), but negatives of each other. since the two impulse responses are real, if the two real filters are both causal, the real and imag parts of the frequency responses are Hilbert pairs, and if the filters are meant to be minimum phase, the log magnitude and phase responses are Hilbert pairs. so there are really two real filters with arbitrary magnitude and *perhaps* arbitrary phase response (it doesn't *have* to be minimum phase and maybe not even causal). and they can be designed optimally (in the sense of the minmax norm, not a Euclidian norm) by that trick that Eric put on the dspguru site. or, as Vlad mentioned, you can design it less optimally, but easily, by computing the impulse response of the arbitrary filter and windowing it. i would suggest using a Kaiser window with beta somewhere around 5. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."