changes to motor library

Dependents:   pid-car-example

Fork of motor by Lawrence Harlow

Branch:
testing
Revision:
9:22b119eef1de
Parent:
8:4df2a47ab4ee
Child:
10:f4fc8ccde4ad
--- a/motor.cpp	Mon Nov 07 16:12:48 2016 +0000
+++ b/motor.cpp	Mon Nov 07 16:37:58 2016 +0000
@@ -1,5 +1,6 @@
 #include "mbed.h"
 #include "TFC.h"
+#include <math.h> 
 DigitalOut myled(LED1);
 
 
@@ -132,6 +133,43 @@
     }
     
     
+void speedSetting(int w1, int w2 ,int w1M, int w2M)
+{
+    // need to compare the measured frequency 
+    
+    float deltaW1 = w1 - w1M;
+    float deltaW2 = w2 - w2M;
+    
+    if(delatW1 <0)
+    {
+        changespeed(0,w1);   
+    }
+    
+    else if(delatW1 >0)
+    {
+        changespeed(1,w1);
+    } 
+    return;
+}
+    
+//need to fill out function for calculating the change in speed.
+void changespeed(bool a, float w)
+{
+    float change;
+    
+    if(a == 1)
+    {
+        w+= change;
+    }
+    
+    else if (a ==0)
+    {
+        
+        w-= change;    
+    }
+ return;   
+}
+    
  //----------------------------------------------------------------------------------------------------------------------------   
  //------------------------------------------------Cornering Control-----------------------------------------------------------   
  //----------------------------------------------------------------------------------------------------------------------------   
@@ -171,6 +209,8 @@
     
     
     float deltaTheta =  center- theta;
+    
+    // need to convert to degrees/radians. that can do the above as well.
     if(deltaTheta <0)
     {
         // going left?
@@ -180,7 +220,7 @@
     else()
     {
         //going right?
-        corner(w2,w1,deltaTheta)
+        corner(w2,w1,deltaTheta);
         
     }