Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Digital Filter Software

Status
Not open for further replies.

rh142

Nuclear
Jul 24, 2007
20
US
What is the best software to do filter. I need create an 8th order low pass butterworth filter.

Also from what I remember from by signal processing class (which was a long time ago) that filtering causes a time delay and phase shift. What is the best way of eliminating it or reduce the affects from it.

Thanks in advance.
rh142
 
Replies continue below

Recommended for you

Why not just buy it pre-made? Look for the Maxim MAX7480... it's an 8th order Butterworth, and there are others out there.

Dan - Owner
Footwell%20Animation%20Tiny.gif
 
macgyvers2000,

To clarify a little more. I am a structural engineer and the "signal" I want to filter is from a numerical analysis which is giving time vs acceleration data. The data is in two columns with sampling rate of 10,000 Hz and the cutoff frequency I want to use is 180 Hz.

Thanks,
rh142
 
First, I'm not an expert in this area.

My coworker showed me the Fourier Analysis extension for MS-Excel. Using this package, he can go back and forth between time and frequency domains. We use this for testing RF transmission lines.

Once you're in the frequency domain, you could almost draw the desired filter response and cut and paste the result. (I think... ;-) )
 
You are right, you can set the non-desired frequency components to 0, then do an inverse FFT. It is not much discussed in DSP textbooks... a fact which I asked about here:
If you use this method, you should use a little bit of a smooth transition from pass-band to stop band rather than abrupt.

There are of course many different ways to do digital filtering. For example
I have a Kaiser Bessel filter function that I wrote in excel vba. It is customizeable with respect to transistion width and how close the stop/pass bands are to 0 / 1. It processes in the time domain and cuts a little bit off the front and back of the signal. It requires installation of the vba analysis tookpak (and a little more hocus pocus to add it to your library) in order to get the bessel functions. Let me know if you are interested in that.

=====================================
Eng-tips forums: The best place on the web for engineering discussions.
 
The time shift can be analysed and addressed for any of the filters. First pick which one you are looking at.

=====================================
Eng-tips forums: The best place on the web for engineering discussions.
 
The expensive software that is 'best' for this job is Matlab.

The free alternatives are called Octave and Scilab. Of the two Scilab is generally faster, but Octave's syntax is almost identical to matlb's, so if you find some matlab code on the web you can usually get it running very easily.

Excel's FFT routine is fine so far as it goes but would not be my choice for analysing much data.

If you specifically want a 8th Butterworth filter then you are in luck, matlab has it built in, in the signal processing toolbox, I suspect the other two do as well.

Incidentally if you 'decimate' your data first then you will be handling much smaller files.

it really dpeends on hwo muchbdat you have, I have 60 files, and 3 hours of 80 channels, so tend to have to think about different solutions than if you've got 2 channels for 10 seconds.



Cheers

Greg Locock

SIG:please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
 
Regarding your question about "time delay", Butterworth is usually a good compromise between time domain performance (flat group delay) and frequency domain performance (sharp cutoff). If Butterworth does not give you good enough time domain performance though, you can use a Bessel filter - although the cutoff won't be as sharp for the same number of sections.

Peter
 
Greglocok,

Thanks, Octave was already available on our system since we have red hat. So I was able to use it.

I am following a published paper for the analysis and filter they used is an 8th order butterworth filter, so I want to use an 8th order butterworth filter. The paper also states that the time delay or phase shift produced by the filter in the filtered signal was eliminated by performing a backward filtering after the normal forward filtering. What does it mean?

Thanks,
rh142
 
That means that you simply do the FFT from the last sample towards the first. Adding that to the "normal" FFT produces a spectrum that can be converted back to time domain without any delays or phase shift.

Gunnar Englund
--------------------------------------
100 % recycled posting: Electrons, ideas, finger-tips have been used over and over again...
 
Skogsgurra,

FFT or filter? Assuming filter, I should flip the filtered response then filter again. Then flip it back? Is this my final filtered response or do I need to add it to the first filtered response and average.

Thanks,
rh142
 
FFT fwd + FFT bwd then manipulate total spectrum (remove components that you do not want/need) and back to time domain. Done it once in a laboration. It seemed to work.

Gunnar Englund
--------------------------------------
100 % recycled posting: Electrons, ideas, finger-tips have been used over and over again...
 
The filtering forward and backward business is a new one on me.

How about this. Do a on-time expreiment of sending an impulse at time=0 through your filter. Look at the output and use it to figure out the time delay of your filter. Then whenever you do any further filtering, just shift the final signal by the known about of the time delay.

=====================================
Eng-tips forums: The best place on the web for engineering discussions.
 
It sounds like a couple of concepts are getting confused here. A butterworth filter, which is a form of IIR, does operate on an FFT like an FIR filter does. This isn't to say that there isn't a way to compensate for filter delays, but...

Anyway, to the OP: What is your plan for implementation of your 8th order filter? With a filter order that high, there are a number of caveates regarding implementation. For one, are you planning on implementing in floating point or fixed point? Are you planning on breaking it into second order sections? What form of sclaing to do you plan to use between the sections? What form architecture are you planning on using, etc, etc.

Another very important factor to consider is are you interested in the frequency domain (frequency content) or time domain (wave shape) of the response? A butterworth filter, or any other filter with a non-linear phase response will cause time domain distortion such as ringing and overshoot.


 
Noway2,

I am more interested in the wave shape, which is why I was wondering about backwards filtering to reduce the effects of time delay and phase shift.

I created a filter in octave using the butter (generates the b and a arrays) and filtfilt (which does forward and backwards filtering). I do see ringing though.

I hadn't specifically specified floating or fixed, I guess Octave uses whichever is default.

Also second order sections is new to me, I'll have investigate it and see how to implement it. I am assuming that this will help with the ringing.

Thanks,
rh142
 
The ringing may be caused by finite precision of the tool, but more than likely it is caused by the fact that a Butterworth filter has a damping ratio of .707. A Butterworth filter is maximally flat in the frequency domain, but does not have a linear phase, meaning you will get time domain, ie wave shape distortion.

Octave will use floating point arithmetic. The fixed versus floating point concerns your implementation, if for example you are implementing your algorithm on a fixed point micro-controller.

If you implement your algorithm in fixed point (or integer) format, there are several things to watch for. Three big ones are: 1 - that as the order goes up, the w0 term will get vanishingly small, which makes scaling an issue, 2 - depending on the form you choose (DF1, DF2, DF2 transposed, etc), you can have significant overflow issues. 3- the finite precision of your limited number of bits becomes a problem that causes errors in the frequency domain and / or limit cycle oscillations in the output.

If I recall correctly, you want to implement an 8th order filter, which can be tough. By breaking the filter into cascaded second order sections you can avoid many of the pitfalls. Look at an analog filter cookbook that uses op-amps. The filters are designed as cascaded second order sections and you will want to do something similar. Ideally, you will match the pole-zero co-effecients (yes you will have zero's in the z-domain even if your analog prototype is an all pole filter) that are closest together and then use something like Norm-infinity scaling (which I haven't figured out how to do in Octave).





 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top