Tracking down compile errors.
This commit is contained in:
parent
b3255d94d4
commit
d565cded53
33
PID_v1.cpp
33
PID_v1.cpp
@ -102,7 +102,7 @@ int PID::ComputeTune() {
|
||||
}
|
||||
unsigned long now = millis();
|
||||
|
||||
if((now-lastTime)<sampleTime) return false;
|
||||
if((now-lastTime)<SampleTime) return false;
|
||||
|
||||
lastTime = now;
|
||||
double refVal = *myInput;
|
||||
@ -121,9 +121,6 @@ int PID::ComputeTune() {
|
||||
} else {
|
||||
if(refVal>absMax)absMax=refVal;
|
||||
if(refVal<absMin)absMin=refVal;
|
||||
} else {
|
||||
if(refVal>absMax)absMax=refVal;
|
||||
if(refVal<absMin)absMin=refVal;
|
||||
}
|
||||
|
||||
//oscillate the output base on the input's relation to the setpoint
|
||||
@ -222,7 +219,7 @@ void PID::SetTunings(double Kp, double Ki, double Kd){
|
||||
/* SetSampleTime(...) *********************************************************
|
||||
* sets the period, in Milliseconds, at which the calculation is performed
|
||||
******************************************************************************/
|
||||
void PID::SampleTime(int NewSampleTime){
|
||||
void PID::SetSampleTime(int NewSampleTime){
|
||||
if (NewSampleTime > 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;
|
||||
|
||||
if(value<25) {
|
||||
nLookBack = value * 4;
|
||||
sampleTime = 250;
|
||||
SampleTime = 250;
|
||||
} else {
|
||||
nLookBack = 100;
|
||||
sampleTime = value*10;
|
||||
SampleTime = value*10;
|
||||
}
|
||||
}
|
||||
|
||||
int PID::LookbackSec(){ return nLookBack * sampleTime / 1000;}
|
||||
int PID::LookbackSec(){ return nLookBack * SampleTime / 1000;}
|
||||
|
13
PID_v1.h
13
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];
|
||||
|
Loading…
Reference in New Issue
Block a user