Hello, I am looking for a closed form equation for coefficient bits, when passband ripple, stop band attenuation and number of coefficients are specified. Only for FIR filters. Regards Bharat

# fir coefficient quantization equation

Started by ●March 8, 2008

Reply by ●March 8, 20082008-03-08

bharat pathak wrote:> Hello, > > I am looking for a closed form equation for coefficient > bits, when passband ripple, stop band attenuation and > number of coefficients are specified. Only for FIR filters.I can't help, but I'm curious. You specify passband ripple, stopband attenuation, and filter order. What's your free variable? Transition width? Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������

Reply by ●March 8, 20082008-03-08

On Mar 8, 4:58�pm, Jerry Avins <j...@ieee.org> wrote:> bharat pathak wrote: > > Hello, > > > � � �I am looking for a closed form equation for coefficient > > � � �bits, when passband ripple, stop band attenuation and > > � � �number of coefficients are specified. Only for FIR filters. > > I can't help, but I'm curious. You specify passband ripple, stopband > attenuation, and filter order. What's your free variable? Transition width?That's one, but the only FIR type I can see which might come close to that sort of spec would be the Kaiser filter, which requires that beta parameter as well. The other 'non-exotic' FIR windows have fixed stopband ripples. Rune

Reply by ●March 8, 20082008-03-08

"bharat pathak" <bharat@arithos.com> wrote in message news:RpKdnSnfP-oKBU_anZ2dnUVZ_vOlnZ2d@giganews.com...> Hello, > > I am looking for a closed form equation for coefficient > bits, when passband ripple, stop band attenuation and > number of coefficients are specified. Only for FIR filters. > > Regards > BharatI really don't think you're going to find anything like this. The design algorithms use something approaching exhaustive search - it's not deterministic at all. So, saying what they will do a priori with a closed form solution seems very unlikely. Consider the universe of solutions: - generally one starts with an underlying filter design with infinite precision implied. - that means response characteristics as well as filter length. - then one has to state the objective criteria for the coefficients. - then one has to find a filter that meets *all* of the requirements. (this implies that one starts with a better filter than what one needs re: performance) I've been meaning to implement a "good enough" algorithm but have never gotten around to it. It would do this: 1) Use a modified Parks-McClellan algorithm 2) Find the best filter with infinite precision. 3) Find the one coefficient (or coefficient pair) that affects the response the most. 4) Fix that one coefficient pair according to the quantization specs. 5) Subtract the frequency response due to that one coefficient pair from the desired response. 6) Find the best filter of (now lesser order) that meets the modified response with infinite precision. 7) Repeat at Step 3 until all of the coefficients are quantized. The idea is that you accept the response of the worst offender first .. and iterate. If you don't like the results after computing the second filter then you can stop and start over with a longer filter - or just give up because your specs are too demanding overall. The weakness would be that coupling between coefficient changes would be ignored. The simplest method I know does this: 1) Start by scaling the entire filter so that the largest coefficient is 1.0 or 0.5 ... some power of 2. This eliminates quantization for the largest coefficient. This step could be replaced by one that finds the one coefficient for which the filter response is the most sensitive - and scale to fix that one. But, I'll bet that the largest is a good pick anyway. 2) Quantize all the other coefficients to some sum of powers of 2 with the number of bits being held to 1,2 or maybe 3. 3) Implement with shifts and adds. Although I guess modern processors will multiply just as fast as add. In view of that, does it still make sense to do this? Anyway, I hope you can see that finding an expression that will predict the result a priori is probably not likely. Fred

Reply by ●March 8, 20082008-03-08

On Mar 8, 8:09 am, "Fred Marshall" <fmarshallx@remove_the_x.acm.org> wrote:> ... > 3) Implement with shifts and adds. Although I guess modern processors will > multiply just as fast as add. In view of that, does it still make sense to > do this? > ... > FredPeople who can't wait for modern processors to add or multiply still use ASICs and FPGAs for speed and where gate count and power matter they also outperform DSPs and RISCs. Dale B. Dalrymple

Reply by ●March 8, 20082008-03-08

bharat pathak wrote:> Hello, > > I am looking for a closed form equation for coefficient > bits, when passband ripple, stop band attenuation and > number of coefficients are specified. Only for FIR filters.It is dead simple. Quantized FIR filter = Ideal FIR filter + FIR filter with the random coefficients. Each random coefficient equals to the quantization error. So, the error of the quantized filter = sqrt(length) x quantization error. The RMS quantization error is 1/3 of LSB. For the typical design requirements, the error matters only in the stopband. Got the idea? Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com

Reply by ●March 8, 20082008-03-08

Hello All, Thanks to all the people who responded to this post. Sometime back I was reading about this in Ifeachor Jervis book and wrote the octave code. which seems to work pretty well. Actually the idea is first overdesign your filters by 1db or 2db (in terms of stop band attenuation). This way you create some tolerance margin for magnitude errors caused by coefficient quantization, thus still meeting your original spec. Regards Bharat function B = cbits_fir(ap, as, nc, mode) % %------------------------------------------------------------------------------ % % This function helps in estimating number of bits required when we % quantize the coefficients of FIR filter. % % Usage: B = cbits_fir(ap, as, nc, mode) % % ap : pass band ripple in db. % as : stop band attenuation in db. % nc : number of coefficients of the filter. % % mode : 0 => conservative approach (Recommended). % mode : 1 => medium conservative approach. % mode : 2 => less conservative approach. % % B : computed precision required for coefficient precision. % %------------------------------------------------------------------------------ % ap = abs(ap); as = abs(as); d1 = (10^(ap/20)-1)/(10^(ap/20)+1) d2 = (1+d1)*(10^(-as/20)); del = min(d1, d2); if(mode == 0) ncm = nc; elseif(mode == 1) ncm = sqrt(nc/3); elseif(mode == 2) ncm = sqrt(nc*log(nc)/3); else disp("mode can take on values 0 or 1 or 2"); end B = ceil(-log10(del/ncm)/log10(2)); if(nc > 256) disp("Suggestion : Implement the FIR filter as cascade ... of smaller section like, first order, second order and ... fourth order sections."); end end

Reply by ●March 8, 20082008-03-08

bharat pathak wrote:> Hello All, > > Thanks to all the people who responded to this post. > > Sometime back I was reading about this in Ifeachor > Jervis book and wrote the octave code. which seems > to work pretty well. > > Actually the idea is first overdesign your filters > by 1db or 2db (in terms of stop band attenuation). > This way you create some tolerance margin for > magnitude errors caused by coefficient quantization, > thus still meeting your original spec.In mechanical engineering, that would be called a margin of safety (factor of safety - 1). Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������

Reply by ●March 10, 20082008-03-10

Jerry Avins wrote:> bharat pathak wrote: > >> Hello All, >> >> Thanks to all the people who responded to this post. >> >> Sometime back I was reading about this in Ifeachor >> Jervis book and wrote the octave code. which seems >> to work pretty well. >> Actually the idea is first overdesign your filters >> by 1db or 2db (in terms of stop band attenuation). >> This way you create some tolerance margin for magnitude >> errors caused by coefficient quantization, >> thus still meeting your original spec. > > > In mechanical engineering, that would be called a margin of safety > (factor of safety - 1). > > JerryAs a rule of thumb, the stop band attenuation improves by about 5dB for each additional bit in the coefficients.