Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: HIDScope MODSERIAL QEI TextLCD mbed
Fork of TotalControlEmg2 by
Filter.cpp
- Committer:
- RemcoDas
- Date:
- 2015-10-28
- Revision:
- 50:16314b798754
- Parent:
- 3:344b173f85fe
File content as of revision 50:16314b798754:
#include "Filter.h"
// According to Direct form 2, see sheets of T.J.W. Lankhorst
// u = input (without filter)
// v = memory (by reference
// a1 and a2 variabel from ASN filter, a0 =1
// b0, b1, b2 variabel from ASN filter
double Filter(double u, double &v1, double &v2, const double a1, const double a2, const double b0, const double b1, const double b2, const double gain){
double v = u - a1 * v1 - a2 * v2;
double y = gain * (b0 * v + b1 * v1 + b2 * v2);
v2 = v1; // shift memory
v1 = v;
return y; // filtered output
}
