# LP, HP, BP, BS FIR Filters with the Fourier Series and Hamming/Hanning/Blackman Windows.

Cuthbert Nyack
Although the Kaiser and Dolph-Chebychev windows are more flexible and can produce better filters than the Hamming, Hanning or Blackman windows, the latter are much easier to work with and can be used when the requirements are 'basic'. The applet here illustrates how LP, HP, BP and BS filters may be derived using the Hamming, Hanning and Blackman windows. It also allows the discontinuity at the band edge to be replaced by a line of finite slope.

Hamming window w(t) = 0.54 + 0.46 * cos(2pt/t) for |t| <=t/2.

In this applet the following expression is used:-
wv(t) = {a + (1 - a) * cos(2pt/t)}n
a and n can be adjusted by scrollbars 12 and 14.

Hanning window w(t) = 0.50 + 0.50 * cos(2pt/t) for |t| <=t/2.

In this applet the following expression is used:-
wv(t) = {a + (1 - a) * cos(2pt/t)}n
a and n can be adjusted by scrollbars 12 and 14. .

Blackman window w(t) = 0.42 + 0.50 * cos(2pt/t) + 0.08 * cos(4pt/t) for |t| <=t/2.

In this applet the following expression is used:-
wv(t) = {a + b * cos(2pt/t)+ (1 - (a + b)) * cos(4pt/t) }n
a, b and n can be adjusted by scrollbars 12, 13 and 14. a, b can be adjusted and c + a + b is kept equal to 1.

An increase in n leads to a compression of the signal in the time domain and because of the inverse relationship between the time and frequency domains, this produces an increase in the transition bandwidth. It also reduces the discontinuity of the impulse response at the truncation points and therefore increases the stop band attenuation.

2 window function plots are shown for the standard window w(t) in dark red and the variable wv(t) window in dark green.

The standard window parameters have been chosen to give acceptable filters over a wide range of cases. With the interactive approach used here, it is easy to adjust the parameters for any particular case.

Scrollbar 0 sets Fn which determines the type of filter.
Fn = 0 to 3 illustrates LP, HP, BP and BS with the Hamming window.
Fn = 4 to 7 illustrates LP, HP, BP and BS with the Hanning window.
Fn = 8 to 11 illustrates LP, HP, BP and BS with the Blackman window.
Fn = 12 to 15 illustrates LP, HP, BP and BS with the Hamming window and a slope instead of a discontinuity at the cut off frequency.
Fn = 16 to 19 illustrates LP, HP, BP and BS with the Blackman window and a slope instead of a discontinuity at the cut off frequency.
When a slope is used, the gradient is set by scrollbar 15 and is shown as as(S15). The slope starts at wc - as/2 and ends at wc + as/2 so the gradient is ±1/as.
Scrollbars 28 and 29 set the frequency reference lines, first line of text shows the gains at frequency of the white line and the second line show the gains at the orange line.
The dBref line is adjusted by scrollbar 27.
Scrollbar 31 sets the length of the filter.
Each Function shows 3 frequency plots, blue corresponds to the rectangular window included here for comparison. Red shows the frequency response with the standard window functions and green shows the frequency response with the window parameters treated as variables. The corresponding Impulse response can be seen by changing scrollbar 30 and is shown as Irec(S30:n), Iw(t)(S30:n) and Iwv(t)(S30:n).

A low Pass filter with the Hamming window is shown below The minimum stop band attenuation for the standard Hamming window is 55dB and for the variable window(a = 0.561, b = 0.439, n = 3) it is 90dB. The frequency at which the standard window reaches an attenuation of 55dB is ~0.174ws and the frequency at which the variable window reaches an attenuation of 90dB is ~0.204ws.

A high Pass filter with the Blackman window is shown below.
The interpretation of the white text is as follows:-
First line:-
The white frequency reference line is controlled by scrollbar 28 and is located at 0.297ws. The gain of the blue, red and green frequency response curves at 0.297ws is -32.65dB, -79.40dB and -80.35dB respectively.

Second line:-
There are 2 reference dB lines controlled by scrollbars 26 and 27. These are set to be -75dB and -80dB.
The Orange frequency reference line is set by scrollbar 29 and is at 0.309ws. The gain of the blue, red and green curves at 0.309ws are -28.87dB, -77.43dB and -46.62dB respectively.

Third line:-
The impulse response is shown by changing scrollbar 30 and goes from 0 to N - 1 = 70.

4th line:-
Fn = 9 which illustrates a high pass filter with the Blackman window. The length of the filter is set by scrollbar 31 and is 51. The cut off frequency is set by scrollbar 2 and is 0.350ws. For the window wv(t) the value of 'a' is set by scrollbar 12 and is 0.611, the value of 'b' is set by scrollbar 13 and is 0.394 and the value of n is set by scrollbar 14 and is 3.500.

A low pass filter with a Blackman window is shown below. The minimum stop band attenuation for the standard window is 75dB and for the variable window it is 89dB.

A band Pass filter with the Hamming window and slope is shown below. The minimum stop band attenuation of the standard Hamming window is 56dB and for the variable window it is 88dB.

A band stop filter with the Blackman window and slope is shown below. The minimum stop band attenuation for the standard Blackman window is 90dB and for the variable window it is 95dB.