Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notch Filter for 60 Hz #15

Open
AGG2017 opened this issue Jan 21, 2022 · 1 comment
Open

Notch Filter for 60 Hz #15

AGG2017 opened this issue Jan 21, 2022 · 1 comment

Comments

@AGG2017
Copy link

AGG2017 commented Jan 21, 2022

Hello,

I'm trying to test this project in practice but in my country the noise from the power line is 60 Hz and I have difficulties to modify your code from 50 to 60 Hz. Can you point me to any information that can help me to recalculate this filter.

Thanks in advance!

@treastorgavin
Copy link

Hi AGG2017,

Looking at the code, we can calculate the coefficients of the notch filter for power lines at 60Hz, assuming a sampling frequency of 500Hz (from arduino.ino).

H(z) = (z-1)/(z-a) where a is within 0-1, the closer a is to 1 the tighter the notch.
to normalize DC unity we multiply H(z) by (1+a)/2
our wn is fo/fc = (60/500)2pi = 0.75398
rotating poles and zeros of z and plugging into H(z)
with a = 0.99 (close to 1 as we want a tight notch since we only want to get rid of 60Hz)
and wn = 0.75398
H(z) = ((1+a)/2) ((z^2) - 2
zcos(wn) +1)/ ( (z^2) - 2azcos(wn) + (a^2))
H(z) = (0.995 - 1.999z^(-1) + 0.995z^(-2) ) / (1- 1.979z^(-1) + 0.9801z^(-2))

Solving the coefficients using inverse z transform

y[n] - 1.979 y[n-1] + 0.9801 y[n-2] = 0.995 x[n] - 1.999 x[n-1] + 0.995 x[n-2]

b coeff = 0.995, -1.999, 0.995
a coeff = 1, -1.979, 0.9801

I would try:

y = 0.995 * x - 1.999* x1 + 0.995 * x2 + 1.979 * y1 - 0.9801 * y2;

for a 60Hz notch filter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants