Filter emg 7-10-15 v1
Dependencies: HIDScope mbed MODSERIAL
Revision 24:38cd27737a43, committed 2016-10-12
- Comitter:
- Bartvaart
- Date:
- Wed Oct 12 15:31:14 2016 +0000
- Parent:
- 23:855c4bcb2284
- Commit message:
- andries
Changed in this revision
diff -r 855c4bcb2284 -r 38cd27737a43 Filterdesigns.cpp --- a/Filterdesigns.cpp Thu Oct 15 10:16:44 2015 +0000 +++ b/Filterdesigns.cpp Wed Oct 12 15:31:14 2016 +0000 @@ -51,7 +51,7 @@ double y50b = Filter(y50a, v1_50b, v2_50b, a1_50b, a2_50b, b0_50b, b1_50b, b2_50b, gain_50b); // High Pass filter. Tot 20Hz wordt weggefliterd - double yHP = Filter(u, v1_HP, v2_HP, a1_HP, a2_HP, b0_HP, b1_HP, b2_HP, gain_HP); + double yHP = Filter(y50b, v1_HP, v2_HP, a1_HP, a2_HP, b0_HP, b1_HP, b2_HP, gain_HP); // Absolute waarde wordt genomen. double y1 = fabs(yHP);
diff -r 855c4bcb2284 -r 38cd27737a43 Kalibratie.cpp --- a/Kalibratie.cpp Thu Oct 15 10:16:44 2015 +0000 +++ b/Kalibratie.cpp Wed Oct 12 15:31:14 2016 +0000 @@ -2,7 +2,7 @@ #include "Filterdesigns.h" //#include "MODSERIAL.h" //bugfix -AnalogIn emg2(A0); //Analog input van emg kabels +//AnalogIn emg2(A0); //Analog input van emg kabels niet meer nodig //MODSERIAL pc2(USBTX, USBRX); //bugfix DigitalOut LedGreen(LED2); DigitalOut LedRed(LED1); @@ -15,14 +15,14 @@ LedRed = 1; } -double KalibratieMax(bool &readymax) //Kalibratie van de maximum waarde +double KalibratieMax(bool &readymax, AnalogIn emg) //Kalibratie van de maximum waarde { //pc2.baud(115200); LedGreen.write(0); //Led aan double ymax = 0; for(int i = 1; i <= samples; i++) { //Als timer onder de 5 seconden is dit uitvoeren - double u = emg2.read(); + double u = emg.read(); double y = Filterdesigns(u); if (y > ymax && i >= samples / 10) { //Als de gemeten waarde groter is dan de opgeslagen waarde wordt dit de nieuwe opgeslagen waarde @@ -38,14 +38,14 @@ return ymax; } -double KalibratieMin(bool &readymin) //Kalibratie van de minimum waarde +double KalibratieMin(bool &readymin, AnalogIn emg) //Kalibratie van de minimum waarde { //pc2.baud(115200); LedRed.write(0); double ymin = 10; for(int i = 1; i <= samples; i++) { - double u = emg2.read(); + double u = emg.read(); double y = Filterdesigns(u); if (y < ymin && i >= samples / 10) {
diff -r 855c4bcb2284 -r 38cd27737a43 Kalibratie.h --- a/Kalibratie.h Thu Oct 15 10:16:44 2015 +0000 +++ b/Kalibratie.h Wed Oct 12 15:31:14 2016 +0000 @@ -1,7 +1,7 @@ #include "mbed.h" -double KalibratieMax(bool &readymax); +double KalibratieMax(bool &readymax, AnalogIn emg); -double KalibratieMin(bool &readymin); +double KalibratieMin(bool &readymin, AnalogIn emg); void Init(); \ No newline at end of file
diff -r 855c4bcb2284 -r 38cd27737a43 main.cpp --- a/main.cpp Thu Oct 15 10:16:44 2015 +0000 +++ b/main.cpp Wed Oct 12 15:31:14 2016 +0000 @@ -29,9 +29,9 @@ { LedBlue = 1; Init(); - ymin = KalibratieMin(readymin); + ymin = KalibratieMin(readymin, emg); wait(1); - ymax = KalibratieMax(readymax); + ymax = KalibratieMax(readymax, emg); // bepalen van thresholds voor aan/uit thresholdlow = 8 * ymin; // standaardwaarde