Reducing IIR filter settling time.
Started by 1 month ago●9 replies●latest reply 1 month ago●172 viewsHello,
I am not an expert in DSP so please excuse me if my question is dumb.
I am trying to design an IIR butterworth filter in python. I am looking at the step response of the filter to estimate settling time. I somehow want to reduce the settling time of the filter but still maintain its stability.
Hence I wanted to know what factors are to be tuned to achieve this because whatever I modify I don't see the settling time coming down.
Thanks,
Mahesh
The most direct way to reduce the settling time is to increase the transition band of the filter (the distance in the frequency response between the pass band and the stopband). The transition band is the biggest contributor to filter delay --- a very tight transition band necessitates a long delay in a causal stable filter implementation (for all filter types). Next, if group delay distortion is not a concern, ensure the filter is a "minimum phase filter" which means all of its poles and zeros are in the unit circle. This should be the case with the IIR butterworth filter in question. A minimum phase filter will have the least delay for a given magnitude response.
Since you are specifying a Butterworth filter, there are only two parameters you can control: order, and -3 dB frequency fc as a fraction of sample frequency fs.
Lower-order filters settle faster than higher-order filters.
Filters with larger fc/fs settle faster than those with smaller fc/fs.
For example, if order = 3, then a filter with fc/fs = 0.25 settles twice as fast vs one with fc/fs = 0.125. Same holds for any order.
Can you recommend any other filter types which I can experiment with in python and which settle fast? As of now I only care about the amplitude of the signal.
I am trying to stabilize readings from a thermistor. The ADC samples at 15 SPS.
The thermistors are placed near an induction cooktop hence I want values which vary in less than 1 second.
As already noted, you may not need a filter.
I'm not sure what you mean by "I want values which vary in less than 1 second". Does this mean you are looking for bandwidth (fc) of 1 Hz?
If you decide to use a filter, the fastest settling IIR filter for a given bandwidth (fc) is a first-order IIR. It also has the least stopband attenuation. You could also use an FIR boxcar (moving average) filter:
b = 1/4*[1 1 1 1] or b = 1/8*[1 1 1 1 1 1 1 1], etc.
Another FIR smoothing filter is triangular, e.g.
c = 1/16*[1 2 3 4 3 2 1], etc.
Note a triangular filter's coeffs are just the convolution of a boxcar's coeffs with itself: c = conv(b,b)
Moving average is what I was using earlier. As there are a lot of memory elements involved, I just was exploring other options which generate similar results.
Mahesh,
A first order IIR filter has similar performance to a boxcar filter. Here is Matlab code to compute the step response of an example 1st order IIR filter:
% first order IIR filter coeffs
b= 1/8; % b0
a= [1 -7/8]; % [a0 a1] note a1 = -(1 - b0)
x= ones(1,32); % step
y= filter(b,a,x); % step response
Since you only need 1 result per second you could go even more simple by just averaging all the samples every second without any memory involved and restart the averaging after getting the result. That corresponds to boxcar with downsampled output.
True, just accumulate 2^n samples and discard (n) LSBS from result (to avoid division), reset accumulator and start again. This is block based averaging and does not need memory, just accumulator. The only drawback it is block based and you have to either tolerate the block boundaries or else window two adjacent block edges.
Why have a filter at all? Isn't the masses involved enough?