David Pasztor / Mbed 2 deprecated Motor_control

Dependencies:   mbed-rtos mbed

Revision:
63:7921a3b553e9
Parent:
60:f171b7006c73
--- a/photointerruptRoutines.h	Fri Mar 24 19:10:41 2017 +0000
+++ b/photointerruptRoutines.h	Fri Mar 24 19:57:24 2017 +0000
@@ -7,15 +7,11 @@
 volatile int CH_state_prev = 0x00;
  
 volatile float diskPosition = 0.0;  //in degrees
-
-volatile float velocityDuty = 0.0;
  
 Timer dt_I3;
-Mutex mutex;
+
 
-int8_t updateState() {           //Convert photointerrupter inputs to a 
-    return stateMap[4*I3 + 2*I2 + I1];  // rotor state. Reports 1/6 positions
-}
+
 
 void updateDiskPosition() {
   if (CH_state != CH_state_prev) {
@@ -76,10 +72,11 @@
 }
 
 void i_edge(){
-    mutex.lock();
-    state = updateState();
-    mutex.unlock();
-    motorOut((state-orState+lead+6)%6, velocityDuty);
+    callMotorThread();
+    //mutex.lock();
+//    state = updateState();
+//    mutex.unlock();
+//    motorOut((state-orState+lead+6)%6, velocityDuty);
 }
 
 void i3rise(){
@@ -94,10 +91,11 @@
         count_i3++;                         // rotor spins forward
         mutex.unlock();
     }
-    mutex.lock();
-    state = updateState();
-    mutex.unlock();
-    motorOut((state-orState+lead+6)%6, velocityDuty);
+    callMotorThread();
+//    mutex.lock();
+//    state = updateState();
+//    mutex.unlock();
+//    motorOut((state-orState+lead+6)%6, velocityDuty);
 }
 
 void startInterrupts() {