change float to double

Fork of PID by Aaron Berk

Revision:
1:ca4077d72c94
Parent:
0:6e12a3e5af19
--- a/PID.cpp	Thu Sep 02 16:48:10 2010 +0000
+++ b/PID.cpp	Wed Nov 23 07:13:07 2016 +0000
@@ -44,12 +44,14 @@
  *  http://www.controlguru.com/
  */
 
+// Modified by K.Arai/JH1PJL on June 15th, 2016
+
 /**
  * Includes
  */
 #include "PID.h"
 
-PID::PID(float Kc, float tauI, float tauD, float interval) {
+PID::PID(double Kc, double tauI, double tauD, double interval) {
 
     usingFeedForward = false;
     inAuto           = false;
@@ -77,7 +79,7 @@
 
 }
 
-void PID::setInputLimits(float inMin, float inMax) {
+void PID::setInputLimits(double inMin, double inMax) {
 
     //Make sure we haven't been given impossible values.
     if (inMin >= inMax) {
@@ -101,7 +103,7 @@
 
 }
 
-void PID::setOutputLimits(float outMin, float outMax) {
+void PID::setOutputLimits(double outMin, double outMax) {
 
     //Make sure we haven't been given impossible values.
     if (outMin >= outMax) {
@@ -124,7 +126,7 @@
 
 }
 
-void PID::setTunings(float Kc, float tauI, float tauD) {
+void PID::setTunings(double Kc, double tauI, double tauD) {
 
     //Verify that the tunings make sense.
     if (Kc == 0.0 || tauI < 0.0 || tauD < 0.0) {
@@ -136,7 +138,7 @@
     iParam_ = tauI;
     dParam_ = tauD;
 
-    float tempTauR;
+    double tempTauR;
 
     if (tauI == 0.0) {
         tempTauR = 0.0;
@@ -161,7 +163,7 @@
 
 void PID::reset(void) {
 
-    float scaledBias = 0.0;
+    double scaledBias = 0.0;
 
     if (usingFeedForward) {
         scaledBias = (bias_ - outMin_) / outSpan_;
@@ -189,7 +191,7 @@
 
 }
 
-void PID::setInterval(float interval) {
+void PID::setInterval(double interval) {
 
     if (interval > 0) {
         //Convert the time-based tunings to reflect this change.
@@ -201,29 +203,29 @@
 
 }
 
-void PID::setSetPoint(float sp) {
+void PID::setSetPoint(double sp) {
 
     setPoint_ = sp;
 
 }
 
-void PID::setProcessValue(float pv) {
+void PID::setProcessValue(double pv) {
 
     processVariable_ = pv;
 
 }
 
-void PID::setBias(float bias){
+void PID::setBias(double bias){
 
     bias_ = bias;
     usingFeedForward = 1;
 
 }
 
-float PID::compute() {
+double PID::compute() {
 
     //Pull in the input and setpoint, and scale them into percent span.
-    float scaledPV = (processVariable_ - inMin_) / inSpan_;
+    double scaledPV = (processVariable_ - inMin_) / inSpan_;
 
     if (scaledPV > 1.0) {
         scaledPV = 1.0;
@@ -231,14 +233,14 @@
         scaledPV = 0.0;
     }
 
-    float scaledSP = (setPoint_ - inMin_) / inSpan_;
+    double scaledSP = (setPoint_ - inMin_) / inSpan_;
     if (scaledSP > 1.0) {
         scaledSP = 1;
     } else if (scaledSP < 0.0) {
         scaledSP = 0;
     }
 
-    float error = scaledSP - scaledPV;
+    double 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.
@@ -247,9 +249,9 @@
     }
 
     //Compute the current slope of the input signal.
-    float dMeas = (scaledPV - prevProcessVariable_) / tSample_;
+    double dMeas = (scaledPV - prevProcessVariable_) / tSample_;
 
-    float scaledBias = 0.0;
+    double scaledBias = 0.0;
 
     if (usingFeedForward) {
         scaledBias = (bias_ - outMin_) / outSpan_;
@@ -275,49 +277,49 @@
 
 }
 
-float PID::getInMin() {
+double PID::getInMin() {
 
     return inMin_;
 
 }
 
-float PID::getInMax() {
+double PID::getInMax() {
 
     return inMax_;
 
 }
 
-float PID::getOutMin() {
+double PID::getOutMin() {
 
     return outMin_;
 
 }
 
-float PID::getOutMax() {
+double PID::getOutMax() {
 
     return outMax_;
 
 }
 
-float PID::getInterval() {
+double PID::getInterval() {
 
     return tSample_;
 
 }
 
-float PID::getPParam() {
+double PID::getPParam() {
 
     return pParam_;
 
 }
 
-float PID::getIParam() {
+double PID::getIParam() {
 
     return iParam_;
 
 }
 
-float PID::getDParam() {
+double PID::getDParam() {
 
     return dParam_;