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@41:91c8c39d7a33, 2015-10-22 (annotated)
- Committer:
- RemcoDas
- Date:
- Thu Oct 22 08:07:27 2015 +0000
- Revision:
- 41:91c8c39d7a33
- Parent:
- 30:8ae855348d22
- Child:
- 44:97f5622db2c4
Werkend, met killswitch als analogin;
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 | 41:91c8c39d7a33 | 3 | /* |
Bartvaart | 22:c1811e60bfce | 4 | DigitalOut LedGreen(LED2); |
Bartvaart | 22:c1811e60bfce | 5 | DigitalOut LedRed(LED1); |
RemcoDas | 41:91c8c39d7a33 | 6 | */ |
RemcoDas | 41:91c8c39d7a33 | 7 | int samples = 100; // amount of samples taken |
RemcoDas | 41:91c8c39d7a33 | 8 | /* |
RemcoDas | 25:c97d079e07f3 | 9 | void Init(){ |
Bartvaart | 17:cfe44346645c | 10 | LedGreen = 1; |
Bartvaart | 17:cfe44346645c | 11 | LedRed = 1; |
RemcoDas | 41:91c8c39d7a33 | 12 | }*/ |
Bartvaart | 17:cfe44346645c | 13 | |
RemcoDas | 30:8ae855348d22 | 14 | double KalibratieMax(AnalogIn& emg, bool side){ //Kalibratie van de maximum waarde |
RemcoDas | 41:91c8c39d7a33 | 15 | //LedGreen.write(0); //Led aan |
RemcoDas | 41:91c8c39d7a33 | 16 | double ymax = 0; |
RemcoDas | 41:91c8c39d7a33 | 17 | for(int i = 1; i <= samples; i++) { //amount of samples |
RemcoDas | 25:c97d079e07f3 | 18 | double u = emg.read(); |
RemcoDas | 30:8ae855348d22 | 19 | double y = 0; |
RemcoDas | 30:8ae855348d22 | 20 | if(side){ // links |
RemcoDas | 30:8ae855348d22 | 21 | y = FilterdesignsLeft(u); |
RemcoDas | 30:8ae855348d22 | 22 | } |
RemcoDas | 30:8ae855348d22 | 23 | else { |
RemcoDas | 30:8ae855348d22 | 24 | y = FilterdesignsRight(u); // rechts |
RemcoDas | 30:8ae855348d22 | 25 | } |
Bartvaart | 22:c1811e60bfce | 26 | if (y > ymax && i >= samples / 10) { //Als de gemeten waarde groter is dan de opgeslagen waarde wordt dit de nieuwe opgeslagen waarde |
Bartvaart | 17:cfe44346645c | 27 | ymax = y; |
RemcoDas | 25:c97d079e07f3 | 28 | } |
Bartvaart | 22:c1811e60bfce | 29 | wait(0.05); |
RemcoDas | 27:f62e450bb411 | 30 | } |
RemcoDas | 25:c97d079e07f3 | 31 | LedGreen.write(1); //Led aan |
Bartvaart | 17:cfe44346645c | 32 | return ymax; |
RemcoDas | 27:f62e450bb411 | 33 | } |
Bartvaart | 17:cfe44346645c | 34 | |
RemcoDas | 30:8ae855348d22 | 35 | double KalibratieMin(AnalogIn& emg, bool side){ //Kalibratie van de minimum waarde |
RemcoDas | 41:91c8c39d7a33 | 36 | //LedRed.write(0); |
Bartvaart | 17:cfe44346645c | 37 | double ymin = 10; |
Bartvaart | 22:c1811e60bfce | 38 | for(int i = 1; i <= samples; i++) { |
RemcoDas | 26:d9855716ced7 | 39 | double u = emg.read(); |
RemcoDas | 30:8ae855348d22 | 40 | double y = 0; |
RemcoDas | 30:8ae855348d22 | 41 | if(side){ // links |
RemcoDas | 30:8ae855348d22 | 42 | y = FilterdesignsLeft(u); |
RemcoDas | 30:8ae855348d22 | 43 | } |
RemcoDas | 30:8ae855348d22 | 44 | else { |
RemcoDas | 30:8ae855348d22 | 45 | y = FilterdesignsRight(u); // rechts |
RemcoDas | 41:91c8c39d7a33 | 46 | } |
Bartvaart | 22:c1811e60bfce | 47 | if (y < ymin && i >= samples / 10) { |
Bartvaart | 17:cfe44346645c | 48 | ymin = y; |
RemcoDas | 25:c97d079e07f3 | 49 | } |
Bartvaart | 22:c1811e60bfce | 50 | wait(0.05); |
RemcoDas | 25:c97d079e07f3 | 51 | } |
RemcoDas | 41:91c8c39d7a33 | 52 | //LedRed.write(1); |
Bartvaart | 17:cfe44346645c | 53 | return ymin; |
Bartvaart | 17:cfe44346645c | 54 | } |