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 biquadFilter mbed
Fork of frdm_calibratie_maximum by
Revision 4:9f4501eb226b, committed 2016-10-21
- Comitter:
- GerhardBerman
- Date:
- Fri Oct 21 15:13:03 2016 +0000
- Parent:
- 3:339b19905505
- Commit message:
- Working with good filter function: total filtered signal is low
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 339b19905505 -r 9f4501eb226b main.cpp
--- a/main.cpp Fri Oct 21 13:22:31 2016 +0000
+++ b/main.cpp Fri Oct 21 15:13:03 2016 +0000
@@ -19,6 +19,8 @@
double EMGright, EMGleft, inR;
double averageEMGr =0;
double averageEMGl =0;
+double outRnotch2 = 0;
+double outLnotch2 = 0;
void filter_timer_act(){filter_timer_go=true;};
@@ -34,6 +36,10 @@
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);
+// Low pass Butterworth filter 2th order, Fc = 450;
+BiQuad bq6(1.7509e-01,3.5018e-01,1.7509e-01,-5.1930e-01,2.1965e-01);
+
+
void KeepTrackOfTime()
{
time_passed++;
@@ -44,24 +50,32 @@
{
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 outLnotch = bcq1.step(inL);
- double outLrect = fabs(outLnotch);
- double outLlow = bcq2.step(outLrect);
+ double outRnotch = bcq1.step(inR); //notch and highpass for detrend
+ double outRrect = fabs(outRnotch); //calculate abs with fabs
+ double outRlow = bcq2.step(outRrect); //lowpass for envelope
+
+ double outLnotch = bcq1.step(inL); //notch and highpass for detrend
+ double outLrect = fabs(outLnotch); //calculate abs with fabs
+ double outLlow = bcq2.step(outLrect); //lowpass for envelope
//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(0, inR); //emgsignal
+ scope.set(1, outRnotch); //highpass+notch filtered
+ scope.set(2, outRnotch2); //abscalc ifelse
+ scope.set(3, outRrect2); //abscalc fabs
+ scope.set(4, outRlow); //abs ifelse + lowpass
+ scope.set(5, outRlow2); //abs fabs + lowpass
+ */
+ scope.set(0, inR); //emgsignal right
+ scope.set(1, outRlow); //emg filtered: highpass, notch, abs, lowpass
+ scope.set(2, inL); //emgsignal left
+ scope.set(3, outLlow); //emg filtered: highpass, notch, abs, lowpass
scope.send();
// To indicate that the function is working, the LED is toggled*/
led2 = !led2;
@@ -76,7 +90,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(&bq6).add(&bq3); //bcq2.add(&bq3).add(&bq4).add(&bq5); //450Hz Lowpass does not work
filter_timer.attach(&filter_timer_act, 0.0004); //2500Hz (same as with filter coefficients on matlab!!! Thus adjust!)
