Hi, I had designed a digital IIR filter from the existing analog prototype. The filter coefficients were obtained using MATLAB. The DSP which is used here is the TMS320F2812 processor. The problem is scaling of filter coefficients.The input data length to the filter is 12 bits. I had scaled the filter coeffiecients to 9 bits. But then with these available datalengths,its difficult to predict the no. of output bits as the filter is recursive. Two filters have been implemented. One is a second order filter amd the other one is a fourth order filter. I know that these quantization errors are non linear and its very difficult to predict the error. But whats the work around? Shd I use trial and error method to find out the exact scaling for my filter coefficients or any other better way exists? Any help in this regards would be greatly appreciated. Regards, Kalyani

# Classical IIR filter problem

Started by ●April 15, 2004

Posted by ●April 15, 2004

kalki wrote:> Hi, >=20 > I had designed a digital IIR filter from the existing analog > prototype. The filter coefficients were obtained using MATLAB. The DSP > which is used here is the TMS320F2812 processor. The problem is > scaling of filter coefficients.The input data length to the filter is > 12 bits. I had scaled the filter coeffiecients to 9 bits. But then > with these available datalengths,its difficult to predict the no. of > output bits as the filter is recursive. Two filters have been > implemented. One is a second order filter amd the other one is a > fourth order filter. I know that these quantization errors are non > linear and its very difficult to predict the error. But whats the work > around? Shd I use trial and error method to find out the exact scaling > for my filter coefficients or any other better way exists? Any help in > this regards would be greatly appreciated. >=20 > Regards, > KalyaniThe TMS320F2812 supports 32 bit MAC so 1. use the full width of the available words, 32 bit, (but 16 bit=20 coefficients should do for 12 bit data) 2. split your filter in second order sections (may be done in Matlab) Ren=E9

Posted by ●April 15, 2004

Ren� wrote:> kalki wrote: > >> Hi, >> >> I had designed a digital IIR filter from the existing analog >> prototype. The filter coefficients were obtained using MATLAB. The DSP >> which is used here is the TMS320F2812 processor. The problem is >> scaling of filter coefficients.The input data length to the filter is >> 12 bits. I had scaled the filter coeffiecients to 9 bits. But then >> with these available datalengths,its difficult to predict the no. of >> output bits as the filter is recursive. Two filters have been >> implemented. One is a second order filter amd the other one is a >> fourth order filter. I know that these quantization errors are non >> linear and its very difficult to predict the error. But whats the work >> around? Shd I use trial and error method to find out the exact scaling >> for my filter coefficients or any other better way exists? Any help in >> this regards would be greatly appreciated. >> >> Regards, >> Kalyani > > > The TMS320F2812 supports 32 bit MAC so > > 1. use the full width of the available words, 32 bit, (but 16 bit > coefficients should do for 12 bit data) > > 2. split your filter in second order sections (may be done in Matlab) > > Ren� >There's two things you need to look at: One is the quantization noise from the on-going arithmetic, the other is the loss of precision of the filter weights as you increase the polynomial order. I estimate quantization noise in my IIR filters by finding the transfer function from each summation to the output, and assuming noise at 2x to 4x the lsb. If the output noise is too great I adjust things. This is why Ren� is suggesting 32-bit data (although on the '2812 you're forced into 32-bit coefficients when you use 32-bit data so you may as well go there). Both the coefficient precision and quantization noise go up as your filter poles approach z = 1. Basically you need enough precision to resolve the difference between your transfer function and (z - 1)^n. For example, a 2nd-order filter with poles at z = 0.99 needs to have enough precision to resolve the difference between 0.9801 and 0.9800, or (0.01)^2. With a 4th-order filter you'd need (0.01)^4. To make sure you should calculate your filter coefficients, round them, then check actual transfer function of the algorithm with the rounded coefficients. Here again using 32-bit coefficients relaxes your requirements for you. One final note: Pay attention to scaling. I run transfer function plots of all the state variables of my filters, looking for peaks above magnitude 1. Then I ask myself if I'm going to get enough excitation at that frequency to saturate my variables, and I think about scaling my inputs and outputs. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com

Posted by ●April 15, 2004

"Tim Wescott" <tim@wescottnospamdesign.com> wrote in message news:107td4f4ig31maa@corp.supernews.com...> Ren� wrote: > > kalki wrote: > > > >> Hi, > >> > >> I had designed a digital IIR filter from the existing analog > >> prototype. The filter coefficients were obtained using MATLAB. The DSP > >> which is used here is the TMS320F2812 processor. The problem is > >> scaling of filter coefficients.The input data length to the filter is > >> 12 bits. I had scaled the filter coeffiecients to 9 bits. But then > >> with these available datalengths,its difficult to predict the no. of > >> output bits as the filter is recursive. Two filters have been > >> implemented. One is a second order filter amd the other one is a > >> fourth order filter. I know that these quantization errors are non > >> linear and its very difficult to predict the error. But whats the work > >> around? Shd I use trial and error method to find out the exact scaling > >> for my filter coefficients or any other better way exists? Any help in > >> this regards would be greatly appreciated. > >> > >> Regards, > >> Kalyani > > One final note: Pay attention to scaling. I run transfer function > plots of all the state variables of my filters, looking for peaks above > magnitude 1. Then I ask myself if I'm going to get enough excitation at > that frequency to saturate my variables, and I think about scaling my > inputs and outputs.Good advice. Another option is to switch to a different filter topology that has better characteristics in terms of state variable magnitude, e.g. normalized lattice/ladder. Me, I am fortunate enough to be working primarily with 32- or 40-bit floating-point DSPs where this is much less of an issue!

Posted by ●April 15, 2004

Typically when doing IIR in fixed point environment you'll want to break it into second order stages (as suggested). When doing this there is a good chance that one of the coefs will be greater than 1.0 and typically the coefs are represented as 16 bit Q15 values whos represented range is +/-1. The work around for this normally involves dividing that coeficient in half and adding that coef*y() product twice to a 32 bit accumulator. Check TI's web site they've got any DSP support for 28x: http://dspvillage.ti.com/docs/catalog/devtools/dsptoolslist.jhtml?familyId=110&toolTypeId=44&toolTypeFlagId=1&ptemplateId=5121&pnavigationId=9110 -Shawn Steenhagen www.appliedsignalprocessing.com "kalki" <kalyanik@myw.ltindia.com> wrote in message news:a130dc51.0404150227.53fd1b7f@posting.google.com...> Hi, > > I had designed a digital IIR filter from the existing analog > prototype. The filter coefficients were obtained using MATLAB. The DSP > which is used here is the TMS320F2812 processor. The problem is > scaling of filter coefficients.The input data length to the filter is > 12 bits. I had scaled the filter coeffiecients to 9 bits. But then > with these available datalengths,its difficult to predict the no. of > output bits as the filter is recursive. Two filters have been > implemented. One is a second order filter amd the other one is a > fourth order filter. I know that these quantization errors are non > linear and its very difficult to predict the error. But whats the work > around? Shd I use trial and error method to find out the exact scaling > for my filter coefficients or any other better way exists? Any help in > this regards would be greatly appreciated. > > Regards, > Kalyani

Posted by ●April 16, 2004

Hi I know they don't have a student version (I'm presuming that you are a student), but if you can get your hands on ONEoverT, it will generate your floating point coefficients and their fixed point equivalents. You can specify the input and output number of bits and then see what the result will be like. It's a great program and doesn't come near the price of other overpriced counterparts. Bob kalyanik@myw.ltindia.com (kalki) wrote in message news:<a130dc51.0404150227.53fd1b7f@posting.google.com>...> Hi, > > I had designed a digital IIR filter from the existing analog > prototype. The filter coefficients were obtained using MATLAB. The DSP > which is used here is the TMS320F2812 processor. The problem is > scaling of filter coefficients.The input data length to the filter is > 12 bits. I had scaled the filter coeffiecients to 9 bits. But then > with these available datalengths,its difficult to predict the no. of > output bits as the filter is recursive. Two filters have been > implemented. One is a second order filter amd the other one is a > fourth order filter. I know that these quantization errors are non > linear and its very difficult to predict the error. But whats the work > around? Shd I use trial and error method to find out the exact scaling > for my filter coefficients or any other better way exists? Any help in > this regards would be greatly appreciated. > > Regards, > Kalyani