View Full Version : Smoothing Part II

Robert Newton
02-09-1993, 12:12 PM
Due to further responses to my call for help on digital filters which were
received after my last posting I include a Summary Part II. Thanks again to
all those who replied. I appreciate your help.

Robert Newton Internet: rnewton@loki.une.oz.au
Lecturer in Biomechanics ACSnet: rnewton@loki.une.oz
University of NewEngland,
Northern Rivers Phone: +61 (066) 203762
P.O. Box 157
Lismore NSW Australia
---------------------------- START ---------------------------------------
>From SM0429%SPRINGB.BITNET@vmd.cso.uiuc.edu Tue Feb 2 15:22:22 1993

Hello and greetings from Springfield, Illinois, USA. There are a number of issu
es that are involved in your questions. First, there are an almost infinite nu
mber of possible digital filters that can be implemented, of which the Butterwo
rth is one "type." What is best for you depends on a couple of things -

First, is the the filtering to be done in real time (while and experiment is in
progress), or will you be smoothing sampled data later?

Second - what exactly do you require from this filter? Do you require perfect
rejection of high frequency noise, or is a major, but not perfect attentuation
acceptable? Or is it more important ( I assume it is ) that the low frequency
(displacement measure) be un-distorted after filtering.

Third - what is the frequency content of the position signal - If your noise co
ponent is relatively low - say 50 Hz. with a 500 Hz. sampling frequency - a sui
table filter will be more difficult to design.

The actual code for filtering is not complicated - especially for something lik
e a Butterworth filter. A proper introduction to digital filtering is a time c
onsuming process - but if you are interested, I could suggest a couple of books
that will give a good introduction - one includes a very instructive piece of s
oftware - BUT - I'm locked out my lab right now, and will have to wait until t
ommorow for that. Good luck -

-Keith Leffler

>From smeets@fgg.eur.nl Tue Feb 2 18:59:42 1993

In response to your inquiery on BIOMCH-L, I can report that I am using a
Buttherworth filter for simmilar work. The source code is appended to this


Jeroen Smeets e-mail: smeets@fgg.eur.nl
Vakgroep Fysiologie
Erasmus Universiteit Rotterdam
Postbus 1738
3000 DR Rotterdam
The Netherlands


#define MAXORDE 10

void filter( float *signaal, float ff, float sf, int sl, int on )
/* ON-de orde butterworth filter, gebouwd uit tweedeorde blokken *
* uit Martin H Ackroyd, Digital Filters, Butterworths & Co., 1973 *
* back and forth filterd to prevent phase shift. *
* works only for even ON. *
* the filterfrequency ff is the effective frequency, sf the sample frequency *
* sl the signal length.
* Jeroen Smeets, 21 juli 1988 *
* C-versie 15-12-1992
{int i, i1, i2, n, nn;
float z, a, b, c, d;
float *filter, *hulp;
float a0[MAXORDE], a1[MAXORDE], a2[MAXORDE], b1[MAXORDE], b2[MAXORDE];
complex alfa[2*MAXORDE], beta[2*MAXORDE];
if ( on > MAXORDE ) nrerror("te hoge orde voor procedure filter");
if ( on % 2 ) nrerror("oneven orde voor procedure filter niet toegestaan
ff /= pow( 2.0/3.0, 1.0/on );
/* de frequentie gecorrigeerd omdat we twee keer filteren */
filter = vector( 0, sl+2 );
hulp = vector( 0, sl+2 );
/* berekenen filterconstantes */
z = M_PI * ff / sf;
a = 2 * sin(z) / cos(z);
b = 0.25 * SQR( a );
nn = ( 3 * on ) / 2 - 1;
for ( i=on; i