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
Diff: Kalibratie.cpp
- Revision:
- 50:16314b798754
- Parent:
- 44:97f5622db2c4
- Child:
- 51:dcbfdf3b9468
diff -r b571c822c3f9 -r 16314b798754 Kalibratie.cpp --- a/Kalibratie.cpp Tue Oct 27 12:01:44 2015 +0000 +++ b/Kalibratie.cpp Wed Oct 28 09:28:48 2015 +0000 @@ -1,54 +1,39 @@ #include "Kalibratie.h" #include "Filterdesigns.h" -/* -DigitalOut LedGreen(LED2); -DigitalOut LedRed(LED1); -*/ + int samples = 100; // amount of samples taken -/* -void Init(){ - LedGreen = 1; - LedRed = 1; -}*/ - -double KalibratieMax(AnalogIn& emg, bool side){ //Kalibratie van de maximum waarde - //LedGreen.write(0); //Led aan +double KalibratieMax(AnalogIn& emg, bool side){ //Calibration max value (contracted) double ymax = 0; for(int i = 1; i <= samples; i++) { //amount of samples double u = emg.read(); double y = 0; - if(side){ // links + if(side){ // left EMG filter values y = FilterdesignsLeft(u); } else { - y = FilterdesignsRight(u); // rechts + y = FilterdesignsRight(u); // right EMG filter values } - if (y > ymax && i >= samples / 10) { //Als de gemeten waarde groter is dan de opgeslagen waarde wordt dit de nieuwe opgeslagen waarde + if (y > ymax && i >= samples / 10) { //Check on maximum, not first 10 samples (offset) ymax = y; - } - wait(0.05); - } - //LedGreen.write(1); //Led aan + } + } return ymax; } -double KalibratieMin(AnalogIn& emg, bool side){ //Kalibratie van de minimum waarde - //LedRed.write(0); +double KalibratieMin(AnalogIn& emg, bool side){ //Calibration min value (relaxed) double ymin = 10; for(int i = 1; i <= samples; i++) { double u = emg.read(); double y = 0; - if(side){ // links + if(side){ // left EMG values y = FilterdesignsLeft(u); } else { - y = FilterdesignsRight(u); // rechts + y = FilterdesignsRight(u); // right EMG values } - if (y < ymin && i >= samples / 10) { + if (y < ymin && i >= samples / 10) { // not first 10 samples (offset) ymin = y; - } - wait(0.05); - } - //LedRed.write(1); + } + } return ymin; } \ No newline at end of file