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
Filter.cpp
- Committer:
- Bartvaart
- Date:
- 2015-10-06
- Revision:
- 1:98be4152a539
- Parent:
- 0:557b1ff83a8a
- Child:
- 2:ae55928ff00f
File content as of revision 1:98be4152a539:
#include "Filter.h"
double Filter(double u, double &v1, double &v2, const double a1, const double a2, const double b0, const double b1, const double b2){
// volgens direct form 2, uit de embedded filtering and control sheets van T.J.W. Lankhorst
// u = ingangssignaal (zonder filter)
// v = tussentap
// v1 = v bij u(x-1), dus v van 1 geleden
// v2 = v bij u(x-2), dus v van 2 geleden
// a1 en a2 variabele uit ASN filter, a0 =1
// b0, b1, b2 variabele uit ASN filter
// y = uitgangssignaal (gefilterd)
double v = u - a1 * v1 - a2 * v2;
double y = b0 * v + b1 * v1 + b2 * v2;
v2 = v1; // signalen doorschuiven, zodat bij volgende input, de vorige waardes vsn v worden onthouden
v1 = v;
return y;
}