pid+sineinput

Dependencies:   HIDScope MODSERIAL QEI biquadFilter mbed

Files at this revision

API Documentation at this revision

Comitter:
cmaas
Date:
Tue Oct 30 06:35:29 2018 +0000
Parent:
5:ea9f9f11d7c1
Commit message:
Correct Kp, Ki, Kd values added

Changed in this revision

Math.lib Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r ea9f9f11d7c1 -r bbc9ce35e0a4 Math.lib
--- a/Math.lib	Mon Oct 29 11:35:56 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://os.mbed.com/users/inst/code/Math/#067c036b09e0
diff -r ea9f9f11d7c1 -r bbc9ce35e0a4 main.cpp
--- a/main.cpp	Mon Oct 29 11:35:56 2018 +0000
+++ b/main.cpp	Tue Oct 30 06:35:29 2018 +0000
@@ -6,7 +6,7 @@
 #include "QEI.h"
 #include "MODSERIAL.h"
 #include "HIDScope.h"
-#include "Math.h"
+//#include "Math.h"
 
 AnalogIn button2(A4);
 PwmOut pwmpin1(D6);
@@ -21,9 +21,9 @@
 // INITIALIZING GLOBAl VALUES
 
 double PI = 3.141592653589793238462;
-double Kp = 100; //200 , 50
-double Ki = 10;   //1, 0.5
-double Kd = 0; //200, 10
+double Kp = 16; //200 , 50
+double Ki = 0;   //1, 0.5
+double Kd = 4.5; //200, 10
 double Ts = 0.1; // Sample time in seconds
 volatile double reference_rotation = PI; //define as radians
 double motor_position;
@@ -100,7 +100,7 @@
     pc.baud(9600);
     //show_counts.attach(PrintFlag, 0.2);
     ref_rot.attach(Motor_mover, 0.01);
-    Scope_Data.attach(ScopeData, 0.1);
+    Scope_Data.attach(ScopeData, 0.01);
 
 // DEFININING VARIABLES
     //float reference;
@@ -121,18 +121,18 @@
                 foo[a] = 3.14f/length*(a);
                 //printf("%f\n\r", foo[a]);
                 reference_rotation = foo[a];
-                wait(0.1f);
+                wait(0.2f);
                 }
             for(a=10; a<18; a++){
                 foo[a] = 3.14f/length*b;
                 //printf("%f\n\r", foo[a]);
                 reference_rotation = foo[a];
                 b = b-1.0f;
-                wait(0.1f);
+                wait(0.2f);
                 }
             }
 
-        reference_rotation = PI;
+        reference_rotation = 0;