DSPRelated.com
Forums

HELP! IIR High Pass filter

Started by L Hao July 24, 2003
Hi, I am trying to implement an IIR High pass filter to filter out a DC
component introduced from a ADC convter we are using.

I set the passband frq 200Hz, stopband freq 50Hz, Rp 0.2, and Rs -30dB.
Using Matlab, I got the following coefficients for using 2 2nd order biquid
filter.

B0           B1              B2             A0          A1              A2
0.8354    -1.6689     0.8354      1             -1.7319      0.7631
1              -1.9839     1                1             -1.9401
0.9609


After quantizing the coefficients, I implemented in the code using TI C5409
Fixed Point DSP. However, it doesn't seem to work. And for the coefficients
that are larger than 1, I divide them by 2 and add them back togather later.

Does anyone see anything wrong with the design? It seems to be pretty
straightforward.

Thanks.


"L Hao" <hao_li@yahoo.com> wrote in message
news:Cc%Ta.238$hn1.67256@news.uswest.net...
> Hi, I am trying to implement an IIR High pass filter to filter out a DC > component introduced from a ADC convter we are using. > > I set the passband frq 200Hz, stopband freq 50Hz, Rp 0.2, and Rs -30dB. > Using Matlab, I got the following coefficients for using 2 2nd order
biquid
> filter. > > B0 B1 B2 A0 A1 A2 > 0.8354 -1.6689 0.8354 1 -1.7319 0.7631 > 1 -1.9839 1 1 -1.9401 > 0.9609 > > > After quantizing the coefficients, I implemented in the code using TI
C5409
> Fixed Point DSP. However, it doesn't seem to work. And for the
coefficients
> that are larger than 1, I divide them by 2 and add them back togather
later.
> > Does anyone see anything wrong with the design? It seems to be pretty > straightforward.
Does this design work in matlab? If you tried using this filter on a test signal in matlab and the results don't show sufficient filtering, then it's your filter design. If the matlab simulation makes sense, then check your implementation in the fixed point DSP.
> > Thanks. > >
L Hao wrote:
>
...
> > B0 B1 B2 A0 A1 A2 > 0.8354 -1.6689 0.8354 1 -1.7319 0.7631 > 1 -1.9839 1 1 -1.9401 > 0.9609 >
... Please use a fixed-width font. Avoid tabs; use spaces instead. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
Thanks for the response.

The Matlab simulation looks good. THe problem seems to be the overflow of
fixed point calculation.

Any suggestions? Thanks.


"Bhaskar Thiagarajan" <bhaskart@deja.com> wrote in message
news:bfrki0$htlup$1@ID-82263.news.uni-berlin.de...
> "L Hao" <hao_li@yahoo.com> wrote in message > news:Cc%Ta.238$hn1.67256@news.uswest.net... > > Hi, I am trying to implement an IIR High pass filter to filter out a DC > > component introduced from a ADC convter we are using. > > > > I set the passband frq 200Hz, stopband freq 50Hz, Rp 0.2, and Rs -30dB. > > Using Matlab, I got the following coefficients for using 2 2nd order > biquid > > filter. > > > > B0 B1 B2 A0 A1
A2
> > 0.8354 -1.6689 0.8354 1 -1.7319 0.7631 > > 1 -1.9839 1 1 -1.9401 > > 0.9609 > > > > > > After quantizing the coefficients, I implemented in the code using TI > C5409 > > Fixed Point DSP. However, it doesn't seem to work. And for the > coefficients > > that are larger than 1, I divide them by 2 and add them back togather > later. > > > > Does anyone see anything wrong with the design? It seems to be pretty > > straightforward. > > Does this design work in matlab? If you tried using this filter on a test > signal in matlab and the results don't show sufficient filtering, then
it's
> your filter design. If the matlab simulation makes sense, then check your > implementation in the fixed point DSP. > > > > > Thanks. > > > > > >
I have seen this problem in ADC's due to the differential gain difference in
integrated ADC drivers such as the AD8138. A simple alternative to
implementing
a high pass filter is to simply calculate the mean value of the noise and
then
store this value as a constant and subtract it from each sample. This could
be done
once (may change a bit over temperature/time) or periodically with
terminated
input, or sinusoid.

Kurt Vetter


"L Hao" <hao_li@yahoo.com> wrote in message
news:Cc%Ta.238$hn1.67256@news.uswest.net...
> Hi, I am trying to implement an IIR High pass filter to filter out a DC > component introduced from a ADC convter we are using. > > I set the passband frq 200Hz, stopband freq 50Hz, Rp 0.2, and Rs -30dB. > Using Matlab, I got the following coefficients for using 2 2nd order
biquid
> filter. > > B0 B1 B2 A0 A1 A2 > 0.8354 -1.6689 0.8354 1 -1.7319 0.7631 > 1 -1.9839 1 1 -1.9401 > 0.9609 > > > After quantizing the coefficients, I implemented in the code using TI
C5409
> Fixed Point DSP. However, it doesn't seem to work. And for the
coefficients
> that are larger than 1, I divide them by 2 and add them back togather
later.
> > Does anyone see anything wrong with the design? It seems to be pretty > straightforward. > > Thanks. > >
Kurt Vetter wrote:
> > I have seen this problem in ADC's due to the differential gain difference in > integrated ADC drivers such as the AD8138. A simple alternative to > implementing > a high pass filter is to simply calculate the mean value of the noise and > then > store this value as a constant and subtract it from each sample. This could > be done > once (may change a bit over temperature/time) or periodically with > terminated > input, or sinusoid. > > Kurt Vetter >
Most noise sources are zero mean or can be made to be zero mean. The difficulty lies in the excursions. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
I have tried a similar approch i.e. calculating the average value of
incoming samples and substract the average from each sample. It does not
work well. I also tried to save all the incoming data and calculated the
average by hand, then substract the value from each sample at realtime. This
one works better than the previous one, however it still doesn't work
completely. The vendor also told me that the DC offset could change from
chip to chip, which led to think of a high pass filter.

The current high pass filter I am working on is a 4th order elliptic IIR in
direct form II using TI fixed point C5409. I am a newbie on the fixed point
DSP. It seems that I need to do coefficient scaling properly to avoid
overflow. I am sure there have been a lot discussion on this one already,
please don't mind for me to bring it up again. Any suggestion is
appreciated!

Thanks.


"Kurt Vetter" <vetterk@optonline.net> wrote in message
news:f1kUa.147874$ye5.25902154@news4.srv.hcvlny.cv.net...
> I have seen this problem in ADC's due to the differential gain difference
in
> integrated ADC drivers such as the AD8138. A simple alternative to > implementing > a high pass filter is to simply calculate the mean value of the noise and > then > store this value as a constant and subtract it from each sample. This
could
> be done > once (may change a bit over temperature/time) or periodically with > terminated > input, or sinusoid. > > Kurt Vetter > > > "L Hao" <hao_li@yahoo.com> wrote in message > news:Cc%Ta.238$hn1.67256@news.uswest.net... > > Hi, I am trying to implement an IIR High pass filter to filter out a DC > > component introduced from a ADC convter we are using. > > > > I set the passband frq 200Hz, stopband freq 50Hz, Rp 0.2, and Rs -30dB. > > Using Matlab, I got the following coefficients for using 2 2nd order > biquid > > filter. > > > > B0 B1 B2 A0 A1
A2
> > 0.8354 -1.6689 0.8354 1 -1.7319 0.7631 > > 1 -1.9839 1 1 -1.9401 > > 0.9609 > > > > > > After quantizing the coefficients, I implemented in the code using TI > C5409 > > Fixed Point DSP. However, it doesn't seem to work. And for the > coefficients > > that are larger than 1, I divide them by 2 and add them back togather > later. > > > > Does anyone see anything wrong with the design? It seems to be pretty > > straightforward. > > > > Thanks. > > > > > >
"L Hao" <hao_li@yahoo.com> wrote in message
news:IvjUa.1477$vX1.58836@news.uswest.net...
> Thanks for the response. > > The Matlab simulation looks good. THe problem seems to be the overflow of > fixed point calculation. > > Any suggestions? Thanks. > > > "Bhaskar Thiagarajan" <bhaskart@deja.com> wrote in message > news:bfrki0$htlup$1@ID-82263.news.uni-berlin.de... > > "L Hao" <hao_li@yahoo.com> wrote in message > > news:Cc%Ta.238$hn1.67256@news.uswest.net... > > > Hi, I am trying to implement an IIR High pass filter to filter out a
DC
> > > component introduced from a ADC convter we are using. > > > > > > I set the passband frq 200Hz, stopband freq 50Hz, Rp 0.2, and
Rs -30dB.
> > > Using Matlab, I got the following coefficients for using 2 2nd order > > biquid > > > filter. > > > > > > B0 B1 B2 A0 A1 > A2 > > > 0.8354 -1.6689 0.8354 1 -1.7319 0.7631 > > > 1 -1.9839 1 1 -1.9401 > > > 0.9609 > > > > > > > > > After quantizing the coefficients, I implemented in the code using TI > > C5409 > > > Fixed Point DSP. However, it doesn't seem to work. And for the > > coefficients > > > that are larger than 1, I divide them by 2 and add them back togather > > later. > > > > > > Does anyone see anything wrong with the design? It seems to be pretty > > > straightforward. > > > > Does this design work in matlab? If you tried using this filter on a
test
> > signal in matlab and the results don't show sufficient filtering, then > it's > > your filter design. If the matlab simulation makes sense, then check
your
> > implementation in the fixed point DSP. > > > > > > > > Thanks. > > > > > > > >
Try implement fixed-point in Matlab using int(), floor(), ceil() type functions. You probably need not get bit-exact, but certainly get rid of the floating point. You can then analyse where the DSP is overflowing/saturating.
"L Hao" <hao_li@yahoo.com> wrote:

>Hi, I am trying to implement an IIR High pass filter to filter out a DC >component introduced from a ADC convter we are using. > >I set the passband frq 200Hz, stopband freq 50Hz, Rp 0.2, and Rs -30dB. >Using Matlab, I got the following coefficients for using 2 2nd order biquid >filter. > >B0 B1 B2 A0 A1 A2 >0.8354 -1.6689 0.8354 1 -1.7319 0.7631 >1 -1.9839 1 1 -1.9401 >0.9609 > > >After quantizing the coefficients, I implemented in the code using TI C5409 >Fixed Point DSP. However, it doesn't seem to work. And for the coefficients >that are larger than 1, I divide them by 2 and add them back togather later.
you're comment about adding back together is unclear, and maybe wrong. 1) divide all coefficients by two 2) perform the filter multiplication 3) shift result left by 1, to get dividing factor back Robert www.gldsp.com ( modify address for return email ) www.numbersusa.com www.americanpatrol.com
"Bhaskar Thiagarajan" <bhaskart@deja.com> wrote:

>"L Hao" <hao_li@yahoo.com> wrote in message >news:Cc%Ta.238$hn1.67256@news.uswest.net... >Does this design work in matlab? If you tried using this filter on a test >signal in matlab and the results don't show sufficient filtering, then it's >your filter design. If the matlab simulation makes sense, then check your >implementation in the fixed point DSP.
I have found that implementing the filter in C code can help a lot as well. I would highly recommend this. Most of the time, I will implement the filter in floating point, and then compare the results step by step with the DSP results. There will be differences, because of the precision differences, but they should not be too large, with the 32/40 bit accumulator ... and the data trends should be the same. Regards, Robert www.gldsp.com ( modify address for return email ) www.numbersusa.com www.americanpatrol.com