# What is FIR Digital Filter

FIR stands for "Finite Impulse Response". An FIR filter is a type of digital filter that uses a finite number of past input samples to calculate an output. It is a non-recursive filter, which means that the output at any given time depends only on the current and past input samples, and not on any previous output samples.

FIR filters have several desirable characteristics, such as linear phase response and stability, which make them popular in many signal processing applications. The impulse response of an FIR filter is finite in length, which means that it settles to zero after a finite number of samples, unlike infinite impulse response (IIR) filters.

FIR filters can be designed using a variety of methods, such as windowing, frequency-sampling, and optimization techniques. The design method used can have an impact on the filter's frequency response, passband ripple, stopband attenuation, and computational complexity.

The transfer function equation of a general digital filter is given by the following equation:

$$H(z)=\frac{\sum_{k=0}^{M-1}b_{k}z^{-k}}{\sum_{k=0}^{N-1}a_{k}z^{-k}}$$ ---->(1)

or, $$H(z) = \frac{b_0 + b_1 z^{-1} + b_2 z^{-2} + ... + b_n z^{-n}}{a_0 + a_1 z^{-1} + a_2 z^{-2} + ... + a_n z^{-n}}$$

The numerator of the transfer function represents the feedforward coefficients or the impulse response of the filter, while the denominator represents the feedback coefficients or the poles of the filter. The filter can be either a finite impulse response (FIR) filter if the denominator is equal to 1, or an infinite impulse response (IIR) filter if the denominator is a polynomial of order greater than 1. The order of the filter is determined by the highest power of z in the denominator.

The transfer function is used to analyze the frequency response of the filter, which describes how the filter modifies the frequency content of a signal that passes through it. The magnitude and phase response of the filter can be obtained by evaluating the transfer function at different frequencies. The output signal of the filter is obtained by convolving the input signal with the impulse response of the filter.

The generalized equation for FIR digital filter is below which is obtained from(1) using only the numerator.

$$H(z)=\sum_{k=0}^{M-1}b_{k}z^{-k}$$ ---->(2)

or,  $$H(z) = b_0 + b_1 z^{-1} + b_2 z^{-2} + ... + b_n z^{-n}$$

FIR Low Pass Filter equation

The output signal of an FIR filter is given by the convolution of the input signal with the filter coefficients, which are defined by the transfer function of the filter.

For a 1st order FIR filter with transfer function $$H(z) = b_0 + b_1 z^{-1}$$, the output signal $$y[n]$$ is given by the convolution of the input signal $$x[n]$$ with the filter coefficients $$b_0$$ and $$b_1$$:

$$y[n] = b_0 x[n] + b_1 x[n-1]$$

For a 2nd order FIR filter with transfer function $$H(z) = b_0 + b_1z^{-1} + b_2z^{-2}$$, the output signal $$y[n]$$ is given by the convolution of the input signal $$x[n]$$ with the filter coefficients $$b_0$$, $$b_1$$, and $$b_2$$:

$$y[n] = b_0 x[n] + b_1 x[n-1] + b_2 x[n-2]$$

To calculate the coefficients for a cutoff frequency for example 100 Hz, we can use a digital filter design tool or equations derived from analog filter design.

For example, using the bilinear transformation, the coefficients can be calculated as follows:

$$f_c= 100Hz$$

$$fs = 44100Hz$$

$$w_c = 2 \pi f_c$$

$$T = \frac{1}{f_s}$$

$$a = \frac{2 T w_c - 4}{2 T w_c + 4}$$

$$b_0 = \frac{1-a}{2}$$

$$b_1 = 1 - a$$

$$b_2 = \frac{1-a}{2}$$

FIR High Pass Filter equation

The output signal of a 1st order FIR high pass filter with transfer function $$H(z) = b_0 - b_1z^{-1}$$ is given by:

$$y[n] = b0 x[n] - b1 x[n-1]$$

where $$x(n)$$ is the input signal and $$y(n)$$ is the filtered output signal.

The output signal of a 2nd order FIR high pass filter with transfer function $$H(z) = b_0 - b_1z^{-1} + b_2 z^{-2}$$ is given by:

$$y[n] = b0 x[n] - b1 x[n-1] + b2 x[n-2]$$

where x(n) is the input signal and y(n) is the filtered output signal.

Overall, FIR filters are widely used in applications such as audio and image processing, telecommunications, and biomedical signal processing.