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 13:21:42 2014 +0000
Parent:
36:ccc901c169b7
Child:
38:017fd93e9efe
Commit message:
poging miljard

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Oct 28 12:47:57 2014 +0000
+++ b/main.cpp	Tue Oct 28 13:21:42 2014 +0000
@@ -173,198 +173,205 @@
 
     TouchButton TButton;
 
-    int key=0;
+    int key=0;//vraagt om calibratie
     key = TButton.PressedButton();
 
     pc.printf("key 1 calibratie triceps/n");
     pc.printf("key 2 caliratie biceps/n");
     pc.printf("key 3 START/n");
 
-    wait(3);
+    wait(5);
+
+    while(true) {
+        if (key==0) {
 
-    if (key==0) {
+            //niks
+            myled1 = 1;
+            myled2 = 1;
+            myled3 = 1;
+
+            pc.printf("moet eerst calibreren\n");
+        } else if (key==1) {
+
+            //rood
+            myled1 = 0;
+            myled2 = 1;
+            myled3 = 1;
 
-        //rood
-        myled1 = 0;
-        myled2 = 1;
-        myled3 = 1;
+            pc.printf("calibratie tricep aan\n");
+            wait(2);
+
+            Calibratie_Triceps();
+            drempelwaardeT=MOVAVG_T-1;
+            pc.printf("drempelwaarde triceps is %f\r\n", drempelwaardeT);
+            pc.printf("calibratie tricep klaar,\n");
+            wait(5);
+
+            //pc.printf("key 2 caliratie biceps/n");
+            //pc.printf("key 3 START/n");
+            //wait(5);
+
+        } else if (key==2) {
+
+            //green
+            myled1 = 1;
+            myled2 = 0;
+            myled3 = 1;
+            wait(0.1);
 
-        pc.printf("calibratie tricep aan\n");
-        Calibratie_Triceps();
-        drempelwaardeT=MOVAVG_T-1;
-        pc.printf("drempelwaarde triceps is %f\r\n", drempelwaardeT);
-        pc.printf("calibratie tricep klaar, accord? -> key 4 \n");
-        wait(5);
+            pc.printf("calibratie bicep snelheid 1 aan\n");
+            wait(2);
+
+            Calibratie_Biceps();
+            drempelwaardeB1=MOVAVG_B-1;
+            pc.printf("drempelwaarde snelheid 1 is %f\r\n", drempelwaardeB1);
+            wait(5);
+
+            pc.printf("calibratie bicep snelheid 2 aan\n");
+            wait(2);
 
-        if (key==3) {
+            Calibratie_Biceps();
+            drempelwaardeB2=MOVAVG_B-1;
+            pc.printf("drempelwaarde snelheid 2 is %f\r\n", drempelwaardeB2);
+            wait(5);
+
+            pc.printf("calibratie bicep snelheid 2 aan\n");
+            wait(2);
+
+            Calibratie_Biceps();
+            wait(2);
 
-            pc.printf("key 2 caliratie biceps/n");
-            pc.printf("key 3 START/n");
-            wait(3);
+            drempelwaardeB2=MOVAVG_B-1;
+            pc.printf("drempelwaarde snelheid 3 is %f\r\n", drempelwaardeB3);
+
+            pc.printf("caliratie biceps is klaar, accord? -> key 4/n");
 
-            if (key==1) {
+            wait(5);
+        } else if (key==3) {
+            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 {
 
-                //green
+                //blue
                 myled1 = 1;
-                myled2 = 0;
-                myled3 = 1;
+                myled2 = 1;
+                myled3 = 0;
                 wait(0.1);
 
-                pc.printf("calibratie bicep snelheid 1 aan\n");
-                Calibratie_Biceps();
-                drempelwaardeB1=MOVAVG_B-1;
-                pc.printf("drempelwaarde snelheid 1 is %f\r\n", drempelwaardeB1);
+                pc.printf("eerst positie dan snelheid aangeven/n");
+
+                //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);
+
+                log_timerT1.attach(Triceps, 0.005);
+                wait(10);
+                log_timerT1.detach();
+
+                MOVAVG_T=MOVAVG_Positie1;
+
+                // positie van batje met behulp van Triceps
+
+                if (MOVAVG_Positie1>= drempelwaardeT) {
+                    yT1=1;
+                } else {
+                    yT1=0;
+                }
+
+                pc.printf("Triceps eerste meting is klaar.\n");
                 wait(5);
 
-                pc.printf("calibratie bicep snelheid 2 aan\n");
-                Calibratie_Biceps();
-                drempelwaardeB2=MOVAVG_B-1;
-                pc.printf("drempelwaarde snelheid 2 is %f\r\n", drempelwaardeB2);
+                //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);
+
+                log_timerT2.attach(Triceps, 0.005);
                 wait(5);
+                log_timerT2.detach();
+
+                MOVAVG_T=MOVAVG_Positie2;
 
-                pc.printf("calibratie bicep snelheid 2 aan\n");
-                Calibratie_Biceps();
-                drempelwaardeB2=MOVAVG_B-1;
-                pc.printf("drempelwaarde snelheid 3 is %f\r\n", drempelwaardeB3);
+                if (MOVAVG_Positie2 >= drempelwaardeT) {
+                    yT2=1;
+                } else {
+                    yT2=0;
+                }
+
+                pc.printf("Triceps tweede meting is klaar.\n");
+
+                //*** INPUT MOTOR 2 ***
+                positie=yT1+yT2;
 
-                pc.printf("caliratie biceps is klaar, accord? -> key 4/n");
+                //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");
+                    } else {
+                        if (positie==2) {
+                            pc.printf("Motor 2 gaat naar stand 3\n");
+                        }
+                    }
+                }
 
                 wait(5);
 
-                if (key==3) {
-
-                    pc.printf("key 2 caliratie biceps/n");
-                    pc.printf("key 3 START/n");
-                    wait(3);
+                Ticker log_timerB;
 
-                    if (key==2) {
-                        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 {
-
-                            //blue
-                            myled1 = 1;
-                            myled2 = 1;
-                            myled3 = 0;
-                            wait(0.1);
-
-                            pc.printf("eerst positie dan snelheid aangeven/n");
-
-                            //bepaling van positie met triceps 1
-                            Ticker log_timerT1;
+                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(&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_timerT1.attach(Triceps, 0.005);
-                            wait(10);
-                            log_timerT1.detach();
-
-                            MOVAVG_T=MOVAVG_Positie1;
-
-                            // positie van batje met behulp van Triceps
+                log_timerB.attach(Biceps,0.005);
+                wait(5);
+                log_timerB.detach();
 
-                            if (MOVAVG_Positie1>= drempelwaardeT) {
-                                yT1=1;
-                            } else {
-                                yT1=0;
-                            }
-
-                            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);
-
-                            log_timerT2.attach(Triceps, 0.005);
-                            wait(5);
-                            log_timerT2.detach();
-
-                            MOVAVG_T=MOVAVG_Positie2;
+                //bepaling van snelheidsstand met biceps
 
-                            if (MOVAVG_Positie2 >= drempelwaardeT) {
-                                yT2=1;
-                            } else {
-                                yT2=0;
-                            }
-
-                            pc.printf("Triceps tweede meting is klaar.\n");
-
-                            //*** 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");
-                                } else {
-                                    if (positie==2) {
-                                        pc.printf("Motor 2 gaat naar stand 3\n");
-                                    }
-                                }
-                            }
-
-                            wait(5);
-
-                            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);
-
-                            log_timerB.attach(Biceps,0.005);
-                            wait(5);
-                            log_timerB.detach();
+                if (MOVAVG_B >= drempelwaardeB1) {
+                    yB1=1;
+                    if (MOVAVG_B >= drempelwaardeB2) {
+                        yB2=1;
+                        if (MOVAVG_B >= drempelwaardeB3) {
+                            yB3=1;
+                        } else {
+                            yB3=0;
+                        }
+                    } else {
+                        yB2=0;
+                    }
+                } else {
+                    yB1=0;
+                }
 
-                            //bepaling van snelheidsstand met biceps
-
-                            if (MOVAVG_B >= drempelwaardeB1) {
-                                yB1=1;
-                                if (MOVAVG_B >= drempelwaardeB2) {
-                                    yB2=1;
-                                    if (MOVAVG_B >= drempelwaardeB3) {
-                                        yB3=1;
-                                    } else {
-                                        yB3=0;
-                                    }
-                                } else {
-                                    yB2=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");
-                                } else {
-                                    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");
-                                        }
-                                    }
-                                }
+                //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");
+                    } else {
+                        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");
                             }
                         }
                     }
@@ -372,7 +379,4 @@
             }
         }
     }
-}
-
-
-
+}
\ No newline at end of file