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
Kalibratie.cpp@51:dcbfdf3b9468, 2015-10-28 (annotated)
- Committer:
- RemcoDas
- Date:
- Wed Oct 28 12:47:38 2015 +0000
- Revision:
- 51:dcbfdf3b9468
- Parent:
- 50:16314b798754
Faal
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Bartvaart | 16:8f175d2a472f | 1 | #include "Kalibratie.h" |
Bartvaart | 17:cfe44346645c | 2 | #include "Filterdesigns.h" |
RemcoDas | 50:16314b798754 | 3 | |
RemcoDas | 41:91c8c39d7a33 | 4 | int samples = 100; // amount of samples taken |
RemcoDas | 50:16314b798754 | 5 | double KalibratieMax(AnalogIn& emg, bool side){ //Calibration max value (contracted) |
RemcoDas | 41:91c8c39d7a33 | 6 | double ymax = 0; |
RemcoDas | 41:91c8c39d7a33 | 7 | for(int i = 1; i <= samples; i++) { //amount of samples |
RemcoDas | 25:c97d079e07f3 | 8 | double u = emg.read(); |
RemcoDas | 30:8ae855348d22 | 9 | double y = 0; |
RemcoDas | 50:16314b798754 | 10 | if(side){ // left EMG filter values |
RemcoDas | 30:8ae855348d22 | 11 | y = FilterdesignsLeft(u); |
RemcoDas | 30:8ae855348d22 | 12 | } |
RemcoDas | 30:8ae855348d22 | 13 | else { |
RemcoDas | 50:16314b798754 | 14 | y = FilterdesignsRight(u); // right EMG filter values |
RemcoDas | 30:8ae855348d22 | 15 | } |
RemcoDas | 50:16314b798754 | 16 | if (y > ymax && i >= samples / 10) { //Check on maximum, not first 10 samples (offset) |
Bartvaart | 17:cfe44346645c | 17 | ymax = y; |
RemcoDas | 51:dcbfdf3b9468 | 18 | } |
RemcoDas | 51:dcbfdf3b9468 | 19 | wait(0.05); |
RemcoDas | 50:16314b798754 | 20 | } |
Bartvaart | 17:cfe44346645c | 21 | return ymax; |
RemcoDas | 27:f62e450bb411 | 22 | } |
Bartvaart | 17:cfe44346645c | 23 | |
RemcoDas | 50:16314b798754 | 24 | double KalibratieMin(AnalogIn& emg, bool side){ //Calibration min value (relaxed) |
Bartvaart | 17:cfe44346645c | 25 | double ymin = 10; |
Bartvaart | 22:c1811e60bfce | 26 | for(int i = 1; i <= samples; i++) { |
RemcoDas | 26:d9855716ced7 | 27 | double u = emg.read(); |
RemcoDas | 30:8ae855348d22 | 28 | double y = 0; |
RemcoDas | 50:16314b798754 | 29 | if(side){ // left EMG values |
RemcoDas | 30:8ae855348d22 | 30 | y = FilterdesignsLeft(u); |
RemcoDas | 30:8ae855348d22 | 31 | } |
RemcoDas | 30:8ae855348d22 | 32 | else { |
RemcoDas | 50:16314b798754 | 33 | y = FilterdesignsRight(u); // right EMG values |
RemcoDas | 41:91c8c39d7a33 | 34 | } |
RemcoDas | 50:16314b798754 | 35 | if (y < ymin && i >= samples / 10) { // not first 10 samples (offset) |
Bartvaart | 17:cfe44346645c | 36 | ymin = y; |
RemcoDas | 51:dcbfdf3b9468 | 37 | } |
RemcoDas | 51:dcbfdf3b9468 | 38 | wait(0.05); |
RemcoDas | 50:16314b798754 | 39 | } |
Bartvaart | 17:cfe44346645c | 40 | return ymin; |
Bartvaart | 17:cfe44346645c | 41 | } |