atoombom

Dependencies:   Encoder HIDScope mbed

Fork of EMG by Tom Tom

LowPassFilter.cpp

Committer:
Bartvaart
Date:
2015-09-28
Revision:
20:4fe3cab02341
Parent:
18:4ebf5e640f0c

File content as of revision 20:4fe3cab02341:

#include "encoder.h"
#include "LowPassFilter.h"

// Define a Ticker, variables for storage, input and output
Ticker biquadTicker;
double v1 = 0, v2 = 0, u = 0, y = 0;
const double a1 = 1.2, a2 = 2.3, b0 = 1.2, b1 = 2.2, b2 = 0.3;
// Implement the computation function
double computeBiquad()
{
    double v = u - a1*v1 - a2*v2;
    y = b0*v + b1*v1 + b2*2;
    v2 = v1;
    v1 = v;
    return y;
}