Jorn Dokter / Mbed 2 deprecated TEB_branch2

Dependencies:   mbed QEI HIDScope biquadFilter MODSERIAL FastPWM

Files at this revision

API Documentation at this revision

Comitter:
JornD
Date:
Tue Oct 15 11:34:02 2019 +0000
Parent:
48:39f84359998a
Child:
50:283a831f84a9
Child:
51:4ff37a929849
Commit message:
Cleaned the files and commented some stuff

Changed in this revision

controller.cpp Show annotated file Show diff for this revision Revisions of this file
controller_copy.cpp Show diff for this revision Revisions of this file
functions.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
structures.h Show annotated file Show diff for this revision Revisions of this file
--- a/controller.cpp	Mon Oct 14 20:05:57 2019 +0000
+++ b/controller.cpp	Tue Oct 15 11:34:02 2019 +0000
@@ -13,19 +13,7 @@
         }
 
 */
-/*
-float * Filt(float P[], float Q[])
-{
 
-    static float coefficients[5];
-        coefficients[0] = (Q[0] * pow(K,2) + Q[1] * K + Q[2])/(P[0] * pow(K,2) + P[1] * K + P[2]);
-        coefficients[1] = (2 * Q[2] - 2 * Q[0] * pow(K,2))/(P[0] * pow(K,2) + P[1] * K + P[2]);
-        coefficients[2] = (Q[0] * pow(K,2) - Q[1] * K + Q[2])/(P[0] * pow(K,2) + P[1] * K + P[2]);
-        coefficients[3] = (2 * P[2] - 2 * P[0] * pow(K,2))/(P[0] * pow(K,2) + P[1] * K + P[2]);
-        coefficients[4] = (P[0] * pow(K,2) - P[1] * K + P[2])/(P[0] * pow(K,2) + P[1] * K + P[2]);
-    return coefficients;
-} 
-*/
 void BuildController(ControllerSettings& StrucName, float P[], float Q[])
 {
     
@@ -62,4 +50,5 @@
         float PA[] = {1,2,3};
         float QA[] = {4,5,6};
         BuildController(Set_EndAffector, PA, QA);
-}
\ No newline at end of file
+}
+
--- a/controller_copy.cpp	Mon Oct 14 20:05:57 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-//Gains
-double e = 1.02; 
-double Ts = 0.92;
-
-    double K_p = 1;//Position gain
-    double K_i = 1;//Integral gain
-    double K_d = 1;//Diverentiation gain
-    
-    //static double u_i = 0;
-    static double e_Prev = 0;
-
-double ControllerPID(double e, double Ts)
-{
-    double u_p = K_p*e;               //Position action
-    double u_i = K_i*(e*Ts+u_i);      //Integral action
-    double u_d = K_d*((e-e_Prev)/Ts);   //Diverential action
-    
-    e_Prev = e; //Write error to previous error
-    
-    double u;
-    
-    u = u_p + u_i + u_d;
-    
-    return u;
-}
\ No newline at end of file
--- a/functions.h	Mon Oct 14 20:05:57 2019 +0000
+++ b/functions.h	Tue Oct 15 11:34:02 2019 +0000
@@ -1,10 +1,8 @@
 #ifndef header_h
 #define header_h
+    //Functions
     double ControllerPID(double e, double Ts); //e = error, Ts = sampling time
     //void motorAndEncoder(float PWM1, float PWM2, float dt);
-    //Define global variables
-    
+    void InitializeControllers(void); //no input
     
-    const float PI = 3.14159265359;
-
 #endif
\ No newline at end of file
--- a/main.cpp	Mon Oct 14 20:05:57 2019 +0000
+++ b/main.cpp	Tue Oct 15 11:34:02 2019 +0000
@@ -34,8 +34,6 @@
     enum States {MovementIdle, CalibrationIdle, Demo, Startup, CalibrationPhysical, CalibrationEMG, Move, TiltCup, FailState};
     States CurrentState; 
 
-    extern double X;
-
     volatile char ledcolor; //r is red, b is blue, g is green, t is bluegreen, p is purple
     volatile int errorCode;
     
--- a/structures.h	Mon Oct 14 20:05:57 2019 +0000
+++ b/structures.h	Tue Oct 15 11:34:02 2019 +0000
@@ -5,6 +5,7 @@
 //--Motor data
     struct motorReturnSub
     {
+        int zerocounts;
         int counts;
         float angle;
         float velocity;
@@ -16,6 +17,7 @@
         motorReturnSub motor2;
         motorReturnSub motor3;
     };
+    
 //--PID controller settings
     struct ControllerSettings //Controller settings of the discrete TF
     {
@@ -25,6 +27,7 @@
         float D;
         float E;
     };
+    
 //--Memory of Input/Output
     struct MemoryIO
     {
@@ -32,6 +35,7 @@
         float ddY;  //output, delayed twice
         float dX;   //input, delayed once
         float ddX;  //input, delayed twice
+        //void ShiftValues
     };