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
Revision 21:8fe8419de3e9, committed 2015-10-14
- Comitter:
- Bartvaart
- Date:
- Wed Oct 14 14:49:47 2015 +0000
- Parent:
- 20:11e1244ad2ad
- Child:
- 22:c1811e60bfce
- Commit message:
- Alles werkt goed, alleen het kalibreren stopt niet helemaal zoals gewenst waardoor bij het indrukken van de knop voor her-kalibratie problemen kunnen ontstaan
Changed in this revision
--- a/Filterdesigns.cpp Wed Oct 14 12:36:42 2015 +0000
+++ b/Filterdesigns.cpp Wed Oct 14 14:49:47 2015 +0000
@@ -18,34 +18,13 @@
const double b0_50b = 1.00000000000, b1_50b = -1.61854514929, b2_50b = 1.0;
const double gain_50b = 0.934872;
-// Notch 0-20Hz
-
-// Filter2a: 0-20Hz Notch
-double v1_020a = 0, v2_020a = 0;
-const double a1_020a = -1.78180535801, a2_020a = 0.78747189013;
-const double b0_020a = 1.00000000000, b1_020a = -1.99365972450, b2_020a = 1.0;
-const double gain_020a = 0.893737;
-
-// Filter2b: 0-20Hz Notch
-double v1_020b = 0, v2_020b = 0;
-const double a1_020b = -1.75020314275, a2_020b = 0.80725578229;
-const double b0_020b = 1.00000000000, b1_020b = -1.99365972450, b2_020b = 1.0;
-const double gain_020b = 0.890775;
-
-// Filter2c: 0-20Hz Notch
-double v1_020c = 0, v2_020c = 0;
-const double a1_020c = -1.97815539898, a2_020c = 0.97877726519;
-const double b0_020c = 1.00000000000, b1_020c = -1.99365972450, b2_020c = 1.0;
-const double gain_020c = 0.990804;
-
//HighPass 20Hz
// Filter2a: 20Hz HighPass
double v1_HP = 0, v2_HP = 0;
-const double a1_HP = 1.64732093404, a2_HP = 0.70900981120;
-const double b0_HP = 1.00000000000, b1_HP = 2.0, b2_HP = 1.00000000000;
-const double gain_HP = 0.84193;
-
+const double a1_HP = -0.76475499450, a2_HP = 0.27692273367;
+const double b0_HP = 1.00000000000, b1_HP = -2.0, b2_HP = 1.00000000000;
+const double gain_HP = 0.510419;
//LowPass 3Hz
@@ -57,8 +36,6 @@
// constante variabelen:
-double gem = 0.4557; // gemiddelde waarde emgsignaal
-
double y=0;
double Filterdesigns(double u)
@@ -66,8 +43,6 @@
//u = input waarde
//y = output waarde
- u = u - gem; // zorgen dat bij geen signaal u = 0
-
// Op deze manier worden de waardes ingelezen in Filter. Zorg dus voor dezelfde volgorde, zodat de waardes goed uitgelezen worden!:
// 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)
@@ -75,14 +50,8 @@
double y50a = Filter(u, v1_50a, v2_50a, a1_50a, a2_50a, b0_50a, b1_50a, b2_50a, gain_50a);
double y50b = Filter(y50a, v1_50b, v2_50b, a1_50b, a2_50b, b0_50b, b1_50b, b2_50b, gain_50b);
- // 0-20Hz Notch filter
- double y020a = Filter(y50a, v1_020a, v2_020a, a1_020a, a2_020a, b0_020a, b1_020a, b2_020a, gain_020a);
- double y020b = Filter(y020a, v1_020b, v2_020b, a1_020b, a2_020b, b0_020b, b1_020b, b2_020b, gain_020b);
- double y020c = Filter(y020b, v1_020c, v2_020c, a1_020c, a2_020c, b0_020c, b1_020c, b2_020c, gain_020c);
-
-
// High Pass filter. Tot 20Hz wordt weggefliterd
- double yHP = Filter(y020c, v1_HP, v2_HP, a1_HP, a2_HP, b0_HP, b1_HP, b2_HP, gain_HP);
+ double yHP = Filter(u, v1_HP, v2_HP, a1_HP, a2_HP, b0_HP, b1_HP, b2_HP, gain_HP);
// Absolute waarde wordt genomen.
double y1 = fabs(yHP);
--- a/Kalibratie.cpp Wed Oct 14 12:36:42 2015 +0000
+++ b/Kalibratie.cpp Wed Oct 14 14:49:47 2015 +0000
@@ -57,7 +57,7 @@
}
else {
}
- pc2.printf("y = %f en ymax = %f \n",y,ymin); //bugfix
+ pc2.printf("y = %f en ymin = %f \n",y,ymin); //bugfix
}
Timermin.stop();
--- a/main.cpp Wed Oct 14 12:36:42 2015 +0000
+++ b/main.cpp Wed Oct 14 14:49:47 2015 +0000
@@ -33,9 +33,9 @@
ymax = KalibratieMax(readymax);
// bepalen van thresholds voor aan/uit
- thresholdlow = 0.2; // standaardwaarde
+ thresholdlow = 10 * ymin; // standaardwaarde
thresholdmid = 0.5 * ymax; // afhankelijk van max output gebruiker
- thresholdhigh = 0.9 * ymax;
+ thresholdhigh = 0.8 * ymax;
}
void EMGfilter()
