..Help .Objects

IIR Filters

A collection of 1st and 2nd order IIR filters. All have frequency inputs, some have additional damping inputs.

Pins
io letter name unit description
in X input auto input signal
F frequency Hz cutoff or center frequency
T time sec time constant for RC filters
L Log2(Q) value specifies Q or damping
R radius percent distance from origon
out = auto filtered input signal

Parameters
name option key description
mode LP1oLow Pass 1st order
HP1iHigh Pass 1st order
LP2lLow Pass 2nd order
HP2hHigh Pass 2nd order
BP2bBand Pass 2nd order
BR2rBand Reject 2nd order
1CPp1 Conjugate Pole
1CZz1 Conjugate Zero
RCt1st order Low Pass RC filter
RC +aRC filter with forward diode
RC -eRC filter with reverse diode
auto auto gain=set internal gain to 0dB
detail detail displayentershows frequency response curve on the object

Notes

General

IIR filters are simulations of real-world analog filters built from resistors, capacitors and inductors and thus inherit many of their properties. They also introduce some new properties unique to the digital simulation.

Types of Filters

The following table summarizes the properties of each filter.
name type order F cutoff L or R dB/oct auto
LP1low pass
1
-3dBnone
-6
no
HP1high pass
RC RC+ RC-low pass
above
below
time const
LP2low pass
2
-3dBlog2Q
-12
yes
HP2high pass
BP2band passcenter
BR2band rejectnull
n/a
1CPconjugate poleexactlinear radius
1CZconjugate zero

  • LP Low Pass filters allow frequencies below the cutoff frequency to pass and reduce frequencies above.
  • HP High Pass is the opposite of low pass, allowing frequencies above the cutoff to pass and reducing frequencies below.
  • RC Resistor Capacitor Filters are an alternate form of a 1st order Low Pass filter and are useful in numerical averaging. An optional diode may be inserted before the input to make a high/low detector
  • BP Band Pass filters allow frequencies close to the cutoff to pass through and reduce frequencies farther away.
  • BR Band Reject is the opposite of band pass, reducing frequencies closed to the cutoff and allowing frequencies farther away to pass through.
  • 1CP and 1CZ are abstractions of filters and represent conjugate poles or zeros located on the z-plane. The R input represents the distance from the origon: 0 < R < 1

    Parameters

    A cutoff frequency is required at the F input pin. By convention, F is the -3dB attentuation frequency for LP and HP filters, and the center frequency for BP and BR. For the Pole and Zero filters, F is the exact frequency of the pole or zero.

    The time constant T for RC filters is identical in value to the RC time constant of a 1st order filter:

    e-RC*t
    which is implemented as:
    y[n] = y[n-1] + T * (x[n] - y[n-1])
    Larger values of T reduce the time it takes for the output to match the input. Converesly, smaller values of T increase the time and result in a smoothing of the input signal. Setting T to some fractional value results in exponetial averaging by 1/T samples.

    Damping applies to 2nd order filters and is specified at the L input pin. For simple filter applications, an L value of -0.5 results in a fairly flat response. The following formulas can be used to design multistage filters given frequency and damping or Q for each stage:

    2L = Q = 1/damping
    L = log2(Q) = -log2(damping)
    Large L values correspond to large Q values which corresponds to lower damping which corresponds to a resonant peak in the frequency response.
    Small L values correspond to small Q values which corresponds to higher damping which corresponds to a smoother frequency response.
    Large L values will turn low pass and high pass filters into band pass filters. Large L values for band pass filters will narrow the range of frequencies that are allowed through. Large L values for band reject filters will narrow the range of frequencies that are not allowed through.

    Radius is used only with the 1CP and 1CZ filters. It specifies the distance from the origon of the z-plane to the pole or zero. Unlike L, radius is a linear scale and must be a positive value.

    Detail display mode plots the frequency response on a logarithmic frequency scale from 20Hz to 20KHz. The circuit must be playing for the display to operate. The horizontal line represents the 0dB level.

    Auto Gain for the 2nd order filters adjusts the input level so that the highest point on the response curve is equal to 1.0. If auto gain is not used, the output levels may become extremely large. 1st order filters do not have auto gain.

    When designing higher order polynomial filters, gain is accounted for in the mathematical analysis and must take on specific values. In this case auto gain must be turned off and pre/post attentuation be applied between stages. The Chebychev example below shows an example of this.

    Stability

    2nd order IIR filters are unstable at low cutoff frequencies, below about 20Hz depending on the damping. The symptoms will be the output wandering around, possibly bouncing off the clipping limits. The Differential System object may be used if a very low filter frequency is required.

    Clipping will occur when internal values of the filter are beyond ±1.0. This is shown by a red ring around the object. Use pre-attenuation to prevent clipping.

    Changing the type of filter while the circuit is playing may result in a short squeal as the internal parameters are shifted from one filter to another.

    Examples

    Direct filtering

    The filter is set as a low pass at 1000Hz, Auto gain is on. Frequencies above 1KHz will be reduced by 12dB per octave. The Q of the filter is 1/sqrt(2), aka Butterworth.

    Boost/Cut Configuration:

    Add or subtract the filtered signal with the input signal to boost or cut frequencies. Using a low pass filter results in a bass control. Using a high pass filter results in a treble control. Using a band filter results in a parametric EQ, or one channel of a graphic equalizer.

    5th order Chebychev filter:

    Suitable for use as an anti-alias filter. Cascading two 2nd order sections and one 1st order section results in a 5th order filter with frequency response falling off at 30dB per octave.
    A reference book supplied the frequency and Q constants which were plugged into the circuit as equations. The two LP2 filters have their auto gain setting turned off. Pre and post gain adjustments are optional and help to reduce clipping.

    Technical Details

    IIR stands for Infinite Impulse Response, meaning that the filter will continue to produce an output signal even though the input signal is not changing. The term infinite, however, is a purely theoretical notion and is not possible in the domain of digital filters. The output will eventually stop changing due to roundoff and precision limits.

    ABox takes advantage of this by monitoring the filter's activity and shutting it off when output change falls below a certain level. This means that when presented with a static input, the output may not be exactly what is expected. For example, a lowpass filter presented with an input of 0.5, may stop responding when the output reaches 0.49998. The activity limit was chosen by inspection and may be adjusted in future versions.

    The frequency response of each filter differs slightly from its analog counterpart. This is due to the bilinear transformation used to convert from analog to digital, which adds an extra zero to the filter's transfer function.

    For lowpass and bandpass filters, the zero is at 22050Hz. Close to this frequency, the response will fall off much more rapidly than the analog version. High pass filters have an extra zero at 0Hz, with frequency response also falling off more rapidly. Corresponding to slightly skewed frequency response is that of slightly skewed phase distortion around the new zero.



  • ©1999-2008 Andy J Turner
    All rights reserved.