Forums

Down sampling / Halfband filters on DSP

Started by tom00 September 24, 2009
Hello!


I need to implement a low pass filter with a flexible cut-off frequency of
10-50Hz for signals sampled at 40kHz. I believe that for this approach a
multirate and multistage filter is the best choose. So first the signal is
down-sampled by a factor of approximately 100, then the signal is filtered
with an IIR filter and finally the signal is up-sampling (may up-sampling
is not required). For the down sapling I have two structures in mind: 

Structure 1:
7 stages with down sampling factor of 2
7 FIR half-band filters with 3 to 15 coefficients 

Structure 2:
2 stages with down sampling factor of 10
2 FIR half-band filters with ~50 coefficients 

If I count the number of multiplications the structure 1 is much better,
but in my DSP program the structure 2 is two times faster that structure 1.
I believe that my non-optimized implementation of the half-band-filter is
partly responsible for the worse performance of structure 1. An other
reason is that structure 1 has more memory access.  

Therefore my general question: 
* Is it useful to use half-band filter on the DSP for down sampling?
   How can I use the fact that almost ever second sample is zero?
* Are there down-sampling structures which also reduce the memory access?
* Does anyone has example code?

Thanks for your answers!

Thomas




tom00 wrote:

> Hello! > > > I need to implement a low pass filter with a flexible cut-off frequency of > 10-50Hz for signals sampled at 40kHz. I believe that for this approach a > multirate and multistage filter is the best choose.
Well, you don't have to. A direct filtering with 32-bit IIR with the noise shaping will probably do the job, and it could be more economical as well.
> So first the signal is > down-sampled by a factor of approximately 100, then the signal is filtered > with an IIR filter and finally the signal is up-sampling (may up-sampling > is not required).
That makes sense.
> For the down sapling I have two structures in mind: > > Structure 1: > 7 stages with down sampling factor of 2 > 7 FIR half-band filters with 3 to 15 coefficients > > Structure 2: > 2 stages with down sampling factor of 10 > 2 FIR half-band filters with ~50 coefficients > > If I count the number of multiplications the structure 1 is much better, > but in my DSP program the structure 2 is two times faster that structure 1.
Of course. The #2 has less of the overhead if implemented on the programmable DSP as it has less stages.
> I believe that my non-optimized implementation of the half-band-filter is > partly responsible for the worse performance of structure 1. An other > reason is that structure 1 has more memory access. > > Therefore my general question: > * Is it useful to use half-band filter on the DSP for down sampling?
It depends.
> How can I use the fact that almost ever second sample is zero?
RTFM
> * Are there down-sampling structures which also reduce the memory access?
It depends.
> * Does anyone has example code?
I do. For money. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
On Thu, 24 Sep 2009 08:56:57 -0500
"tom00" <ThomasB@sms.at> wrote:

> Hello! > > > I need to implement a low pass filter with a flexible cut-off > frequency of 10-50Hz for signals sampled at 40kHz. I believe that for > this approach a multirate and multistage filter is the best choose. > So first the signal is down-sampled by a factor of approximately 100, > then the signal is filtered with an IIR filter and finally the signal > is up-sampling (may up-sampling is not required). For the down > sapling I have two structures in mind: > > Structure 1: > 7 stages with down sampling factor of 2 > 7 FIR half-band filters with 3 to 15 coefficients > > Structure 2: > 2 stages with down sampling factor of 10 > 2 FIR half-band filters with ~50 coefficients > > If I count the number of multiplications the structure 1 is much > better, but in my DSP program the structure 2 is two times faster > that structure 1. I believe that my non-optimized implementation of > the half-band-filter is partly responsible for the worse performance > of structure 1. An other reason is that structure 1 has more memory > access. > > Therefore my general question: > * Is it useful to use half-band filter on the DSP for down sampling? > How can I use the fact that almost ever second sample is zero? > * Are there down-sampling structures which also reduce the memory > access? > * Does anyone has example code? > > Thanks for your answers! > > Thomas > > >
I'll make you the same recommendation Vladmir made to me about a month ago on a similair question. Crochiere and Rabiner. Multirate Digital Signal Processing. Englewood Cliffs, NJ: Prentice-Hall, 1983. Buy a copy, take a day or so to really read it. It's dense thick going, and uses older (and less precise) notation for digital signals, but it's fantastically well written and will answer all your questions. -- Rob Gaddi, Highland Technology Email address is currently out of order
On Sep 24, 12:09&#2013266080;pm, Rob Gaddi <rga...@technologyhighland.com> wrote:
> On Thu, 24 Sep 2009 08:56:57 -0500 > > > > > > "tom00" <Thom...@sms.at> wrote: > > Hello! > > > I need to implement a low pass filter with a flexible cut-off > > frequency of 10-50Hz for signals sampled at 40kHz. I believe that for > > this approach a multirate and multistage filter is the best choose. > > So first the signal is down-sampled by a factor of approximately 100, > > then the signal is filtered with an IIR filter and finally the signal > > is up-sampling (may up-sampling is not required). For the down > > sapling I have two structures in mind: > > > Structure 1: > > 7 stages with down sampling factor of 2 > > 7 FIR half-band filters with 3 to 15 coefficients > > > Structure 2: > > 2 stages with down sampling factor of 10 > > 2 FIR half-band filters with ~50 coefficients > > > If I count the number of multiplications the structure 1 is much > > better, but in my DSP program the structure 2 is two times faster > > that structure 1. I believe that my non-optimized implementation of > > the half-band-filter is partly responsible for the worse performance > > of structure 1. An other reason is that structure 1 has more memory > > access. &#2013266080; > > > Therefore my general question: > > * Is it useful to use half-band filter on the DSP for down sampling? > > &#2013266080; &#2013266080;How can I use the fact that almost ever second sample is zero? > > * Are there down-sampling structures which also reduce the memory > > access? > > * Does anyone has example code? > > > Thanks for your answers! > > > Thomas > > I'll make you the same recommendation Vladmir made to me about a month > ago on a similair question. &#2013266080;Crochiere and Rabiner. Multirate Digital > Signal Processing. Englewood Cliffs, NJ: Prentice-Hall, 1983. &#2013266080;Buy a > copy, take a day or so to really read it. &#2013266080;It's dense thick going, and > uses older (and less precise) notation for digital signals, but it's > fantastically well written and will answer all your questions. > > -- > Rob Gaddi, Highland Technology > Email address is currently out of order- Hide quoted text - > > - Show quoted text -
There is an IEEE paper (ASSP Journal or the Proccedings if I remember correctly) on the same topic by the same authors that is much more condensed and probably much more useful to the OP. As Vlad noted the 2nd implementation has less overhead, but the 1st implementation will have conserderably less calculations. But, if in the 2nd implementation, you decimate a halfband filter output by 10 it will alias into your passband (not good), half-band filters are for decimating by 2. Do not forget that after correctly downsampling with halfband filters the signal spectrum is generally heavily aliased. The lowest rate filter should both remove this aliasing and be used to set the final signal bandwidth. Finally, looking at your signal bandwidth and allowing for an alias free transition band in the lowest rate filter, you could use many more than 7 stages of decimate by 2 halfband filters to reduce the computations. Dirk A. Bell DSP Consultant
On Sep 24, 12:09&#2013266080;pm, Rob Gaddi <rga...@technologyhighland.com> wrote:
> On Thu, 24 Sep 2009 08:56:57 -0500 > > > > > > "tom00" <Thom...@sms.at> wrote: > > Hello! > > > I need to implement a low pass filter with a flexible cut-off > > frequency of 10-50Hz for signals sampled at 40kHz. I believe that for > > this approach a multirate and multistage filter is the best choose. > > So first the signal is down-sampled by a factor of approximately 100, > > then the signal is filtered with an IIR filter and finally the signal > > is up-sampling (may up-sampling is not required). For the down > > sapling I have two structures in mind: > > > Structure 1: > > 7 stages with down sampling factor of 2 > > 7 FIR half-band filters with 3 to 15 coefficients > > > Structure 2: > > 2 stages with down sampling factor of 10 > > 2 FIR half-band filters with ~50 coefficients > > > If I count the number of multiplications the structure 1 is much > > better, but in my DSP program the structure 2 is two times faster > > that structure 1. I believe that my non-optimized implementation of > > the half-band-filter is partly responsible for the worse performance > > of structure 1. An other reason is that structure 1 has more memory > > access. &#2013266080; > > > Therefore my general question: > > * Is it useful to use half-band filter on the DSP for down sampling? > > &#2013266080; &#2013266080;How can I use the fact that almost ever second sample is zero? > > * Are there down-sampling structures which also reduce the memory > > access? > > * Does anyone has example code? > > > Thanks for your answers! > > > Thomas > > I'll make you the same recommendation Vladmir made to me about a month > ago on a similair question. &#2013266080;Crochiere and Rabiner. Multirate Digital > Signal Processing. Englewood Cliffs, NJ: Prentice-Hall, 1983. &#2013266080;Buy a > copy, take a day or so to really read it. &#2013266080;It's dense thick going, and > uses older (and less precise) notation for digital signals, but it's > fantastically well written and will answer all your questions. > > -- > Rob Gaddi, Highland Technology > Email address is currently out of order- Hide quoted text - > > - Show quoted text -
There is an IEEE paper (ASSP Journal or the Proceedings if I remember correctly) on the same topic by the same authors that is much more condensed and probably much more useful to the OP. As Vlad noted the 2nd implementation has less overhead, but the 1st implementation will have considerably less calculations. But, if in the 2nd implementation, you decimate a halfband filter output by 10 it will alias into your passband (not good), halfband filters are for decimating by 2. Do not forget that after correctly downsampling with halfband filters the signal spectrum is generally heavily aliased. The lowest rate filter should both remove this aliasing and be used to set the final signal bandwidth. The passband and the transition band of the lowest rate filter should fall in the part of the spectrum that has been preserved without aliasing. If you wanted to, for lower bandwidths you could include 1-2 more stages of halfband filters, but you should calculate the computational gain, and consider whether having more than one filtering architecture is worthwhile. Dirk A. Bell DSP Consultant
Dirk Bell wrote:

> There is an IEEE paper (ASSP Journal or the Proceedings if I > remember correctly) on the same topic by the same authors that > is much more condensed and probably much more useful to the OP. >
From an old post of Rick Lyons': [11] Crochiere, R. and Rabiner, L. "Decimation and Interpolation of Digital Signals-A Tutorial Review," Proceedings of the IEEE, Vol. 69, No. 3, March 1981. [12] Crochiere, R. and Rabiner, L. "Further Considerations in the Design of Decimators and Interpolators," IEEE Trans. on Acoust. Speech, and Signal Proc., Vol. ASSP?24, No. 4, August 1976. Martin -- Quidquid latine scriptum est, altum videtur.