Motor

Fork of Motor by Reiko Randoja

Files at this revision

API Documentation at this revision

Comitter:
Reiko
Date:
Sun Nov 03 11:41:40 2013 +0000
Parent:
9:bec5a728405f
Commit message:
Increased PI controller parameters

Changed in this revision

motor.cpp Show annotated file Show diff for this revision Revisions of this file
motor.h Show annotated file Show diff for this revision Revisions of this file
diff -r bec5a728405f -r b0e6051a6109 motor.cpp
--- a/motor.cpp	Sun Sep 22 07:24:15 2013 +0000
+++ b/motor.cpp	Sun Nov 03 11:41:40 2013 +0000
@@ -7,15 +7,15 @@
     PwmOut pwm(PWMpin);
     pwm.period_us(pwmPeriod);
     setPoint = 0;
-    pMulti = 32;
-    iDiv = 1;
+    pMulti = 48;
+    iMulti = 2;
     dMulti = 1;
     error = 0;
     prevError = 0;
     P = 0;
     I = 0;
     minPwm = 100;
-    pidMulti = 128;
+    pidMulti = 256;
     iMax = 4096 * pidMulti;
     
     currentSpeed = 0;
@@ -72,7 +72,7 @@
             minPwmValue = -minPwm;
         }
         
-        I += error * pidMulti / iDiv;
+        I += error * pidMulti * iMulti;
         //constrain integral
         if (I < -iMax) I = -iMax;
         if (I > iMax) I = iMax;
diff -r bec5a728405f -r b0e6051a6109 motor.h
--- a/motor.h	Sun Sep 22 07:24:15 2013 +0000
+++ b/motor.h	Sun Nov 03 11:41:40 2013 +0000
@@ -89,7 +89,7 @@
 
     int setPoint;
     int pMulti;
-    int iDiv;
+    int iMulti;
     int dMulti;
     int error;
     int prevError;