LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I determine the best Order to run my butterworth filter at?

Solved!
Go to solution

I'm lowpass filtering a signal that was sampled at 200hz through a 40Hz butterworth. I need to determine the optimal filter order. How do i create a quantitative comparison of the effects of the butterworth filter on the frequencies above 40Hz based on varying order?

 

I have tried using the FFT to create a chart in the frequency space, but am not sure how to proceed. Any help would be greatly appreciated. What I want to compare is the path immediately before and immediately after the butterworth filter.

 

Also is there an alternate way to read in a column of numbers from a text file without using the Read from Measurement file Express VI?

0 Kudos
Message 1 of 7
(22,836 Views)

Evilduck,

 

1. Consult any book on filter design.  Most have graphs or tables of attenuation versus filter order.

2. Since you sampled at 200 Hz, the Nyquist criterion specifies that signal frequencies less than 100 Hz ca be accurately represented in the sampled data.  The second harmonic will be OK but the third harmonic (at 120 Hz) will not.

3. To make a comparison of different filter orders, simply run the same signal through multiple filters and plot all the outputs on the same graph.

 

I think you are not fully understanding what you are trying to do.  Or you have not explained it well.  Typically a filter is specified by defining the frequency range where the desired signal is located (the passband), the frequency range where the undesired signals are located (the stopband), and the amount of attenuation of the undesired signal which is required.  From that information the filter type and order can be readily determined.

 

Lynn

Message 2 of 7
(22,828 Views)

Hi Lynn,

 

thanks for the interest. My filter's passband is 0-40 Hz and the stopband is 40-200 Hz. (really, anything over 40 Hz is in the stopband).

 

The comparison I want to make is quantitative however. Although I could pass the data through several filters of varying order, I cannot simply visually compare them on the graph.

 

 

What I have done is replaced the FFT with the power spectrum density.vi

 

I was thinking I might be able to integrate the power spectrum from 40 to +Inf so that there is a comparison to be made?

0 Kudos
Message 3 of 7
(22,821 Views)

That is an invalid filter specification.  The passband edge and the stopband edge cannot be the same.  Making them the same implies an infinite order filter.  That will produce an infinite delay so you will never get any output.  And as I mentioned before anything above 100 Hz violates the Nyquist criterion.

 

The power spectrum density takes an FFT then does some additional processing on the transformed output so it may not be much different.

 

Lynn

Message 4 of 7
(22,812 Views)

I have my filter working correctly now. I just need a quantifiable way to justify picking any one order of filtering over another.

 

Here is my front panel, How can I compare the (After/ Before) graphs of varying orders (in a quantifiable way)? How can one tell which is the best?

 

I was thinking I could compare the (Integral from 0 to 40)/40 and the (Integral from 40-inf). The order that yeilds the closest to 1 and 0 respectively should be the one I go with. Does that sound logical?

 

How do I compute a definite integral with a lower bound and an upper bound?

Download All
0 Kudos
Message 5 of 7
(22,804 Views)
Solution
Accepted by topic author Evilduck

OK,

 

One standard way of comparing filters for steepness of roll-off is to look at the ratio of frequencies at two different attenuations.  Typically this is done at -3dB and something else such as -60 dB.  You have your data plotted linearly. Perhaps just looking at the ratio of f(@0.75)/f(@0.25) would be sufficient for your needs.  From looking at your images: Order 2 f(@0.75) ~= 38.  f(@0.25) ~= 60. Ratio = 1.58. Order 10 ratio = 39/42 = 0.93.  If you want larger numbers for better performance use the reciprocals.

 

Lynn

Message 6 of 7
(22,791 Views)

Without further information about your application it is difficult to say which filter will be better.  From a transition bandwidth and stopband attenuation perspective a larger order will be "better" in the sense that the transition band will be more narrow or the stopband attenuation will be better.  Essentially, the filter response more closely approximates an ideal response as the filter order increases.  You might ask yourself instead what is a sufficient stopband attenuation, or what is a sufficient transition bandwidth for your application.  For example, if your filtered signal is later added to another signal with a noise floor of -60 dB, then it does not make sense to have a filter that has a stopband attenuation of -100dB.  Once you have the stopband attenuation and transition bandwidth that make sense for your application, then you can increase the filter order until they are satisfied.

 

Also, keep in mind that the phase response of the filter changes with the order, so if your signal has many frequency components in the passband then they will be delayed relative to each other.  Whether that matters or not depends on your application.

 

You could use the filter express VI to quickly try different filter orders, or look at the following examples:

\examples\measure\maxmpl.llb\IIR Filtering and Response.vi

\examples\measure\maxmpl.llb\IIR Filtering Using Optional Specs.vi

 

 

-Jim

0 Kudos
Message 7 of 7
(22,776 Views)