emg

Dependencies:   HIDScope MODSERIAL mbed-dsp mbed TouchButton

Fork of test by BMT M9 Groep01

Files at this revision

API Documentation at this revision

Comitter:
s1340735
Date:
Tue Oct 28 10:46:48 2014 +0000
Parent:
33:bc0abe29bad1
Child:
35:e60f09b575d7
Commit message:
initial drempelwaarde toegevoegd

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Oct 28 10:28:30 2014 +0000
+++ b/main.cpp	Tue Oct 28 10:46:48 2014 +0000
@@ -25,7 +25,7 @@
 * key 1 will light Red LED                  -> CALIBRATIE TRICEPS
 * key 2 will light Green LED                -> CALIBRATIE BICEPS
 * key 3 will light Blue LED                 -> START
-* key 4 will light White LED (R+G+B)        -> ?
+* key 4 will light White LED (R+G+B)        -> ?ONBEKEND
 */
 
 //*** OBJECTS ***
@@ -70,6 +70,7 @@
 
 
 // *** TRICEPS en BICEPS EMG ***
+
 void Triceps()
 {
     //Triceps lezen
@@ -157,7 +158,7 @@
     arm_biquad_cascade_df1_init_f32(&highpassT,1,highpass_const,highpass_states);
 
     log_timerB.attach(Biceps, 0.005);
-    wait(3);
+    wait(5);
     log_timerB.detach();
 }
 
@@ -170,6 +171,11 @@
 
     int key=0;
 
+    drempelwaardeT=0;
+    drempelwaardeB1=0;
+    drempelwaardeB2=0;
+    drempelwaardeB3=0;
+    
     key = TButton.PresedButton();
 
     pc.printf("key 1 calibratie triceps/n");
@@ -219,119 +225,129 @@
             pc.printf("caliratie biceps is klaar/n");
 
         } else if (key==2) {
-            myled1 = 1;
-            myled2 = 0;
-            myled3 = 1;
-            wait(0.1);
-
-            pc.printf("eerst positie dan snelheid aangeven/n");
+            if (drempelwaardeT==0) {
+                pc.printf("voer calibratie triceps uit");
+            } else if (drempelwaardeB1==0) {
+                pc.printf("voer calibratie biceps uit");
+            } else if (drempelwaardeB2==0) {
+                pc.printf("voer calibratie biceps uit");
+            } else if (drempelwaardeB3==0) {
+                pc.printf("voer calibratie biceps uit");
+            } else {
+                myled1 = 1;
+                myled2 = 0;
+                myled3 = 1;
+                wait(0.1);
 
-            //bepaling van positie met triceps 1
-            Ticker log_timerT1;
-
-            arm_biquad_cascade_df1_init_f32(&notchT,1,notch_const,notch_states);
-            arm_biquad_cascade_df1_init_f32(&lowpassT,1,lowpass_const,lowpass_states);
-            arm_biquad_cascade_df1_init_f32(&highpassT,1,highpass_const,highpass_states);
+                pc.printf("eerst positie dan snelheid aangeven/n");
 
-            log_timerT1.attach(Triceps, 0.005);
-            wait(10);
-            log_timerT1.detach();
+                //bepaling van positie met triceps 1
+                Ticker log_timerT1;
 
-            MOVAVG_T=MOVAVG_Positie1;
-
-            // positie van batje met behulp van Triceps
+                arm_biquad_cascade_df1_init_f32(&notchT,1,notch_const,notch_states);
+                arm_biquad_cascade_df1_init_f32(&lowpassT,1,lowpass_const,lowpass_states);
+                arm_biquad_cascade_df1_init_f32(&highpassT,1,highpass_const,highpass_states);
 
-            if (MOVAVG_Positie1>= drempelwaardeT) {
-                yT1=1;
-            } else {
-                yT1=0;
-            }
+                log_timerT1.attach(Triceps, 0.005);
+                wait(10);
+                log_timerT1.detach();
+
+                MOVAVG_T=MOVAVG_Positie1;
 
-            pc.printf("Triceps eerste meting is klaar.\n");
-            wait(5);
+                // positie van batje met behulp van Triceps
+
+                if (MOVAVG_Positie1>= drempelwaardeT) {
+                    yT1=1;
+                } else {
+                    yT1=0;
+                }
 
-            //bepaling van positie met tricep 2
-            Ticker log_timerT2;
+                pc.printf("Triceps eerste meting is klaar.\n");
+                wait(5);
+
+                //bepaling van positie met tricep 2
+                Ticker log_timerT2;
 
-            arm_biquad_cascade_df1_init_f32(&notchT,1,notch_const,notch_states);
-            arm_biquad_cascade_df1_init_f32(&lowpassT,1,lowpass_const,lowpass_states);
-            arm_biquad_cascade_df1_init_f32(&highpassT,1,highpass_const,highpass_states);
+                arm_biquad_cascade_df1_init_f32(&notchT,1,notch_const,notch_states);
+                arm_biquad_cascade_df1_init_f32(&lowpassT,1,lowpass_const,lowpass_states);
+                arm_biquad_cascade_df1_init_f32(&highpassT,1,highpass_const,highpass_states);
 
-            log_timerT2.attach(Triceps, 0.005);
-            wait(5);
-            log_timerT2.detach();
+                log_timerT2.attach(Triceps, 0.005);
+                wait(5);
+                log_timerT2.detach();
 
-            MOVAVG_T=MOVAVG_Positie2;
+                MOVAVG_T=MOVAVG_Positie2;
 
-            if (MOVAVG_Positie2 >= drempelwaardeT) {
-                yT2=1;
-            } else {
-                yT2=0;
-            }
+                if (MOVAVG_Positie2 >= drempelwaardeT) {
+                    yT2=1;
+                } else {
+                    yT2=0;
+                }
 
-            pc.printf("Triceps tweede meting is klaar.\n");
+                pc.printf("Triceps tweede meting is klaar.\n");
+
+                //*** INPUT MOTOR 2 ***
+                positie=yT1+yT2;
 
-            //*** INPUT MOTOR 2 ***
-            positie=yT1+yT2;
-
-            //controle positie op scherm
-            if (positie==0) {
-                pc.printf("Motor 2 blijft op stand 1\n");
-            } else {
-                if (positie==1) {
-                    pc.printf("Motor 2 gaat naar stand 2\n");
+                //controle positie op scherm
+                if (positie==0) {
+                    pc.printf("Motor 2 blijft op stand 1\n");
                 } else {
-                    if (positie==2) {
-                        pc.printf("Motor 2 gaat naar stand 3\n");
+                    if (positie==1) {
+                        pc.printf("Motor 2 gaat naar stand 2\n");
+                    } else {
+                        if (positie==2) {
+                            pc.printf("Motor 2 gaat naar stand 3\n");
+                        }
                     }
                 }
-            }
 
-            wait(5);
+                wait(5);
+
+                Ticker log_timerB;
 
-            Ticker log_timerB;
+                arm_biquad_cascade_df1_init_f32(&notchB,1,notch_const,notch_states);
+                arm_biquad_cascade_df1_init_f32(&lowpassB,1,lowpass_const,lowpass_states);
+                arm_biquad_cascade_df1_init_f32(&highpassB,1,highpass_const,highpass_states);
 
-            arm_biquad_cascade_df1_init_f32(&notchB,1,notch_const,notch_states);
-            arm_biquad_cascade_df1_init_f32(&lowpassB,1,lowpass_const,lowpass_states);
-            arm_biquad_cascade_df1_init_f32(&highpassB,1,highpass_const,highpass_states);
+                log_timerB.attach(Biceps,0.005);
+                wait(5);
+                log_timerB.detach();
 
-            log_timerB.attach(Biceps,0.005);
-            wait(5);
-            log_timerB.detach();
-
-            //bepaling van snelheidsstand met biceps
+                //bepaling van snelheidsstand met biceps
 
-            if (MOVAVG_B >= drempelwaardeB1) {
-                yB1=1;
-                if (MOVAVG_B >= drempelwaardeB2) {
-                    yB2=1;
-                    if (MOVAVG_B >= drempelwaardeB3) {
-                        yB3=1;
+                if (MOVAVG_B >= drempelwaardeB1) {
+                    yB1=1;
+                    if (MOVAVG_B >= drempelwaardeB2) {
+                        yB2=1;
+                        if (MOVAVG_B >= drempelwaardeB3) {
+                            yB3=1;
+                        } else {
+                            yB3=0;
+                        }
                     } else {
-                        yB3=0;
+                        yB2=0;
                     }
                 } else {
-                    yB2=0;
+                    yB1=0;
                 }
-            } else {
-                yB1=0;
-            }
 
-            //*** INPUT MOTOR 1 ***
-            snelheidsstand=yB1+yB2+yB3;
+                //*** INPUT MOTOR 1 ***
+                snelheidsstand=yB1+yB2+yB3;
 
-            //controle snelheidsstand op scherm
-            if (snelheidsstand==0) {
-                pc.printf("Motor 1 beweegt niet\n");
-            } else {
-                if (snelheidsstand==1) {
-                    pc.printf("Motor 1 beweegt met snelheid 1\n");
+                //controle snelheidsstand op scherm
+                if (snelheidsstand==0) {
+                    pc.printf("Motor 1 beweegt niet\n");
                 } else {
-                    if (snelheidsstand==2) {
-                        pc.printf("Motor 1 beweegt met snelheid 2\n");
+                    if (snelheidsstand==1) {
+                        pc.printf("Motor 1 beweegt met snelheid 1\n");
                     } else {
-                        if (snelheidsstand==3) {
-                            pc.printf("Motor 1 beweegt met snelheid 3\n");
+                        if (snelheidsstand==2) {
+                            pc.printf("Motor 1 beweegt met snelheid 2\n");
+                        } else {
+                            if (snelheidsstand==3) {
+                                pc.printf("Motor 1 beweegt met snelheid 3\n");
+                            }
                         }
                     }
                 }