Dependencies:   mbed QEI HIDScope biquadFilter MODSERIAL FastPWM

Revision:
3:750afb8580dd
Parent:
2:29daa03e4f62
Child:
4:f6862a157db9
--- a/main.cpp	Mon Oct 21 12:03:31 2019 +0000
+++ b/main.cpp	Mon Oct 21 12:17:59 2019 +0000
@@ -11,10 +11,10 @@
 Serial pc(USBTX, USBRX);
 volatile float width_percent;
 
-float k_p = 17.5;  
-float k_i = 1.02;
-float k_d = 23.2;
-float t_s = 0.0025; //sample time in sec
+const float k_p = 3;  
+const float k_i = 1000;
+const float k_d = 1;
+const float t_s = 0.0025; //sample time in sec
 
 
 //inputs for LPF; still to fill in!
@@ -28,7 +28,7 @@
 
 float getError(){
     float a; //error
-    cin >> a;
+    cin >> a;   //input on keyboard
     return a;
     }
     
@@ -40,7 +40,7 @@
 
 
 
-/*float PIDControl(float error){
+float PIDControl(float error){
     static float error_integral = 0;
     static float error_prev = error;
     static BiQuad LPF (b1, b2, b3, b4, b5); 
@@ -63,9 +63,6 @@
     }
     
 
-*/
-
-
 int main()
 {
     pc.baud(115200);
@@ -77,12 +74,14 @@
     pc.printf("Your error is: %f\r\n",er);
     pc.printf("-------\r\n-------\r\n");
     wait(0.5);
-    goto startmain;
+    
 
     
     
-    //float outcome = PIDControl(error);
-    //pc.printf("The outcome is %f\n",outcome);
-   // pc.printf("Your input is: %f\n", error);
+    float outcome = PIDControl(er);
+    pc.printf("The outcome is %f\n",outcome);
+    
+    
+    goto startmain; //allows to input multiple numbers after each other
 
 }