Samenwerking Groep 12

Dependencies:   Encoder MODSERIAL HIDScope mbed

Foo

Files at this revision

API Documentation at this revision

Comitter:
ThomasBNL
Date:
Tue Sep 22 21:42:11 2015 +0000
Parent:
25:75cce8f86272
Commit message:
Changed the order of the MAIN -> callibration revolutions naarboven gehaald

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 75cce8f86272 -r 6bdfc1856531 main.cpp
--- a/main.cpp	Tue Sep 22 21:36:28 2015 +0000
+++ b/main.cpp	Tue Sep 22 21:42:11 2015 +0000
@@ -60,16 +60,28 @@
 //------------------------------------------------------------------------------------------------------------------------------------
 
 // MAIN
-int main()                                                                                                           // Begin main loop 1
+int main()                                                                                                          // Begin main loop 1
 {
-        // CALLIBRATION BEGIN POSITION
+        // CALLIBRATION STARTING POSITION
+        
                 pc.baud(9600);           // baud rate at which the information is processed to the computer
                 //motor2.setPosition(0); // calls the current position of the motor zero
+
+        // CALLIBRATION POSITION OF MOTOR
+                    // The position is limited to number of counts per revolution
+            
+           while ((motor2.getPosition()>counts_per_rev) || (motor2.getPosition()<-counts_per_rev)) 
+                    // If value is outside -4200 and 4200 (number of counts equal to one revolution) reset to zero
+                                {
+                                    motor2.setPosition(0);
+                                    pc.printf(" HE \r\n LLO \r\n WO \r\n RLD \r\n !!! \r\n FOO! \r\n");
+                                    break;
+                                } 
     
-    while(true) {                                                                                                    // while loop 1
+    while(true) {                                                                                                   // while loop 1
         // IF BUTTON IS PRESSED
             if (button.read() < 0.5)                                                                                 
-                {                                                                                                    // start if else loop 1
+                {                                                                                                   // start if else loop 1
                         motor2direction = 0;  // clockwise motor rotation (front view)
                         motor2speed = 0.5f;   // motorspeed                
                                         
@@ -100,19 +112,8 @@
                                     TickerController.attach(&motor2_controller,0.01f);//100Hz
                                     pc.printf("else loop controller");
                                 }
-                }                                                                                               // end of if-else loop 1
-    
-        // CALLIBRATION POSITION OF MOTOR
-                    // The position is limited to number of counts per revolution
-            
-           while ((motor2.getPosition()>counts_per_rev) || (motor2.getPosition()<-counts_per_rev)) 
-                    // If value is outside -4200 and 4200 (number of counts equal to one revolution) reset to zero
-                                {
-                                    motor2.setPosition(0);
-                                    pc.printf(" HE \r\n LLO \r\n WO \r\n RLD \r\n !!! \r\n FOO! \r\n");
-                                    break;
-                                } 
-        }                                                                                                             // end of while loop 1
-        }                                                                                                             // end of main
+                }                                                                                                  // end of if-else loop 1
+        }                                                                                                          // end of while loop 1
+        }                                                                                                          // end of main
 
-//------------------------------------------------------------------------------------------------------------------------------------
\ No newline at end of file
+//------------------------------------------------------------------------------------------------------------------------------------