Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Numeric filter synthesis : Remove 50Hz frequency from a microphone signal

ThomasT

New Member
Good morning,

I encounter the following problem (In my job) :

Using a microcontroller, I digitalize a signal coming from a microphone at a sampling frequency of 16KHz. (This signal goes through a hardware preampli). I get a buffer containing 250 samples.

An algorithm computes statistics on this buffer, but this one is disturbed due to the presence of a 50Hz (Or 60Hz depending on the country) frequency coming from surrounding power supplies mixed with the signal recorded by the microphone.

I would like to realize a numeric filter on this buffer in order to remove this 50Hz frequency (Or 60Hz). I studied numeric filtering 15 years ago, I remember that we managed to synthesize RIF filter using Matlab (Choosing Window, filter order an so on ...).

Now, I do not remember the method, I do not remember how to obtain the coefficients and how to implement the filter practically...

Does anyone knows how to do it please ? Does anyone could explain me the mthod in detail, how to obtain the coefficients and how to implement it ?

If anyone has knowledge on numeric filtering, thank you by advance for your help on the subject.

I wish you a good day.
Best regards,

Thomas
 
Notch Filter

Do you have any special requirements line linear phase ?

Estimate how many db of rejection you need ?

Can you consider solution at analog side. Problem is your sampling frequency
means algorithm has to manage multiples of 16 Khz, say 3X, to handle the
math involved. Whereas 59 Hz notch, OpAmp, simple to do at input.
 
Last edited:
One of the problems of mains noise is that can be high-frequency spikes repeated at 50, 60, 100 or 120 Hz. Low pass or notch filters won't remove that.
 
Here are some references on 50/60Hz filtering with A/D converters, that may be of interest.
 
You can make a very deep notch but have a poor passband around the notch. This requires multiple high Q notches.
Then the line frequency may drift more than 5% also degrades the attenuation. Thus the choice of the specs is crucial for pass and stop band specs. The depth is extremely sensitive to the component tolerance error.
1740605662156.png
 
Here are ideal parts that can be scaled with R*1k and C/1k
1740605982119.png
 
@OP, do you need the 50 hertz removed from time domain signal or
would FFT delivering the frequency content solve your quest ?
 
This is possible in theory but impossible with 0.01% tolerance. This uses a 50 Hz BPF Q=5, BW = 10 Av=1 (0 dB) subtracted from 20 dB amplifier.

1740610153494.png
 
A parametric EQ is often used made tunable using a gyrator notch filter.

But the best solution is to eliminate the hum at the source by using a good shielding and a balanced mic. with a good INA or differential amplifier.
 
Are you completely sure you are dealing with the fundamental frequency and not some harmonic?

A looooong time ago, early 1980s, I helped remove a similar interference on a recording studio. We determined that the 2nd and 3rd harmonics were providing the bulk of the interference.
YMMV, however. But I would certainly perform an FFT with a digital scope to understand the problem better before blindly applying filters.

How did we figure out the offending frequencies in those analog days? Lissajous patterns, with the reference frequency coming from an audio signal generator.
 
Good morning,

I encounter the following problem (In my job) :

Using a microcontroller, I digitalize a signal coming from a microphone at a sampling frequency of 16KHz. (This signal goes through a hardware preampli). I get a buffer containing 250 samples.

An algorithm computes statistics on this buffer, but this one is disturbed due to the presence of a 50Hz (Or 60Hz depending on the country) frequency coming from surrounding power supplies mixed with the signal recorded by the microphone.

I would like to realize a numeric filter on this buffer in order to remove this 50Hz frequency (Or 60Hz). I studied numeric filtering 15 years ago, I remember that we managed to synthesize RIF filter using Matlab (Choosing Window, filter order an so on ...).

Now, I do not remember the method, I do not remember how to obtain the coefficients and how to implement the filter practically...

Does anyone knows how to do it please ? Does anyone could explain me the mthod in detail, how to obtain the coefficients and how to implement it ?

If anyone has knowledge on numeric filtering, thank you by advance for your help on the subject.

I wish you a good day.
Best regards,

Thomas
Do you need help eliminating the hum at mic source? Cables? Shielding,

I suggest a miniature 1:1 transformer with high L as a CM choke which will balance the signal, raise CM impedance to support suppressing the E-field hum from any mic from DC to your fmax..
 

Latest threads

New Articles From Microcontroller Tips

Back
Top