change float to double

Fork of PID by Aaron Berk

Revision:
1:ca4077d72c94
Parent:
0:6e12a3e5af19
--- a/PID.h	Thu Sep 02 16:48:10 2010 +0000
+++ b/PID.h	Wed Nov 23 07:13:07 2016 +0000
@@ -44,6 +44,8 @@
  *  http://www.controlguru.com/
  */
 
+// Modified by K.Arai/JH1PJL on June 15th, 2016
+
 #ifndef PID_H
 #define PID_H
 
@@ -76,7 +78,7 @@
      * @param tauD - Tuning parameter
      * @param interval PID calculation performed every interval seconds.
      */
-    PID(float Kc, float tauI, float tauD, float interval);
+    PID(double Kc, double tauI, double tauD, double interval);
 
     /**
      * Scale from inputs to 0-100%.
@@ -84,7 +86,7 @@
      * @param InMin The real world value corresponding to 0%.
      * @param InMax The real world value corresponding to 100%.
      */
-    void setInputLimits(float inMin , float inMax);
+    void setInputLimits(double inMin , double inMax);
 
     /**
      * Scale from outputs to 0-100%.
@@ -92,7 +94,7 @@
      * @param outMin The real world value corresponding to 0%.
      * @param outMax The real world value corresponding to 100%.
      */
-    void setOutputLimits(float outMin, float outMax);
+    void setOutputLimits(double outMin, double outMax);
 
     /**
      * Calculate PID constants.
@@ -103,7 +105,7 @@
      * @param tauI - Tuning parameter
      * @param tauD - Tuning parameter
      */
-    void setTunings(float Kc, float tauI, float tauD);
+    void setTunings(double Kc, double tauI, double tauD);
 
     /**
      * Reinitializes controller internals. Automatically
@@ -124,45 +126,45 @@
      *
      * @param interval PID calculation peformed every interval seconds.
      */
-    void setInterval(float interval);
+    void setInterval(double interval);
     
     /**
      * Set the set point.
      *
      * @param sp The set point as a real world value.
      */
-    void setSetPoint(float sp);
+    void setSetPoint(double sp);
     
     /**
      * Set the process value.
      *
      * @param pv The process value as a real world value.
      */
-    void setProcessValue(float pv);
+    void setProcessValue(double pv);
     
     /**
      * Set the bias.
      *
      * @param bias The bias for the controller output.
      */
-    void setBias(float bias);
+    void setBias(double bias);
 
     /**
      * PID calculation.
      *
-     * @return The controller output as a float between outMin and outMax.
+     * @return The controller output as a double between outMin and outMax.
      */
-    float compute(void);
+    double compute(void);
 
     //Getters.
-    float getInMin();
-    float getInMax();
-    float getOutMin();
-    float getOutMax();
-    float getInterval();
-    float getPParam();
-    float getIParam();
-    float getDParam();
+    double getInMin();
+    double getInMax();
+    double getOutMin();
+    double getOutMax();
+    double getInterval();
+    double getPParam();
+    double getIParam();
+    double getDParam();
 
 private:
 
@@ -170,43 +172,43 @@
     bool inAuto;
 
     //Actual tuning parameters used in PID calculation.
-    float Kc_;
-    float tauR_;
-    float tauD_;
+    double Kc_;
+    double tauR_;
+    double tauD_;
     
     //Raw tuning parameters.
-    float pParam_;
-    float iParam_;
-    float dParam_;
+    double pParam_;
+    double iParam_;
+    double dParam_;
     
     //The point we want to reach.
-    float setPoint_;         
+    double setPoint_;         
     //The thing we measure.
-    float processVariable_;  
-    float prevProcessVariable_;
+    double processVariable_;  
+    double prevProcessVariable_;
     //The output that affects the process variable.
-    float controllerOutput_; 
-    float prevControllerOutput_;
+    double controllerOutput_; 
+    double prevControllerOutput_;
 
     //We work in % for calculations so these will scale from
     //real world values to 0-100% and back again.
-    float inMin_;
-    float inMax_;
-    float inSpan_;
-    float outMin_;
-    float outMax_;
-    float outSpan_;
+    double inMin_;
+    double inMax_;
+    double inSpan_;
+    double outMin_;
+    double outMax_;
+    double outSpan_;
 
     //The accumulated error, i.e. integral.
-    float accError_;
+    double accError_;
     //The controller output bias.
-    float bias_;
+    double bias_;
 
     //The interval between samples.
-    float tSample_;          
+    double tSample_;          
 
     //Controller output as a real world value.
-    volatile float realOutput_;
+    volatile double realOutput_;
 
 };