3
$\begingroup$

I am trying to implement a notch filter by placing zeros and poles. I found in this thread how to specify the frequency to be filtered out (referred to as $\omega_n$ in previous link,) but it is not clear to me how the value of $a$ determines the bandwidth: say I want to discard 50 Hz (to keep the same values as in the previous link) with a notch filter having a 3-dB bandwidth of 5 Hz around the 50 Hz, how can I choose $a$ to realise this?

$\endgroup$

1 Answer 1

4
$\begingroup$

Summary

Given the equation for the transfer function of the second order notch filter:

$$ H(z) =\frac{1+2\alpha \cos(\omega_n)+\alpha^2}{2+2\cos(\omega_n)}\frac{z^2-2z\cos\omega_n+1}{(z^2-2az\cos\omega_n+a^2)} $$

Where:

$\omega_n$: center frequency for the notch (in radians/sample)

$\alpha$: positive real constant $<1$ which sets bandwidth of the notch.

The closer $\alpha$ is to 1, the tighter the bandwidth of the notch.

The relationship between the -3dB notch bandwidth and $\alpha$ is:

$$\alpha = \sec(\omega_c/2)- \tan(\omega_c/2) \tag{1} \label{1}$$

Where:

$\omega_c$: the -3 dB notch bandwidth (in radians/sample); the range of frequencies from the upper -3 dB cutoff to the lower -3 dB cutoff.

Details and Derivation

Rotating the filter to DC to make it a low pass filter simplifies the equation; from this we can establish the relationship between $\alpha$ and bandwidth as the one-sided bandwidth of the first order low pass filter will be half the bandwidth of the two-sided second order notch filter when the notch frequency is sufficiently away from DC or Nyquist and tight enough in bandwidth such that there is no interaction between the positive and negative frequencies.

This is demonstrated in the comparative plots below showing the magnitude frequency response for the 1st order DC nulling filter and 2nd order notch filter with the same value for $\alpha$. A low value of $\alpha=0.6$ was used to exaggerate the bandwidth to make it visible for comparison in the plots. Typically $\alpha$ would be much closer to 1 for tighter DC nulling and notch bandwidth.

first order lowpass and second order bandpass

The poles and zeros on the z-plane for each of these filters is shown below (which the exaggerated low $\alpha$ as done above), which when understood provides intuitive insight into the frequency response for these filters both in magnitude and phase:

Z plane plots

The frequency response is the magnitude and phase of $H(z)$ when we restrict $z$ to be the unit circle; $z = e^{j\omega}$ for $\omega \in [0, 2\pi)$, corresponding to the normalized radian frequency in samples/cycle from DC to the sampling rate. Thus the unit circle is the frequency axis. As we see below for an arbitrary point on the frequency axis labeled $z$, the angle to $z$ is the frequency, and for that particular frequency, the magnitude of the first order DC nulling filter will be the ratio of the length of the numerator vector $v_1 = z-z_1$ divided by the length of the denominator vector $v_2 = z-p_1$. Under typical operation with $\alpha$ very close to 1 (but less than 1 in order to be inside the unit circle and therefore stable), we can see how for most points on the unit circle the two vectors will be approximately equal in length and thus provide a constant magnitude. It is only when we get close to $z=1$ (which is DC with $\omega =0$) that we will get a substantial difference in the length of the two vectors, with the numerator approaching zero, resulting in a tight null. Notably we can see with the 2nd order notch filter that when $\alpha$ is close to 1 and $\omega_n$ is sufficiently far from $0$ or $\pi$ that as $z$ approaches one notch the effect of the other notch will be minimal on the response. Specifically in the plot below, if we had a larger $\alpha$, as $z$ approaches the notch at $+\omega_n$ with $z = z_1$, there would be a significant difference in the lengths between $v_3$ and $v_4$ creating the null, but the lengths of $v_5$ and $v_6$ would be approximately equal, minimizing any effect on the magnitude response. The remaining derivation assumes that this is the case which simplifies the result.

freq response using Z-plane

To convert the transfer function for the second order notch filter \ref{1} into the first order DC nulling filter, we set $\omega_n=1$ to rotate the filter to DC and then factor into two first order sections:

$$ H(z)|_{\omega_n=0} = \bigg(\frac{1+\alpha}{2}\bigg)^2\frac{z^2-2z+1}{(z^2-2az+a^2)} $$

Which is equal to:

$$ H(z)|_{\omega_n=0} = \bigg(\frac{1+\alpha}{2}\bigg)^2 \frac{(z-1)^2}{(z-\alpha)^2}$$

Which is the cascade of two first-order DC nulling filters with transfer function given as:

$$G(z) = \bigg(\frac{1+\alpha}{2}\bigg)\frac{z-1}{z-\alpha}$$

A second order notch filter will have the same frequency response on one side of the spectrum relative to the center frequency as the equivalent first order high pass filter. So we can use the first order DC nulling filter response $G(z)$ to determine a relationship between $\alpha$ and its -3 dB cutoff frequency $\omega_c/2$, which will then be half the bandwidth for the second order notch filter $\omega_c$. At the -3 dB BW, the magnitude of $|G(z)|^2 = 1/2$. Thus we can solve the following equation to get a relationship for the one-side 3dB bandwidth versus frequency with $z=e^{j\omega}$:

$$|G(z)|^2 = G(z)G^*(z)$$

$$|G(z=e^{j\omega_c/2})|^2 = \bigg(\frac{1+\alpha}{2}\bigg)^2\frac{(e^{j\omega_c/2}-1)(e^{-j\omega_c/2} -1)}{(e^{j\omega_c/2}-\alpha)(e^{-j\omega_c/2} -\alpha)}$$

$$ = \bigg(\frac{1+\alpha}{2}\bigg)^2\frac{1-2\cos(\omega_c/2)+1}{1-2\alpha\cos(\omega_c/2)+\alpha^2}$$

This results in the equation to solve:

$$|G(z=e^{j\omega_c/2})|^2 = 1/2 \tag{2} \label{2}$$

Solving \ref{2} for $\omega_c$ results in the two-sided 3 dB bandwidth as a function of $\alpha$:

$$\omega_c = 2\cos^{-1}\bigg(\frac{2\alpha}{\alpha^2+1}\bigg) \tag{3} \label{3}$$

Rearranging \ref{3} to solve for $\alpha$ based on $\omega_c$ results in:

$$\alpha = \sec(\omega_c/2)- \tan(\omega_c/2) \tag{4}\label{4}$$

The bandwidths are given in normalized radian frequency ($2\pi f/f_s$ where $f_s$ is the sampling rate, $\pi$ corresponds to $f_s/2$).

So for example if the sampling rate was 1 KHz, and we desired a 5 Hz double-sided 3 dB bandwidth notch around 50 Hz, the value for $\alpha$ would determined as follows:

$$\omega_c/2 = \frac{2\pi f_c}{f_s} = \frac{2\pi 2.5}{1000} \approx 0.0157$$

$$\alpha \approx \frac{1}{cos(0.0157)}- \tan(0.0157) = 0.9844$$

The above computations are demonstrated with the plot below:

freq response

With the zoomed in plot showing the exact solution for -3 dB bandwidth:

zoom in plot

For further details on the implementation considerations for the DC nulling filter, please see this link.

$\endgroup$
6
  • $\begingroup$ Hi @Dan, thank you for your answer. You meant $e^{j\omega}-1$ instead of $e^{j\omega-1}$ in the expression of $\left\|G(z)\right\|^2$ I think ? Also, redoing your calcultations for $\omega_c$ and $\alpha$, I get the same results :) $\endgroup$
    – aheuchamps
    Commented May 16, 2022 at 17:02
  • $\begingroup$ @aheuchamps yes, thank you! I meant for verification does it actually result in the expected -3dB BW, have you tried that? $\endgroup$ Commented May 16, 2022 at 17:37
  • $\begingroup$ no problem (there is the same kind of typo in the denumerator, I forgot to mention). Regarding the result, I am actually not quite sure, but it looks like it is not what I had in mind. [![enter image description here][1]][1] (I did not include normalization to have zero gain at DC here) [1]: i.sstatic.net/BU0w4.png $\endgroup$
    – aheuchamps
    Commented May 16, 2022 at 19:59
  • 1
    $\begingroup$ @aheuchamps All set! I updated the formulas based on mistakes I found; the formulas now given were verified with the plot shown. $\endgroup$ Commented May 17, 2022 at 5:20
  • 1
    $\begingroup$ Hello again @Dan, thank you so much, it is perfect ! Very much appreciated :) $\endgroup$
    – aheuchamps
    Commented May 17, 2022 at 7:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.