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 biquadFilter mbed
Fork of EMG_totaal by
Revision 30:29c9e9d0e398, committed 2015-10-15
- Comitter:
- Margreeth95
- Date:
- Thu Oct 15 12:56:45 2015 +0000
- Parent:
- 29:c43e9f78db37
- Child:
- 31:a17c20e0614e
- Commit message:
- Werkend systeem met dubbele threshold, voor beide armen. Goede user interface
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Oct 15 10:54:01 2015 +0000
+++ b/main.cpp Thu Oct 15 12:56:45 2015 +0000
@@ -12,9 +12,10 @@
Ticker serial;
Ticker MovingAverageLeft;
Ticker MovingAverageRight;
- HIDScope scope(6);
+ HIDScope scope(3);
DigitalOut led(LED_RED);
DigitalOut ledG(LED_GREEN);
+ DigitalOut ledB(LED_BLUE);
MODSERIAL pc(USBTX, USBRX);
@@ -33,7 +34,9 @@
double EMG_right_f3;
double EMG_right_abs;
double Threshold1;
- double Threshold2 = 0.06;
+ double Threshold2;
+ double Threshold3;
+ double Threshold4;
int N = 50;
double MAF_left[50];
@@ -102,12 +105,9 @@
// HIDScope
void ScopeSend()
{
- scope.set(0, EMG_left_value);
- scope.set(1, EMG_left_f1);
- scope.set(2, EMG_left_abs);
- scope.set(3, EMG_left_f2);
- scope.set(4, EMG_left_f3);
- scope.set(5, EMG_left_MAF);
+ scope.set(0, EMG_left_MAF);
+ scope.set(1, Threshold1);
+ scope.set(2, Threshold2);
scope.send();
}
@@ -121,17 +121,53 @@
MovingAverageRight.attach(&MovingAverageFilterRight, 0.005);
pc.baud(115200);
+ ledG.write(1), led.write(1), ledB.write(1);
+ wait(20);
+
ledG.write(1);
- wait(20);
+ wait(0.2);
+ ledG.write(0);
+ wait(0.2);
+ ledG.write(1);
+ wait(0.2);
+ ledG.write(0);
+ wait(0.2);
+ ledG.write(1);
+ wait(0.2);
ledG.write(0);
wait(2);
- Threshold1 = 0.75*EMG_left_MAF;
- pc.printf("%f\n", Threshold1);
+ Threshold1 = 0.5*EMG_left_MAF;
+ Threshold2 = 0.2*EMG_left_MAF;
+ ledG.write(1);
+
+ wait(2);
+ ledB.write(1);
+ wait(0.2);
+ ledB.write(0);
+ wait(0.2);
+ ledB.write(1);
+ wait(0.2);
+ ledB.write(0);
+ wait(0.2);
+ ledB.write(1);
+ wait(0.2);
+ ledB.write(0);
+ wait(2);
+ Threshold3 = 0.5*EMG_right_MAF;
+ Threshold4 = 0.2*EMG_right_MAF;
+ ledB.write(1);
+
+ pc.printf("T1 = %f, T2 = %f, T3 = %f, T4 = %f\n", Threshold1, Threshold2, Threshold3, Threshold4);
ledG.write(1);
while(1)
{
- if (EMG_left_f3 > Threshold1)
+ if (EMG_left_MAF > Threshold1)
+ {
+ led.write(0);
+ }
+
+ else if((EMG_left_MAF > Threshold2) && (led == 0 ))
{
led.write(0);
}
