Function should start with a capital letter to match the style of the existing functions
This commit is contained in:
parent
6231da4cf9
commit
e48e87eede
@ -34,7 +34,7 @@ PID::PID(double* Input, double* Output, double* Setpoint,
|
|||||||
PID::SetControllerDirection(ControllerDirection);
|
PID::SetControllerDirection(ControllerDirection);
|
||||||
PID::SetTunings(Kp, Ki, Kd);
|
PID::SetTunings(Kp, Ki, Kd);
|
||||||
|
|
||||||
PID::setResolution(MILLIS); // Use a resolution of milliseconds by default
|
PID::SetResolution(MILLIS); // Use a resolution of milliseconds by default
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ PID::PID(double* Input, double* Output, double* Setpoint,
|
|||||||
bool PID::Compute()
|
bool PID::Compute()
|
||||||
{
|
{
|
||||||
if(!inAuto) return false;
|
if(!inAuto) return false;
|
||||||
unsigned long now = PID::getTime();
|
unsigned long now = PID::GetTime();
|
||||||
timeChange = (now - lastTime);
|
timeChange = (now - lastTime);
|
||||||
if(SampleTime == 0 || timeChange>=SampleTime)
|
if(SampleTime == 0 || timeChange>=SampleTime)
|
||||||
{
|
{
|
||||||
@ -203,27 +203,27 @@ void PID::SetControllerDirection(int Direction)
|
|||||||
controllerDirection = Direction;
|
controllerDirection = Direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* getTime()*******************************************************************
|
/* GetTime()*******************************************************************
|
||||||
* Will get the current time either by using millis() or micros()
|
* Will get the current time either by using millis() or micros()
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
unsigned long PID::getTime()
|
unsigned long PID::GetTime()
|
||||||
{
|
{
|
||||||
if (secondsDivider == 1000.0) return millis();
|
if (secondsDivider == 1000.0) return millis();
|
||||||
return micros();
|
return micros();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* setResolution(...)**********************************************************
|
/* SetResolution(...)**********************************************************
|
||||||
* Will set the resolution of getTime().
|
* Will set the resolution of GetTime().
|
||||||
* MILLIS will set the resolution to milliseconds while
|
* MILLIS will set the resolution to milliseconds while
|
||||||
* MICROS will set the resolution to microseconds.
|
* MICROS will set the resolution to microseconds.
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
void PID::setResolution(int resolution)
|
void PID::SetResolution(int resolution)
|
||||||
{
|
{
|
||||||
if (resolution == MILLIS)
|
if (resolution == MILLIS)
|
||||||
secondsDivider = 1000.0;
|
secondsDivider = 1000.0;
|
||||||
else
|
else
|
||||||
secondsDivider = 1000000.0;
|
secondsDivider = 1000000.0;
|
||||||
lastTime = PID::getTime()-SampleTime; // Update last time variable
|
lastTime = PID::GetTime()-SampleTime; // Update last time variable
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Status Funcions*************************************************************
|
/* Status Funcions*************************************************************
|
||||||
|
@ -43,7 +43,7 @@ class PID
|
|||||||
// once it is set in the constructor.
|
// once it is set in the constructor.
|
||||||
void SetSampleTime(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
|
// the PID calculation is performed. default is 100
|
||||||
void setResolution(int); // * Set the resolution of the getTime() function.
|
void SetResolution(int); // * Set the resolution of the GetTime() function.
|
||||||
// MILLIS sets the resolution to milliseconds.
|
// MILLIS sets the resolution to milliseconds.
|
||||||
// MICROS sets the resolution to microseconds.
|
// MICROS sets the resolution to microseconds.
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ class PID
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void Initialize();
|
void Initialize();
|
||||||
unsigned long getTime(); // * This will call either millis() or micros()
|
unsigned long GetTime(); // * This will call either millis() or micros()
|
||||||
// depending on the used resolution.
|
// depending on the used resolution.
|
||||||
|
|
||||||
double dispKp; // * we'll hold on to the tuning parameters in user-entered
|
double dispKp; // * we'll hold on to the tuning parameters in user-entered
|
||||||
|
Loading…
Reference in New Issue
Block a user