groep 16 / Mbed 2 deprecated Project_BioRobotics_12

Dependencies:   mbed QEI HIDScope BiQuad4th_order biquadFilter MODSERIAL FastPWM

Revision:
4:a0c1c021026b
Parent:
3:dca57056e5cb
Child:
5:07e401cb251d
--- a/main.cpp	Mon Oct 22 14:45:37 2018 +0000
+++ b/main.cpp	Mon Oct 22 15:01:01 2018 +0000
@@ -8,7 +8,7 @@
 InterruptIn Fail_button(SW3);
 MODSERIAL pc(USBTX, USBRX);
 
-enum states {WAITING,MOTOR_ANGLE_CLBRT,EMG_CLBRT,HOMING,WAITING4SIGNAL,MOVE_W_EMG,MOVE_W_DEMO,FAILURE_MODE,SHUTDOWN};
+enum states {WAITING, MOTOR_ANGLE_CLBRT, EMG_CLBRT, HOMING, WAITING4SIGNAL, MOVE_W_EMG, MOVE_W_DEMO, FAILURE_MODE, SHUTDOWN};
 states currentState = WAITING;
 char c;
     
@@ -19,6 +19,7 @@
 
 int main()
 {
+    // Switch all LEDs off
     led_red = 1;
     led_green = 1;
     led_blue = 1;
@@ -38,29 +39,37 @@
                     }
                 wait(1.0f);
                 break;
+                
             case MOTOR_ANGLE_CLBRT:
                 pc.printf("Motor angle calibration \r\n");
                 led_red = 1; led_green = 0; led_blue = 0;   // Colouring the led TURQUOISE
-                wait(3.0f); // time_in_this_state > 3.0f
+                wait(3.0f);                                 // time_in_this_state > 3.0f
                 // if (fabs(motor_velocity) < 0.01f) {
+                // INSERT CALIBRATING
                 currentState = EMG_CLBRT;
                 break;
+                
             case EMG_CLBRT:
                 pc.printf("EMG calibration \r\n");
                 led_red = 1; led_green = 1; led_blue = 0;   // Colouring the led BLUE
                 wait(5.0f); // time_in_this_state > 5.0f
                 // if moving_average(procd_emg) < 0.1*max_procd_emg_ever
+                // INSERT CALIBRATING
                 currentState = HOMING;
-                break;                   
+                break;       
+                            
             case HOMING:
                 pc.printf("HOMING, moving to the home starting configuration. \r\n");
                 led_red = 0; led_green = 1; led_red = 0;                  // Colouring the led PURPLE
                 wait(5.0f); // time_in_this_state > 5.0f
                 // if ((fabs(angle_error1) < 0.01f) && (fabs(angle_error2) < 0.01f)) {
+                // INSERT MOVEMENT
                 currentState = WAITING4SIGNAL;
                 break;
+                
             case WAITING4SIGNAL:
                 led_red = 0; led_green = 0; led_blue = 0;                // Colouring the led WHITE
+                // CANNOT USE KEYBOARD. SO LOOK FOR ALTERNATIVE
                 pc.printf("Press d to run the demo, Press e to move with EMG, Press c to re-calibrate or Press s to shut the robot down. \r\n");
                 c = pc.getc();
                 if (c == 'd') {
@@ -76,9 +85,13 @@
                     currentState = SHUTDOWN;
                     }
                 break;
+                
+                
             case MOVE_W_DEMO:
                 led_red = 1; led_green = 1; led_blue = 0;   // Colouring the led GREEN
                 pc.printf("MOVE_W_DEMO, Running the demo \r\n");
+                // BUILD DEMO MODE
+                // FIND ALTERNATIVE FOR KEYBOARD
                 c = pc.getcNb();
                 if (c == 'h') {
                     currentState = HOMING;
@@ -86,9 +99,11 @@
                 Fail_button.fall(&Failing); 
                 wait(1.0f);
                 break;
+                
             case MOVE_W_EMG:
                 led_red = 1; led_green = 0; led_blue = 1;   // Colouring the led GREEN
                 pc.printf("MOVE_W_EMG, Moving with use of EMG \r\n");
+                // BUILD THE MOVEMENT WITH EMG
                 wait(1);
                 c = pc.getcNb();
                 if (c == 'h') {
@@ -96,14 +111,18 @@
                     }
                 Fail_button.fall(&Failing); 
                 wait(1.0f);
-                break;       
+                break;      
+                 
             case FAILURE_MODE:
                 led_red = 0; led_green = 1; led_blue = 1;   // Colouring the led RED
+                // WHAT NEEDS TO HAPPEN IN FAILURE MODE?
                 pc.printf("FAILURE MODE \r\n");
                 wait(2.0f);
                 break;
+                
             case SHUTDOWN:
                 pc.printf("Shutting down \r\n");
+                // BUILD WHAT NEEDS TO BE DONE WHEN SHUTTING DOWN
                 led_red = 1; led_green = 1; led_blue = 1;   // Colouring the led BLACK
                 wait(1.0f);
                 for (int i = 0; i < 4; i++) {               // Blinking WHITE 3x before turning BLACK
@@ -125,6 +144,7 @@
                         
             default: 
                 pc.printf("Unknown or unimplemented state reached!!! \n\r");
+                // WHAT HAPPENS IN THIS STATE? DOES IT KEEPS MOVING?
                 led_red = 1; led_green = 1; led_blue = 1;   // Colouring the led BLACK
                 for (int n = 0; n < 50; n++) {              // Making an SOS signal with the RED led
                     for (int i = 0; i < 6; i++) {