Tasos Sangiotis

July 15, 2022

Get mains out of my signal

Power-frequency interference gets picked up through insufficiently shielded instrumentation or electricly generated mechanical faults.

While correct installation, ground loop avoidance and elimination of other sources is the goal sometimes it is not possible.

Bellow is the timeseries and spectrum of an heterodyned output ultrasound sensor. It transfers the high frequency signals to the accoustic range.

Screenshot 2022-07-15 082004.png

Screenshot 2022-07-15 073615.png

As you see, 50 Hz is very prominent here resulting in a constant hum. You can also spot a lot of harmonics.

Queue the notch filter.

A notch filter is a type of band-stop filter, which is a filter that attenuates frequencies within a specific range while passing all other frequencies unaltered. For a notch filter, this range of frequencies is very narrow. The range of frequencies that a band-stop filter attenuates is called the stopband.

Because we want to also catch the harmonica we can use a filter sampling frequency that is
a multiple of our power-frequency.

The ideal result in a the time domain will look as bellow.


Doing that to our signal results in a much cleaner representation for the other phenomena.



Harmonics are still there but affect much less the signal. One could certainly phase them out but I used audacity which does not feature sampling rate settings for notch filters so I went manual and I stoped after 450Hz.

I will dig into that more in the future.

  1. Scipy notch function
  2. Introduction to Signal Processing - Sophocles J. Orfanidis (Rutgers University)
  3. Audacity used to generate the above tests 

About Tasos Sangiotis

An electrical engineer at Arpedon with a broad range of interests from electrical, to mechanical & automation. Photoshooter, runner and a fan of good food & alcohol. You can also find me on Twitter, on LinkedIn, and on Instagram. If you choose to wander this wasteland do so with caution. Consider this your final warning.