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@27:f62e450bb411, 2015-10-16 (annotated)
- Committer:
- RemcoDas
- Date:
- Fri Oct 16 12:37:26 2015 +0000
- Revision:
- 27:f62e450bb411
- Parent:
- 26:d9855716ced7
- Child:
- 30:8ae855348d22
Dubbele kalibratie toegevoegd
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" |
Bartvaart | 22:c1811e60bfce | 3 | //#include "MODSERIAL.h" //bugfix |
Bartvaart | 17:cfe44346645c | 4 | |
RemcoDas | 25:c97d079e07f3 | 5 | //AnalogIn emg2(A0); //Analog input van emg kabels |
Bartvaart | 22:c1811e60bfce | 6 | //MODSERIAL pc2(USBTX, USBRX); //bugfix |
Bartvaart | 22:c1811e60bfce | 7 | DigitalOut LedGreen(LED2); |
Bartvaart | 22:c1811e60bfce | 8 | DigitalOut LedRed(LED1); |
Bartvaart | 22:c1811e60bfce | 9 | |
Bartvaart | 22:c1811e60bfce | 10 | int samples = 100; |
Bartvaart | 17:cfe44346645c | 11 | |
RemcoDas | 25:c97d079e07f3 | 12 | void Init(){ |
Bartvaart | 17:cfe44346645c | 13 | LedGreen = 1; |
Bartvaart | 17:cfe44346645c | 14 | LedRed = 1; |
Bartvaart | 17:cfe44346645c | 15 | } |
Bartvaart | 17:cfe44346645c | 16 | |
RemcoDas | 25:c97d079e07f3 | 17 | double KalibratieMax(AnalogIn& emg){ //Kalibratie van de maximum waarde |
Bartvaart | 17:cfe44346645c | 18 | LedGreen.write(0); //Led aan |
Bartvaart | 17:cfe44346645c | 19 | double ymax = 0; |
RemcoDas | 25:c97d079e07f3 | 20 | |
RemcoDas | 24:ddd69385b55f | 21 | for(int i = 1; i <= samples; i++) { //Als timer onder de 5 seconden is dit uitvoeren |
RemcoDas | 25:c97d079e07f3 | 22 | double u = emg.read(); |
RemcoDas | 25:c97d079e07f3 | 23 | double y = Filterdesigns(u); |
RemcoDas | 24:ddd69385b55f | 24 | |
Bartvaart | 22:c1811e60bfce | 25 | 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 | 26 | ymax = y; |
RemcoDas | 25:c97d079e07f3 | 27 | } |
Bartvaart | 22:c1811e60bfce | 28 | wait(0.05); |
RemcoDas | 27:f62e450bb411 | 29 | } |
RemcoDas | 25:c97d079e07f3 | 30 | LedGreen.write(1); //Led aan |
Bartvaart | 17:cfe44346645c | 31 | return ymax; |
RemcoDas | 27:f62e450bb411 | 32 | } |
Bartvaart | 17:cfe44346645c | 33 | |
RemcoDas | 25:c97d079e07f3 | 34 | double KalibratieMin(AnalogIn& emg){ //Kalibratie van de minimum waarde |
Bartvaart | 17:cfe44346645c | 35 | LedRed.write(0); |
Bartvaart | 17:cfe44346645c | 36 | double ymin = 10; |
Bartvaart | 17:cfe44346645c | 37 | |
Bartvaart | 22:c1811e60bfce | 38 | for(int i = 1; i <= samples; i++) { |
RemcoDas | 26:d9855716ced7 | 39 | double u = emg.read(); |
Bartvaart | 20:11e1244ad2ad | 40 | double y = Filterdesigns(u); |
Bartvaart | 17:cfe44346645c | 41 | |
Bartvaart | 22:c1811e60bfce | 42 | if (y < ymin && i >= samples / 10) { |
Bartvaart | 17:cfe44346645c | 43 | ymin = y; |
RemcoDas | 25:c97d079e07f3 | 44 | } |
Bartvaart | 22:c1811e60bfce | 45 | wait(0.05); |
RemcoDas | 25:c97d079e07f3 | 46 | } |
Bartvaart | 17:cfe44346645c | 47 | LedRed.write(1); |
Bartvaart | 17:cfe44346645c | 48 | return ymin; |
Bartvaart | 17:cfe44346645c | 49 | } |