Skip to content

yangrui9501/dsp_iir_filter1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

DSP Library: First-Order IIR Filters

Example: LPF

This example illustrates the process of creating a low-pass filter (LPF) object and effectively eliminating the noise signal through digital filtering.

// 2023-05-24
#include <Arduino.h>
#include <iir_filter1.h>

IIRFilter1 lpf;

double y = 0.0;
double n = 0.0;
double ym = 0.0;
double yf = 0.0;
double t = 0.0;
double fc = 10.0;
double T = 0.001;

void setup()
{
    Serial.begin(115200);

    lpf.init(IIRFilter1::TYPE_LPF, fc, T);

    randomSeed(0);
}

void loop()
{
    static int i;

    n = (double)(random(-1000, 1000)) / 1000.0;

    t = (double)(i)*T;
    y = sin(2.0 * PI * 1.0 * t);

    ym = y + n;

    yf = lpf.update(ym);

    i++;

    Serial.print(ym, 4);
    Serial.print(" ");
    Serial.print(y, 4);
    Serial.print(" ");
    Serial.print(yf, 4);
    Serial.println();
    Serial.flush();

    delay(10);
}

image

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages