This program removes unwanted noise (60 Hz) using a digital notch filter. A sine wave enters the MSP432's precision ADC module and exits through an external DAC after being digitally filtered. Matlab is used to calculate the 60Hz notch filter transfer function which is then implemented in C.
https://github.com/Ltran0325/MSP432-Digital-Notch-Filter/blob/main/main.c
Demo:
https://www.youtube.com/watch?v=BwOXYYQE5To
Notch Filter Transfer Function:
MATLAB Code:
% H(s) = (s^2 + w^2)/(s^2 + (w/Q)s + w^2)
% w = 60Hz = center frequency to reject
% Q = 3 = quality factor (increase to narrow rejection)
% w/Q = bandwidth of the rejection band
Hc = tf([1, 0, (2 * pi * 60)^2], [1, 20, (2 * pi * 60)^2]);
bode(Hc);
Hd = c2d(Hc, 1/2000)
MATLAB Bode Plot:
60Hz notch filter.
Oscilloscope (Scopy):
60 Hz is filtered.