Is there a mathematical approach to initializing an IIR filter so that turn-on transients are minimized?
Background: I have a high pass Butterworth design that overloads at the start of a sine wave signal. If I know the sine turns on at phase =0,i.e. at sine(t) = 0, can I preset the filter registers to minimize the overshoot?
-
2$\begingroup$ Since you can control the initialization of the IIR, am I right assuming your IIR is a digital filter? May I ask why you chose to use a Butterworth in a digital design? That's not a very common choice. $\endgroup$– Marcus MüllerCommented Nov 14, 2019 at 22:31
-
1$\begingroup$ it's extremely common for audio heads. $\endgroup$– robert bristow-johnsonCommented Nov 15, 2019 at 2:33
-
$\begingroup$ @robertbristow-johnson ah! Didn't realize that; for the flatness reason? $\endgroup$– Marcus MüllerCommented Nov 15, 2019 at 12:51
-
1$\begingroup$ yes. and, it's not terribly phase un-linear. not as good as Bessel filters, but much sharper cutoff than Bessel. $\endgroup$– robert bristow-johnsonCommented Nov 15, 2019 at 16:49
2 Answers
This is a common problem, and has an easy solution. The following assumes you are using a cascade of second-order direct-form-1 sections. For a Butterworth highpass filter with a small ratio of Fcutoff to Fs, the numerator coefficients are close to [1 -2 1], and therefore the frequency response of the numerator by itself has a large attenuation at low frequencies. This is compensated by the gain of the recursive section (the poles). When a low-frequency sinusoidal signal is first applied, the input shift register (corresponding to the numerator) is not filled up until the 3rd clock cycle, and therefore the output of the numerator FIR may be large for the first 2 clock cycles, after which it becomes small. These initial large values get captured in the recursive section, and recirculate for some time until they die out. So the simple solution is to delay the operation of the filter until the input shift register is filled with the first 3 samples.
-
$\begingroup$ Note that this trick is very useful in the case where the input has a DC component that you are trying to remove. Typically you would need to wait quite a long time for the the filter to settle (assuming a high ratio of Fs/Fcutoff). By delaying the filter operation until the input register is filled, the output appears on cycle 3 with no DC component, and no long settling tails. $\endgroup$– BobCommented Nov 15, 2019 at 14:15
-
$\begingroup$ Thanks, i'll try this and let you know how it works. And the DC component is an issue with my application. $\endgroup$ Commented Nov 16, 2019 at 17:02
An easy way to deal with this would be to actually let the sine run through your filter for a while, and then just at the right phase save the state of the IIR.
However, chances are: if the impulse response in this situation is a problem to you, your IIR isn't the right design.
-
$\begingroup$ Why so dismissive about discrete Butterworth filters? They have some really nice properties that I've found quite useful for cross-overs and multi-band designs. They can be implemented very efficiently (using all passes) and in particular the phase relationship between high and low pass are very useful. $\endgroup$– HilmarCommented Nov 15, 2019 at 14:14
-
$\begingroup$ not really dismissive! I'm just skeptical when someone uses an IIR but doesn't want typical IIR properties (like the reaction to the wideband excitation through the beginning of the sine). $\endgroup$ Commented Nov 15, 2019 at 15:03