0
0
RosConceptBeginner · 3 min read

Band Stop Filter: Definition, How It Works, and Examples

A band stop filter is a signal processing tool that blocks frequencies within a specific range while allowing frequencies outside that range to pass. It works like a gate that stops a band of unwanted frequencies and lets others through.
⚙️

How It Works

A band stop filter works by removing or reducing signals within a certain frequency range, called the stop band, while letting signals outside this range pass freely. Imagine it like a noise-cancelling window that blocks out a specific annoying sound frequency but lets all other sounds come through.

It combines the effects of a low-pass filter (which allows low frequencies) and a high-pass filter (which allows high frequencies) to create a gap where frequencies are blocked. This is useful when you want to remove a narrow range of frequencies, such as a hum or interference, without affecting the rest of the signal.

💻

Example

This example shows how to create a band stop filter using Python's SciPy library to remove a frequency band from a signal.

python
import numpy as np
import matplotlib.pyplot as plt
from scipy.signal import butter, filtfilt

# Create a sample signal with two frequencies: 5Hz and 50Hz
fs = 500  # Sampling frequency
T = 1.0   # seconds
t = np.linspace(0, T, int(fs*T), endpoint=False)
signal = np.sin(2*np.pi*5*t) + 0.5*np.sin(2*np.pi*50*t)

# Design a band stop filter to remove frequencies between 45Hz and 55Hz
lowcut = 45.0
highcut = 55.0
order = 4

nyq = 0.5 * fs
low = lowcut / nyq
high = highcut / nyq
b, a = butter(order, [low, high], btype='bandstop')

# Apply the filter
filtered_signal = filtfilt(b, a, signal)

# Plot original and filtered signals
plt.figure(figsize=(10, 6))
plt.plot(t, signal, label='Original Signal')
plt.plot(t, filtered_signal, label='Filtered Signal (Band Stop)')
plt.xlabel('Time [seconds]')
plt.ylabel('Amplitude')
plt.legend()
plt.title('Band Stop Filter Example')
plt.show()
Output
A plot showing two lines: the original signal with combined 5Hz and 50Hz waves, and the filtered signal where the 50Hz component is removed, leaving mostly the 5Hz wave.
🎯

When to Use

Use a band stop filter when you want to remove a specific range of unwanted frequencies from a signal without affecting others. For example:

  • Removing electrical hum noise at 50Hz or 60Hz from audio recordings.
  • Filtering out narrowband interference in communication signals.
  • Cleaning sensor data by blocking known frequency disturbances.

It is especially helpful when the unwanted noise is confined to a small frequency band.

Key Points

  • A band stop filter blocks frequencies within a specific range (stop band).
  • It passes frequencies outside the stop band.
  • It is useful for removing narrowband noise or interference.
  • It combines low-pass and high-pass filtering effects.
  • Commonly used in audio, communications, and sensor data processing.

Key Takeaways

A band stop filter removes frequencies within a chosen range while passing others.
It is ideal for eliminating narrowband noise like electrical hum.
The filter works by combining low-pass and high-pass filters to block a frequency band.
Python's SciPy library can easily create and apply band stop filters.
Use band stop filters to clean signals without affecting useful frequency components.