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@50:16314b798754, 2015-10-28 (annotated)
- Committer:
- RemcoDas
- Date:
- Wed Oct 28 09:28:48 2015 +0000
- Revision:
- 50:16314b798754
- Parent:
- 3:344b173f85fe
Final, schoongeveegd
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Bartvaart | 0:557b1ff83a8a | 1 | #include "Filter.h" |
| RemcoDas | 50:16314b798754 | 2 | // According to Direct form 2, see sheets of T.J.W. Lankhorst |
| RemcoDas | 50:16314b798754 | 3 | // u = input (without filter) |
| RemcoDas | 50:16314b798754 | 4 | // v = memory (by reference |
| RemcoDas | 50:16314b798754 | 5 | // a1 and a2 variabel from ASN filter, a0 =1 |
| RemcoDas | 50:16314b798754 | 6 | // b0, b1, b2 variabel from ASN filter |
| RemcoDas | 50:16314b798754 | 7 | 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){ |
| Bartvaart | 0:557b1ff83a8a | 8 | double v = u - a1 * v1 - a2 * v2; |
| RemcoDas | 50:16314b798754 | 9 | double y = gain * (b0 * v + b1 * v1 + b2 * v2); |
| RemcoDas | 50:16314b798754 | 10 | v2 = v1; // shift memory |
| RemcoDas | 50:16314b798754 | 11 | v1 = v; |
| RemcoDas | 50:16314b798754 | 12 | return y; // filtered output |
| Bartvaart | 0:557b1ff83a8a | 13 | } |
