Examples of simple digital filters

The following examples illustrate the essential features of digital filters.

  1. UNITY GAIN FILTER: yn = xn
    Each output value yn is exactly the same as the corresponding input value xn:

    y0 = x0
    y1 = x1
    y2 = x2
    ... etc

    This is a trivial case in which the filter has no effect on the signal.

  2. SIMPLE GAIN FILTER: yn = Kxn (K = constant)
    This simply applies a gain factor K to each input value:

    y0 = Kx0
    y1 = Kx1
    y2 = Kx2
    ... etc

    K > 1 makes the filter an amplifier, while 0 < K < 1 makes it an attenuator. K < 0 corresponds to an inverting amplifier. Example (1) above is the special case where K = 1.

  3. PURE DELAY FILTER: yn = xn-1
    The output value at time t = nh is simply the input at time t = (n-1)h, i.e. the signal is delayed by time h:

    y0 = x-1
    y1 = x0
    y2 = x1
    y3 = x2
    ... etc

    Note that as sampling is assumed to commence at t = 0, the input value x-1 at t = -h is undefined. It is usual to take this (and any other values of x prior to t = 0) as zero.

  4. TWO-TERM DIFFERENCE FILTER: yn = xn - xn-1
    The output value at t = nh is equal to the difference between the current input xn and the previous input xn-1:

    y0 = x0 - x-1
    y1 = x1 - x0
    y2 = x2 - x1
    y3 = x3 - x2
    ... etc

    i.e. the output is the change in the input over the most recent sampling interval h. The effect of this filter is similar to that of an analog differentiator circuit.

  5. TWO-TERM AVERAGE FILTER: yn = (xn + xn-1) / 2
    The output is the average (arithmetic mean) of the current and previous input:

    y0 = (x0 + x-1) / 2
    y1 = (x1 + x0) / 2
    y2 = (x2 + x1) / 2
    y3 = (x3 + x2) / 2
    ... etc

    This is a simple type of low pass filter as it tends to smooth out high-frequency variations in a signal. (We will look at more effective low pass filter designs later).

  6. THREE-TERM AVERAGE FILTER: yn = (xn + xn-1 + xn-2) / 3
    This is similar to the previous example, with the average being taken of the current and two previous inputs:

    y0 = (x0 + x-1 + x-2) / 3
    y1 = (x1 + x0 + x-1) / 3
    y2 = (x2 + x1 + x0) / 3
    y3 = (x3 + x2 + x1) / 3
    ... etc

    As before, x-1 and x-2 are taken to be zero.

  7. CENTRAL DIFFERENCE FILTER: yn = (xn - xn-2) / 2
    This is similar in its effect to example (4). The output is equal to half the change in the input signal over the previous two sampling intervals:

    y0 = (x0 - x-2) / 2
    y1 = (x1 - x-1) / 2
    y2 = (x2 - x0) / 2
    y3 = (x3 - x1) / 2
    ... etc


Next | Previous | DSP home page | Index