David Pasztor / Mbed 2 deprecated Motor_control

Dependencies:   mbed-rtos mbed

Revision:
7:6bf4a61cf7c7
Parent:
4:dc705df93090
Child:
10:25d8696cb2c6
--- a/main.cpp	Tue Mar 14 13:17:26 2017 +0000
+++ b/main.cpp	Tue Mar 14 14:08:18 2017 +0000
@@ -12,7 +12,7 @@
 volatile uint8_t orState = 0;                   //Motor rotor offset.
 volatile float w [3] = {0, 0, 0};               //Angular velocities
 volatile float avgW = 0;
-volatile int duty = 100;
+volatile float duty = 0.75;
 volatile int count_i3 = 0;
 
 const uint16_t angle = 6283;                    //2*pi*1000 for 1 revolution
@@ -94,7 +94,7 @@
     dt_I2.start();          //Probably put these in an init function?
     dt_I3.start();
     
-    motorOut(4, 100);            //Kickstart the motor
+    motorOut(4, duty);            //Kickstart the motor
     motorTimer.start();
     
     //controlTicker.attach(&control, dt);
@@ -119,9 +119,10 @@
             return 0;
         }
         */
-        /*
+        
         avgW = (w[0] + w[1] + w[2])/3;    //average speeds for better prediction
-        pc.printf("Speed: %f, duty cycle: %d ; ",w[2], duty);
+        pc.printf("Speed: %f, duty cycle: %f  \n\r",w[2], duty);
+        /*
         duty ++;
         wait(2);
         if(duty > 100) {
@@ -129,9 +130,9 @@
             return 0;    
         }
         */
-        //if(motorTimer.read_ms() >= 10000) {
-        //    stopMotor();
-        //    return 0;    
-        //}
+        if(motorTimer.read_ms() >= 30000) {
+            stopMotor();
+            return 0;    
+        }
     }
 }
\ No newline at end of file