From d565cded53094ac01a63078cd4c0f1295aad67b4 Mon Sep 17 00:00:00 2001 From: Chris Giacofei Date: Wed, 1 May 2024 16:13:35 -0400 Subject: [PATCH] Tracking down compile errors. --- PID_v1.cpp | 51 ++++++++++++++++++++++++--------------------------- PID_v1.h | 13 ++++++------- 2 files changed, 30 insertions(+), 34 deletions(-) diff --git a/PID_v1.cpp b/PID_v1.cpp index 517d28d..fb9aae0 100644 --- a/PID_v1.cpp +++ b/PID_v1.cpp @@ -102,7 +102,7 @@ int PID::ComputeTune() { } unsigned long now = millis(); - if((now-lastTime)absMax)absMax=refVal; - if(refValabsMax)absMax=refVal; if(refVal 0){ double ratio = (double)NewSampleTime / (double)SampleTime; @@ -309,30 +306,30 @@ void PID::Direction(int Direction){ * functions query the internal state of the PID. they're here for display * purposes. this are the functions the PID Front-end uses for example ******************************************************************************/ -double PID::Kp(){ return Kp; } -double PID::Ki(){ return Ki;} -double PID::Kd(){ return Kd;} -int PID::Mode(){ return OpMode;} +double PID::Kp(){ return kp; } +double PID::Ki(){ return ki;} +double PID::Kd(){ return kd;} +modes PID::Mode(){ return OpMode;} int PID::Direction(){ return controllerDirection;} void PID::Cancel(){ autotune_running = false;} double PID::TunedKp(){ return 0.6 * Ku;} -double PID::TunedKi(){ return 1.2*Ku / Pu ; // Ki = Kc/Ti} - double PID::TunedKd(){ return 0.075 * Ku * Pu; //Kd = Kc * Td} - void PID::SetOutputStep(double Step){ oStep = Step;} - double PID::GetOutputStep(){ return oStep;} - void PID::SetNoiseBand(double Band){ noise_band = Band;} - double PID::GetNoiseBand(){ return noise_band;} +double PID::TunedKi(){ return 1.2*Ku / Pu ;} // Ki = Kc/Ti} +double PID::TunedKd(){ return 0.075 * Ku * Pu;} //Kd = Kc * Td} +void PID::OutputStep(double Step){ oStep = Step;} +double PID::OutputStep(){ return oStep;} +void PID::NoiseBand(double Band){ noise_band = Band;} +double PID::NoiseBand(){ return noise_band;} - void PID::LookbackSec(int value){ - if (value<1) value = 1; +void PID::LookbackSec(int value){ + if (value<1) value = 1; - if(value<25) { - nLookBack = value * 4; - sampleTime = 250; - } else { - nLookBack = 100; - sampleTime = value*10; - } - } + if(value<25) { + nLookBack = value * 4; + SampleTime = 250; + } else { + nLookBack = 100; + SampleTime = value*10; + } +} - int PID::LookbackSec(){ return nLookBack * sampleTime / 1000;} +int PID::LookbackSec(){ return nLookBack * SampleTime / 1000;} diff --git a/PID_v1.h b/PID_v1.h index 5a93d32..e720141 100644 --- a/PID_v1.h +++ b/PID_v1.h @@ -46,7 +46,7 @@ class PID // means the output will increase when error is positive. REVERSE // means the opposite. it's very unlikely that this will be needed // once it is set in the constructor. - void SampleTime(int); // * sets the frequency, in Milliseconds, with which + void SetSampleTime(int); // * sets the frequency, in Milliseconds, with which // the PID calculation is performed. default is 100 //Display functions **************************************************************** @@ -59,14 +59,14 @@ class PID // Auto Tune Public void Cancel(); // * Stops the AutoTune - void SetOutputStep(double); // * how far above and below the starting value will the output step? - double GetOutputStep(); // + void OutputStep(double); // * how far above and below the starting value will the output step? + double OutputStep(); // void LookbackSec(int); // * how far back are we looking to identify peaks int LookbackSec(); // - void SetNoiseBand(double); // * the autotune will ignore signal chatter smaller than this value - double GetNoiseBand(); // this should be acurately set + void NoiseBand(double); // * the autotune will ignore signal chatter smaller than this value + double NoiseBand(); // this should be acurately set double TunedKp(); // * once autotune is complete, these functions contain the double TunedKi(); // computed tuning parameters. @@ -90,7 +90,6 @@ class PID unsigned long lastTime; double outputSum, lastInput; - unsigned long SampleTime; double outMin, outMax; bool inAuto, pOnE; modes OpMode; @@ -101,7 +100,7 @@ class PID double noise_band; bool autotune_running; unsigned long peak1, peak2; - int sampleTime; + int SampleTime; int nLookBack; int peakType; double lastInputs[101];