Skip to content

madhawapolkotuwa/DigitalFilters

Repository files navigation

CIC and FIR Filters with Test Program

This repository contains implementations of a Cascaded Integrator-Comb (CIC) decimation filter and a Finite Impulse Response (FIR) filter with various windowing options. A test program is included to verify the filtering process using generated signals with noise.

Features

  • CIC Filter: Implements a decimation filter to reduce the sampling rate and remove high-frequency noise.
  • FIR Filter: Supports various window functions to improve frequency response.
  • Signal Generation & Testing: Includes a Jupyter Notebook to generate test signals with noise and visualize the filtering process.

Filter Types

LowPass, 
HighPass,
BandPass, 
BandStop(Notch)

Window Types

Rectangular,
Triangular,
Welch,
Sine,
Hann,
Hamming,
Blackman,
Nuttall,
BlackmanNuttall,
BlackmanHarris,
FlatTop,
Kaiser

How to Test

Step 1: Generate Noisy Signal

  1. Open signalGeneration.ipynb in Jupyter Notebook.
  2. Adjust signal and noise frequencies as needed.
  3. Run the Generate Signal + Noise section.
  4. This will generate a noisy signal and save the data to noisy_signal.txt.

Step 2: Apply Filters in C++

  1. Open Test.cpp.
  2. Adjust the filter settings (CIC, FIR) as required.
  3. Compile and run the C++ program.
  4. The program will generate a filtered.txt file containing the filtered signal data.

Step 3: Visualize Filtered Signal

  1. Open signalGeneration.ipynb again.
  2. Run the Check Filtered Signal section to visualize the filtered output.

Requirements

Python

  • Jupyter Notebook
  • NumPy
  • Matplotlib

C++

  • C++ compiler (GCC, Clang, or MSVC)
  • CMake (optional, for building)

Compilation (C++)

To compile and run the test program:

 g++ Test.cpp -o filter_test
 ./filter_test