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
Diff: Filter.cpp
- Revision:
- 0:557b1ff83a8a
- Child:
- 1:98be4152a539
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Filter.cpp Tue Oct 06 12:02:22 2015 +0000
@@ -0,0 +1,20 @@
+#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;
+ }
\ No newline at end of file
