Re: Slow varying inputs

I've got some time so I'll answer your questions.

On Sun, 2005-03-06 at 22:26 -0500, Daniel Nilsson wrote:
> 
> Thanks, I have been looking at your code trying to figure out if you
> are implementing an FIR or IIR filter ? Or is it some other kind of
> filter ? Sorry for the basic questions here...

It uses trapezoidal integration.  The proof is rather easy but I can't
seem to find something like it by googling around.  Therefore, I can't
give you a pointer.  If you want I'll write it up and post it.  It's a
home made algorithm so I don't know what to call it, but I'm certain
someone else might know (perhaps TIR for Trapezoidal Integrated Response
filter).  I put it together in the '80s when I was doing digital
simulations then later modified it to use integer math for
microprocessors with A/D.

>  I
> can't figure out from you code how to extract the A and B filter
> coefficients though so that I can run my samples using your filter
> using the filter and freqz functions in octave (or Matlab) ?

There's no A or B coefficients.  You just select a cutoff frequency (F)
and calculate the scaled integer time constant as documented in the
low_pass_filter.c code.  The code models the well known low pass filter:

             1
         -------  where the time constant T = 1/(2*PI*F)
          sT + 1

A high pass can be done using the same trapezoidal integration
techniques for:

             s
         --------
          sT + 1 

A band pass/reject can also be done.  I'm sure you can calculate the
frequency response of these transfer functions in matlab or octave.

If you want to run your data though the filter and your data is in a
file then just use the program I posted and modify it for your cutoff
frequency and use fopen/scanf to read in your raw data stream.  Warning:
the data needs to be integers that are less than 65536 (short int).  The
routine was written for A/D counts.

Regards

Received on 2005-03-08Z15:07:15