Ramon Waninge / Mbed 2 deprecated Milestone1

Dependencies:   FastPWM mbed QEI biquadFilter HIDScope MODSERIAL

Revision:
47:bad50d34561c
Parent:
43:e8f2193822b7
diff -r e8f2193822b7 -r bad50d34561c main.cpp
--- a/main.cpp	Wed Oct 31 16:32:36 2018 +0000
+++ b/main.cpp	Wed Oct 31 18:54:33 2018 +0000
@@ -141,11 +141,11 @@
 void    turnl()    // main function for movement of motor 1, all above functions with an extra tab are called
 {   
     //float   refvaluel = pi/4.0f;
-    float   refvaluel = DesiredAnglel();                             // different minus sign per motor
+    float   refvaluel = DesiredAnglel();                            // different minus sign per motor
     int     countsl = Countslinput();                               // different encoder pins per motor
-    currentanglel = CurrentAngle(countsl);                  // different minus sign per motor
-    float   PIDcontroll = PIDcontrollerl(refvaluel,currentanglel);   // same for every motor
-    errorl = ErrorCalc(refvaluel,currentanglel);            // same for every motor
+    currentanglel = CurrentAngle(countsl);                          // different minus sign per motor
+    float   PIDcontroll = PIDcontrollerl(refvaluel,currentanglel);  // same for every motor
+    errorl = ErrorCalc(refvaluel,currentanglel);                    // same for every motor
     
     pin6 = fabs(PIDcontroll);                                       // different pins for every motor
     pin7 = PIDcontroll > 0.0f;                                      // different pins for every motor
@@ -183,11 +183,11 @@
 void    turnr()    // main function for movement of motor 1, all above functions with an extra tab are called
 {   
     float   refvaluer = pi/4.0f;
-    //float   refvaluer = DesiredAngler();                             // different minus sign per motor
+    //float   refvaluer = DesiredAngler();                          // different minus sign per motor
     int     countsr = Countsrinput();                               // different encoder pins per motor
-    currentangler = CurrentAngle(countsr);                  // different minus sign per motor
-    float   PIDcontrolr = PIDcontrollerr(refvaluer,currentangler);   // same for every motor
-    errorr = ErrorCalc(refvaluer,currentangler);            // same for every motor
+    currentangler = CurrentAngle(countsr);                          // different minus sign per motor
+    float   PIDcontrolr = PIDcontrollerr(refvaluer,currentangler);  // same for every motor
+    errorr = ErrorCalc(refvaluer,currentangler);                    // same for every motor
     
     pin5 = fabs(PIDcontrolr);                                       // different pins for every motor
     pin4 = PIDcontrolr > 0.0f;                                      // different pins for every motor
@@ -225,11 +225,11 @@
 void    turnf()    // main function for movement of motor 1, all above functions with an extra tab are called
 {   
     //float   refvaluef = pi/4.0f;
-    float   refvaluef = DesiredAnglef();                             // different minus sign per motor
+    float   refvaluef = DesiredAnglef();                            // different minus sign per motor
     int     countsf = Countsfinput();                               // different encoder pins per motor
-    currentanglef = CurrentAngle(countsf);                  // different minus sign per motor
-    float   PIDcontrolf = PIDcontrollerf(refvaluef,currentanglef);   // same for every motor
-    errorf = ErrorCalc(refvaluef,currentanglef);            // same for every motor
+    currentanglef = CurrentAngle(countsf);                          // different minus sign per motor
+    float   PIDcontrolf = PIDcontrollerf(refvaluef,currentanglef);  // same for every motor
+    errorf = ErrorCalc(refvaluef,currentanglef);                    // same for every motor
     
     pin3 = fabs(PIDcontrolf);                                       // different pins for every motor
     pin2 = PIDcontrolf > 0.0f;                                      // different pins for every motor
@@ -241,15 +241,38 @@
     return MotorPosition;
 }
 
+float PreviousAngle()
+{   float angle     angle = CurrentAngle();
+    static float    previousangle = angle;
+    
+    
+    previousangle = angle; 
+    
+}
+
+float calibration(float pwmpin,float dirpin);
+{   
+    angle = CurrentAngle()
+    while ()
+    {   pwmpin = 0.1f;
+        dirpin = pwmpin>0.0f;
+        
+        
+        
+    }
+        
+    
+}
+
 // Main program
 int main()
 {   
     pc.baud(115200);  
     pin3.period_us(15);     // If you give a period on one pin, c++ gives all pins this period
         
-    motorl.attach(turnl,dt);
-    motorr.attach(turnr,dt);
-    motorf.attach(turnf,dt);
+    //motorl.attach(turnl,dt);
+    //motorr.attach(turnr,dt);
+    //motorf.attach(turnf,dt);
     
     emergencybutton.rise(Emergency);              //If the button is pressed, stop program