# Filtering out a specific frequency in an analog signal

I'm wondering how I would go about filtering out a regular sine-wave signal with a constant frequency and voltage.

I'm really new to the whole DSP-area but imagine I would have a regular sinewave at a specific frequency (let's say 30Hz), and on top of that signal I have a bunch of other small peaks (which are the ones I would want to sample and read). What method would I choose?

Here is a visualization of what I meant: Excuse my terrible Paint-skills but how would I filter out that sinewave, and just keep the small spikes in voltage? What might be worth sharing is that the time between the spikes does have an impact on my measurement of the spikes, or to rephrase: The amount of spikes within x-units of time does have an impact.

Any guidance to the right direction would really be appreciated.

Thank you.

• Looks like you need a notch filter: en.wikipedia.org/wiki/Band-stop_filter
– MBaz
Jul 19 '15 at 22:07
• @MBaz Ah! Exactly what I seem to need. Thank you very much!!!! Jul 19 '15 at 23:35
• I am not able to view the image but from your description I think you simply need a clipper circuit. A clipper can be designed using diodes. en.wikipedia.org/wiki/Clipper_(electronics). Jul 20 '15 at 6:23

A notch filter is a good approach in general for removing an unwanted frequency. But if you are certain of the exact frequency, phase and amplitude of the unwanted sine wave, then you may also consider adding the noisy signal to a sine wave of the same frequency and amplitude but 180 degrees out of phase with the unwanted sine wave.

To illustrate the notch filter example, the plot below shows an attempt to generate a sine wave with some odd impulses (black), and then filter it with a notch filter knowing the exact frequency (red). R code for implementing it below.

# 24782
# install.packages('signal')

T <- 1024
t <- 0:(T-1)

fs <- 1000
omega <- 2*pi*30/1000
phi <- 0.9279835

x <- sin(omega*t + phi)

changed <- sample(1:T, 10)

y <- x
y[changed] <- y[changed] + 3

alpha <- 0.9
num <- c(1, -2*cos(omega), 1)
den <- c(1, -2*alpha*cos(omega), alpha*alpha)

yf <- signal::filter(num, den, y)

plot(t,y, type="l", lwd=10)
lines(t,yf, col="red", lwd=4)

legend(850, 4, c("Original", "Filtered"), lwd=c(2.5,2.5),col=c("black","red"))


You can sample the raw signal and then use a bandstop filter to filter out the 30 Hz frequency component.

http://www.mathworks.com/help/signal/examples/introduction-to-the-filter-design-and-analysis-tool-fdatool.html

Fdatool is a MATLAB tool simply to use