good

Dependencies:   mbed

Fork of BX-car by Clark Lin

Revision:
8:8e49e21d80a2
Parent:
7:fd976e1ced33
Child:
9:33b99cb45e99
diff -r fd976e1ced33 -r 8e49e21d80a2 controller.cpp
--- a/controller.cpp	Sun Jun 22 13:58:01 2014 +0000
+++ b/controller.cpp	Sun Jun 22 15:29:20 2014 +0000
@@ -10,7 +10,7 @@
     //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(-1.0,1.0);
+    setOutputLimits(0.0,1.0);
  
     tSample_ = interval;
  
@@ -208,7 +208,7 @@
     }
  
     float error = scaledSP - scaledPV;
- 
+
     //Check and see if the output is pegged at a limit and only
     //integrate if it is not. This is to prevent reset-windup.
     if (!(prevControllerOutput_ >= 1 && error > 0) && !(prevControllerOutput_ <= 0 && error < 0)) {
@@ -230,8 +230,8 @@
     //controllerOutput_ = Kc_ * error + tauR_ * accError_ + tauD_ * dMeas;
  
     //Make sure the computed output is within output constraints.
-    if (controllerOutput_ < 0.0) {
-        controllerOutput_ = 0.0;
+    if (controllerOutput_ < -1.0) {
+        controllerOutput_ = -1.0;
     }
     else if (controllerOutput_ > 1.0) {
         controllerOutput_ = 1.0;
@@ -241,9 +241,10 @@
     prevControllerOutput_ = controllerOutput_;
     //Remember the input for the derivative calculation next time.
     prevProcessVariable_ = scaledPV;
- 
+    
+     
     //Scale the output from percent span back out to a real world number.
-    return ((controllerOutput_ * outSpan_) + outMin_);
+    return (controllerOutput_ * 90);
  
 }