01-13-2021 07:30 AM
Hello,
I've just noticed a problem with the digital filter feature that hasn't occurred to me before. As a test I ran the following script on some accelerometer data:
Option Explicit 'Forces the explicit declaration of all the variables in a script.
FiltStruc = "IIR"
FiltStyle = "Butterworth"
FiltType = "Low pass"
FiltDegree = 2
FiltLimit = 3
FiltLowLimit = 0
FiltUppLimit = 0
FiltWave = 1.2
FiltSamples = 25
FiltWndFct = "Hamming"
FiltZeroPhase = True
FiltCorrection = True
'------------ Command -------------------
Set ChnResult = ChnFiltCalc("[1]/Time", "[1]/Latac", "/FilteredSignal_1", "IIR", "Butterworth", "Low pass", 2, 3, 0, 0, 1.2, 25, "Hamming", True, True)
Set ChnResult = ChnFiltCalc("[1]/Time", "[1]/FilteredSignal_1", "/FilteredSignal_2", "IIR", "Butterworth", "Low pass", 2, 3, 0, 0, 1.2, 25, "Hamming", True, True)
Set ChnResult = ChnFiltCalc("[1]/Time", "[1]/FilteredSignal_2", "/FilteredSignal_3", "IIR", "Butterworth", "Low pass", 2, 3, 0, 0, 1.2, 25, "Hamming", True, True)
Set ChnResult = ChnFiltCalc("[1]/Time", "[1]/FilteredSignal_3", "/FilteredSignal_4", "IIR", "Butterworth", "Low pass", 2, 3, 0, 0, 1.2, 25, "Hamming", True, True)
All it does it repeatedly filter the data so I can look at how it progresses. I was surprised to see how much content there was above the 3 Hz limit. The red trace is the original data, the green is the first filter pass, then blue, orange and purple.
Is this due to the filter degree being only two, so that the roll off is too gentle?
If so, and assuming I use 'force zero phase' and 'correct start/end offset' (and as it happens I'm treating all the channels the same), is there any reason why I can't just wind the filter order right up to give a steeper roll off?
Is the repeated filtering (approximately) the same as increasing the filter order?
An additional point of confusion is the reduction in amplitude below the 3 Hz limit, as seen in an FFT of each filtered signal:
Any advice on a better approach?
Thanks, Simon.
Solved! Go to Solution.
01-15-2021 10:03 AM - edited 01-15-2021 10:09 AM
Hi Simon,
I asked R&D about this, and this was there answer. The definition of the filter cutoff frequency is the point where the amplitude attenuation is equal to 3DB, which is half of the power of the input signal at that frequency. This means that by definition there will always be non-zero attenuation in the result amplitudes of frequencies in the Passband region just before the filter cutoff frequency. The top graph is the filter gain curve for a Butterworth filter of minimum degree/order, where the Stopband region is essentially a straight line on this log-log plot. Here you can see that for frequencies in the first half-decade before the cutoff frequency there is non-zero attenuation.
Increasing the filter degree/order changes the shape of the gain curve in the Stopband region. The bottom plot is the gain curve for the same Butterworth filter but using a higher degree/order filter. This is NOT the same as running the same filter multiple times.
It will be easier to see these effects more clearly in your tests if you include multiple decades of frequencies to the left and right of the cutoff frequency you're using.
Brad Turpin
Principal Technical Support Engineer
National Instruments
01-18-2021 02:14 AM
Thanks Brad. All good revision and as I suspected.
Just one question: you refer to the 'bottom plot' being a gain curve for a higher order filter but it would appear to be a phase plot. Could you check that for me?
Also, I wondered in my original request if there were any disadvantages to using a higher order filter. Do you know of any?
Regards.
01-22-2021 07:54 AM
Hi Simon,
Sorry, of course the bottom plot is phase vs. frequency and not gain vs. frequency. I have no idea what I was smoking when I wrote that. I have posed the question to R&D about drawbacks of higher order digital filters.
You're very tactful,
Brad Turpin
Principal Technical Support Engineer
NI