hello all, I am currently working with FIR filter.Here i get the coefficients as deciamal values like -0.000467744403 0.000802870932 -0.000000000000 -0.001041888331 0.000768540238 0.000930750510 -0.001834127637 0.000000000000 0.002708566451....... i have to perform the filtering with 15 bit input line and 16 bit output line. can anyone suggest me how to store these coefficients in memory as binary and convert them back. i am currently using an approach of multiplying it with 1024 and storing the binary equivalent in memory and then after provcessing perform 10 times left shift,but its not so accurate ,kindly help me out thanks and regards jack

# FIR coefficients

Started by ●November 24, 2003

Reply by ●November 24, 20032003-11-24

Hello Jack, Did you look at "Scaling to prevent overflow (Fixed Point)" (Heureka, 19.11) ? In the ansers you find two files fp & fir that may help you. Good luck, Wolfgang "jack kilby" <jackilby@yahoo.com> schrieb im Newsbeitrag news:18668c6c.0311240052.4631e377@posting.google.com...> hello all, > I am currently working with FIR filter.Here i get the coefficients as > deciamal values like > -0.000467744403 > 0.000802870932 > -0.000000000000 > -0.001041888331 > 0.000768540238 > 0.000930750510 > -0.001834127637 > 0.000000000000 > 0.002708566451....... > i have to perform the filtering with 15 bit input line and 16 bit > output line. > can anyone suggest me how to store these coefficients in memory as > binary and convert them back. > i am currently using an approach of multiplying it with 1024 and > storing the binary equivalent in memory and then after provcessing > perform 10 times left shift,but its not so accurate ,kindly help me > out > thanks and regards > jack

Reply by ●November 24, 20032003-11-24

Hello Jack, Did you look at "Scaling to prevent overflow (Fixed Point)" (Heureka, 19.11) ? In the ansers you find two files fp & fir that may help you. Good luck, Wolfgang "jack kilby" <jackilby@yahoo.com> schrieb im Newsbeitrag news:18668c6c.0311240052.4631e377@posting.google.com...> hello all, > I am currently working with FIR filter.Here i get the coefficients as > deciamal values like > -0.000467744403 > 0.000802870932 > -0.000000000000 > -0.001041888331 > 0.000768540238 > 0.000930750510 > -0.001834127637 > 0.000000000000 > 0.002708566451....... > i have to perform the filtering with 15 bit input line and 16 bit > output line. > can anyone suggest me how to store these coefficients in memory as > binary and convert them back. > i am currently using an approach of multiplying it with 1024 and > storing the binary equivalent in memory and then after provcessing > perform 10 times left shift,but its not so accurate ,kindly help me > out > thanks and regards > jack

Reply by ●November 25, 20032003-11-25

Hi, u can to use scaling 2**15: to memory Ks[j]=(short)(Kfloat*0x8000); to calculate y+=(...*Ks[j])>>15; Cheers

Reply by ●November 25, 20032003-11-25

Vic wrote:> Hi, > u can to use scaling 2**15: > to memory Ks[j]=(short)(Kfloat*0x8000); > to calculate y+=(...*Ks[j])>>15; > > CheersFor these particular coefficients, Q15 isn't very appropriate. Even the largest coefficient would only be the integer value 89 - a very high coefficient quantization error. Try Q23, i.e., multiply all real coefficients by 2^23 to get the integer-valued coefficients. -- % Randy Yates % "...the answer lies within your soul %% Fuquay-Varina, NC % 'cause no one knows which side %%% 919-577-9882 % the coin will fall." %%%% <yates@ieee.org> % 'Big Wheels', *Out of the Blue*, ELO http://home.earthlink.net/~yatescr

Reply by ●November 25, 20032003-11-25

Randy Yates wrote:> For these particular coefficients, Q15 isn't > very appropriate. Even the largest coefficient > would only be the integer value 89 - a very > high coefficient quantization error. > > Try Q23, i.e., multiply all real coefficients by > 2^23 to get the integer-valued coefficients.Randy, I'm not sure the OP listed all the coefficients. In the original post, the list of coefs was followed by something akin to an ellipsis: > -0.000467744403 > 0.000802870932 > -0.000000000000 > -0.001041888331 > 0.000768540238 > 0.000930750510 > -0.001834127637 > 0.000000000000 > 0.002708566451....... Those coefs struck me as oddly small too, which is what led me to look for symmetry - instead of symmetry, I saw the dots. Presumably, he has more coefs, and they get larger. -- Jim Thomas Principal Applications Engineer Bittware, Inc jthomas@bittware.com http://www.bittware.com (703) 779-7770 To mess up a Linux box, you need to work at it; to mess up your Windows box, you just need to work on it. - Scott Granneman

Reply by ●November 25, 20032003-11-25

Jim Thomas <jthomas@bittware.com> wrote in message news:<vs6spdidhdhnef@corp.supernews.com>...> Randy Yates wrote: > > For these particular coefficients, Q15 isn't > > very appropriate. Even the largest coefficient > > would only be the integer value 89 - a very > > high coefficient quantization error. > > > > Try Q23, i.e., multiply all real coefficients by > > 2^23 to get the integer-valued coefficients. > > Randy, > > I'm not sure the OP listed all the coefficients. In the original post, > the list of coefs was followed by something akin to an ellipsis: > > > -0.000467744403 > > 0.000802870932 > > -0.000000000000 > > -0.001041888331 > > 0.000768540238 > > 0.000930750510 > > -0.001834127637 > > 0.000000000000 > > 0.002708566451....... > > Those coefs struck me as oddly small too, which is what led me to look > for symmetry - instead of symmetry, I saw the dots. Presumably, he has > more coefs, and they get larger.Hey Jim, Good point - I hadn't noticed the dots or the "values like" phrase. Hey Jack, can you give us all your coefficients? Actually, we need to know your machine architecture (especially the accumulator length) as well if you want to avoid overflow while accumulating. Or, better yet, read my paper on the subject and you can learn how to do it yourself. http://home.earthlink.net/~yatescr/fir.pdf --Randy

Reply by ●November 26, 20032003-11-26

Hello all, Thanks for all of your responses.Kindly look in to the coeefficients and help me cross the river.a of now i work like this datain = 15 bits 1 input to multiplier (from the data)= 15 bits 2 input to multiplier (from coeff) = 10 bits (i multiply by 2 power 10) output of multiplier = 25 bits input to accumulato =25 bits i finally take the last 16 bits out.... input ----> multiplier ----> accumulator ----- > output -5.190235e-004 7.013896e-004 4.266952e-004 -1.029301e-003 -2.968241e-004 1.574129e-003 -2.264815e-005 -2.327546e-003 7.114860e-004 3.198614e-003 -1.948620e-003 -4.004581e-003 3.880218e-003 4.471644e-003 -6.589314e-003 -4.243290e-003 1.007195e-002 2.889538e-003 -1.422408e-002 9.683918e-005 1.884194e-002 -5.346749e-003 -2.363674e-002 1.377756e-002 2.826236e-002 -2.710135e-002 -3.235257e-002 4.962334e-002 3.556310e-002 -9.729160e-002 -3.761264e-002 3.153014e-001 5.383093e-001 3.153014e-001 -3.761264e-002 -9.729160e-002 3.556310e-002 4.962334e-002 -3.235257e-002 -2.710135e-002 2.826236e-002 1.377756e-002 -2.363674e-002 -5.346749e-003 1.884194e-002 9.683918e-005 -1.422408e-002 2.889538e-003 1.007195e-002 -4.243290e-003 -6.589314e-003 4.471644e-003 3.880218e-003 -4.004581e-003 -1.948620e-003 3.198614e-003 7.114860e-004 -2.327546e-003 -2.264815e-005 1.574129e-003 -2.968241e-004 -1.029301e-003 4.266952e-004 7.013896e-004 -5.190235e-004 thanks jack yates@ieee.org (Randy Yates) wrote in message news:<567ce618.0311251717.5c70ec0b@posting.google.com>...> Jim Thomas <jthomas@bittware.com> wrote in message news:<vs6spdidhdhnef@corp.supernews.com>... > > Randy Yates wrote: > > > For these particular coefficients, Q15 isn't > > > very appropriate. Even the largest coefficient > > > would only be the integer value 89 - a very > > > high coefficient quantization error. > > > > > > Try Q23, i.e., multiply all real coefficients by > > > 2^23 to get the integer-valued coefficients. > > > > Randy, > > > > I'm not sure the OP listed all the coefficients. In the original post, > > the list of coefs was followed by something akin to an ellipsis: > > > > > -0.000467744403 > > > 0.000802870932 > > > -0.000000000000 > > > -0.001041888331 > > > 0.000768540238 > > > 0.000930750510 > > > -0.001834127637 > > > 0.000000000000 > > > 0.002708566451....... > > > > Those coefs struck me as oddly small too, which is what led me to look > > for symmetry - instead of symmetry, I saw the dots. Presumably, he has > > more coefs, and they get larger. > > Hey Jim, > > Good point - I hadn't noticed the dots or the "values like" phrase. > > Hey Jack, can you give us all your coefficients? > > Actually, we need to know your machine architecture (especially > the accumulator length) as well if you want to avoid overflow > while accumulating. Or, better yet, read my paper on the subject > and you can learn how to do it yourself. > > http://home.earthlink.net/~yatescr/fir.pdf > > --Randy

Reply by ●November 26, 20032003-11-26

jack kilby wrote:> Hello all, > Thanks for all of your responses.Kindly look in to the coeefficients > and help me cross the river.a of now i work like this > datain = 15 bits > 1 input to multiplier (from the data)= 15 bits > 2 input to multiplier (from coeff) = 10 bits (i multiply by 2 power > 10) > output of multiplier = 25 bits > input to accumulato =25 bits > i finally take the last 16 bits out....Hi Jack, If the coefficients are only 10 bits long, then multiplying the real coefficients below by 1024 (2^10) will overflow the largest one: round(0.538 * 1024) = 551. The largest value you can represent with a signed, two's complement 10-bit number is 511. Perhaps this is your problem? --Randy> > > > input ----> multiplier ----> accumulator ----- > output > > -5.190235e-004 > 7.013896e-004 > 4.266952e-004 > -1.029301e-003 > -2.968241e-004 > 1.574129e-003 > -2.264815e-005 > -2.327546e-003 > 7.114860e-004 > 3.198614e-003 > -1.948620e-003 > -4.004581e-003 > 3.880218e-003 > 4.471644e-003 > -6.589314e-003 > -4.243290e-003 > 1.007195e-002 > 2.889538e-003 > -1.422408e-002 > 9.683918e-005 > 1.884194e-002 > -5.346749e-003 > -2.363674e-002 > 1.377756e-002 > 2.826236e-002 > -2.710135e-002 > -3.235257e-002 > 4.962334e-002 > 3.556310e-002 > -9.729160e-002 > -3.761264e-002 > 3.153014e-001 > 5.383093e-001 > 3.153014e-001 > -3.761264e-002 > -9.729160e-002 > 3.556310e-002 > 4.962334e-002 > -3.235257e-002 > -2.710135e-002 > 2.826236e-002 > 1.377756e-002 > -2.363674e-002 > -5.346749e-003 > 1.884194e-002 > 9.683918e-005 > -1.422408e-002 > 2.889538e-003 > 1.007195e-002 > -4.243290e-003 > -6.589314e-003 > 4.471644e-003 > 3.880218e-003 > -4.004581e-003 > -1.948620e-003 > 3.198614e-003 > 7.114860e-004 > -2.327546e-003 > -2.264815e-005 > 1.574129e-003 > -2.968241e-004 > -1.029301e-003 > 4.266952e-004 > 7.013896e-004 > -5.190235e-004 > > > thanks > jack > > > yates@ieee.org (Randy Yates) wrote in message news:<567ce618.0311251717.5c70ec0b@posting.google.com>... > >>Jim Thomas <jthomas@bittware.com> wrote in message news:<vs6spdidhdhnef@corp.supernews.com>... >> >>>Randy Yates wrote: >>> >>>>For these particular coefficients, Q15 isn't >>>>very appropriate. Even the largest coefficient >>>>would only be the integer value 89 - a very >>>>high coefficient quantization error. >>>> >>>>Try Q23, i.e., multiply all real coefficients by >>>>2^23 to get the integer-valued coefficients. >>> >>>Randy, >>> >>>I'm not sure the OP listed all the coefficients. In the original post, >>>the list of coefs was followed by something akin to an ellipsis: >>> >>> > -0.000467744403 >>> > 0.000802870932 >>> > -0.000000000000 >>> > -0.001041888331 >>> > 0.000768540238 >>> > 0.000930750510 >>> > -0.001834127637 >>> > 0.000000000000 >>> > 0.002708566451....... >>> >>>Those coefs struck me as oddly small too, which is what led me to look >>>for symmetry - instead of symmetry, I saw the dots. Presumably, he has >>>more coefs, and they get larger. >> >>Hey Jim, >> >>Good point - I hadn't noticed the dots or the "values like" phrase. >> >>Hey Jack, can you give us all your coefficients? >> >>Actually, we need to know your machine architecture (especially >>the accumulator length) as well if you want to avoid overflow >>while accumulating. Or, better yet, read my paper on the subject >>and you can learn how to do it yourself. >> >>http://home.earthlink.net/~yatescr/fir.pdf >> >>--Randy-- % Randy Yates % "...the answer lies within your soul %% Fuquay-Varina, NC % 'cause no one knows which side %%% 919-577-9882 % the coin will fall." %%%% <yates@ieee.org> % 'Big Wheels', *Out of the Blue*, ELO http://home.earthlink.net/~yatescr

Reply by ●November 27, 20032003-11-27

"Randy Yates" <yates@ieee.org> wrote in message news:THcxb.23273$Wy4.2940@newsread2.news.atl.earthlink.net...> jack kilby wrote: > > Hello all, > > Thanks for all of your responses.Kindly look in to the coeefficients > > and help me cross the river.a of now i work like this > > datain = 15 bits > > 1 input to multiplier (from the data)= 15 bits > > 2 input to multiplier (from coeff) = 10 bits (i multiply by 2 power > > 10) > > output of multiplier = 25 bits > > input to accumulato =25 bits > > i finally take the last 16 bits out.... > > Hi Jack, > > If the coefficients are only 10 bits long, then multiplying the > real coefficients below by 1024 (2^10) will overflow the largest > one: > > round(0.538 * 1024) = 551. > > The largest value you can represent with a signed, two's complement > 10-bit number is 511. > > Perhaps this is your problem?So, scale the coefficients by 511/0.538 = 949.8141264 or some other similar number that might minimize the error in the coefficients or to directly minimize the error in the filter response. Fred