wu

Dependencies:   mbed-rtos mbed

Fork of Bov3 by kao yi

Revision:
9:33b99cb45e99
Parent:
8:8e49e21d80a2
Child:
10:03d5aa2511c4
--- a/controller.cpp	Sun Jun 22 15:29:20 2014 +0000
+++ b/controller.cpp	Tue Jun 24 10:06:54 2014 +0000
@@ -2,15 +2,17 @@
 #include "controller.h"
 
 
-PID::PID(float Kc, float tauI, float tauD, float interval) {
+PID::PID(float in_min,float in_max,float out_min,float out_max,float Kc, float tauI, float tauD, float interval) {
  
     usingFeedForward = false;
     //inAuto = false;
  
     //Default the limits to the full range of I/O.
     //Make sure to set these to more appropriate limits for your application.
-    setInputLimits(10.0, 118.0);
-    setOutputLimits(0.0,1.0);
+ 
+ //BX tune
+    setInputLimits(in_min,in_max);
+    setOutputLimits(out_min,out_max);
  
     tSample_ = interval;
  
@@ -230,11 +232,11 @@
     //controllerOutput_ = Kc_ * error + tauR_ * accError_ + tauD_ * dMeas;
  
     //Make sure the computed output is within output constraints.
-    if (controllerOutput_ < -1.0) {
-        controllerOutput_ = -1.0;
+    if (controllerOutput_ < outMin_) {
+        controllerOutput_ = outMin_;
     }
-    else if (controllerOutput_ > 1.0) {
-        controllerOutput_ = 1.0;
+    else if (controllerOutput_ >outMax_ ) {
+        controllerOutput_ = outMax_;
     }
  
     //Remember this output for the windup check next time.
@@ -244,7 +246,7 @@
     
      
     //Scale the output from percent span back out to a real world number.
-    return (controllerOutput_ * 90);
+    return (controllerOutput_ );
  
 }