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: mbed HIDScope biquadFilter
Diff: main.cpp
- Revision:
- 4:ebb36bf9feb8
- Parent:
- 3:339b19905505
- Child:
- 5:df782fe787f0
--- a/main.cpp Fri Oct 21 13:22:31 2016 +0000
+++ b/main.cpp Fri Oct 21 15:01:44 2016 +0000
@@ -1,6 +1,7 @@
#include "mbed.h"
#include "BiQuad.h"
#include "HIDScope.h"
+#include <math.h>
//#define SERIAL_BAUD 115200
@@ -30,9 +31,7 @@
BiQuad bq2(9.8239e-01,-1.9648e+00,9.8239e-01,-1.9645e+00,9.6508e-01);
// Low pass Butterworth filter 2nd order, Fc = 8;
BiQuad bq3(5.6248e-05,1.1250e-04,5.6248e-05,-1.9787e+00,9.7890e-01);
-// Low pass Butterworth filter 4th order, Fc = 450; plited up in 2x2nd order
-BiQuad bq4(1.0000e+00,2.0000e+00,1.0000e+00,-4.6382e-01,8.9354e-02);
-BiQuad bq5(1.0000e+00,2.0000e+00,1.0000e+00,-6.3254e-01,4.8559e-01);
+
void KeepTrackOfTime()
{
@@ -44,23 +43,23 @@
{
double inR = emg0.read();
double inL = emg1.read();
- //double inLcal = inL-averageL(sumL,size);
- double outRnotch = bcq1.step(inR);
- double outRrect = fabs(outRnotch);
- double outRlow = bcq2.step(outRrect);
+
+ double outRfilter1 = bcq1.step(inR);
+ double outRrect= fabs(outRfilter1);
+ double outRenvelope= bcq2.step(outRrect);
- double outLnotch = bcq1.step(inL);
- double outLrect = fabs(outLnotch);
- double outLlow = bcq2.step(outLrect);
-
+ double outLfilter1 = bcq1.step(inL);
+ double outLrect = fabs(outLfilter1);
+ double outLenvelope= bcq2.step(outLrect);
+
//pc.printf("Detrend EMG = %f\n\r",inR);
//pc.printf("EMG signal= %f\n\r",emg0.read());
//pc.printf("average EMG right = %f\n\r",averageEMGr);
scope.set(0, inR);
scope.set(1, inL);
- scope.set(2, outRlow);
- scope.set(3, outLlow);
+ scope.set(2, outRenvelope);
+ scope.set(3, outLenvelope);
scope.send();
// To indicate that the function is working, the LED is toggled*/
@@ -76,7 +75,7 @@
//t.attach(&KeepTrackOfTime,1.0); //taking the time in seconds
bcq1.add(&bq1).add(&bq2);
- bcq2.add(&bq3).add(&bq4).add(&bq5);
+ bcq2.add(&bq3);
filter_timer.attach(&filter_timer_act, 0.0004); //2500Hz (same as with filter coefficients on matlab!!! Thus adjust!)