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.
Fork of Biquad_Hidscope by
Diff: main.cpp
- Revision:
- 0:17b00659dfd2
- Child:
- 1:15de82403661
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Oct 06 14:55:51 2015 +0000 @@ -0,0 +1,50 @@ + +#include "mbed.h" +#include "HIDScope.h" + + +Serial pc(USBTX, USBRX); + +HIDScope scope(1); +Ticker scopeTimer; + +// Read the analog input +AnalogIn ain(A0); + +const double a1=-1.993955222010733; +const double a2=0.9939734363649758; +const double b0=0.9969821645939272; +const double b1=-1.9939643291878544; +const double b2=0.9969821645939272; + + +double v1, v2; + + + +double biquadFilter() { + + double v = ain.read() - a1*v1 - a2*v2; + double y = b0*v + b1*v1 + b2*v2; + v2 = v1; + v1 = v; + return y; + +}; + +void scopeSend() +{ + scope.set(0,ain); + scope.send(); + +} + + int main() +{ + + // Attach the data read and send function at 100 Hz + scopeTimer.attach_us(&scopeSend, 1e4); + pc.printf("foo!\n"); + + while(1) { } +} \ No newline at end of file