Update to my version - 1.2.2.
This commit is contained in:
parent
aff2e8e688
commit
a2764c9461
20
PID_v1.cpp
20
PID_v1.cpp
@ -17,7 +17,7 @@
|
||||
* The parameters specified here are those for for which we can't set up
|
||||
* reliable defaults, so we need to have the user set them.
|
||||
***************************************************************************/
|
||||
PID::PID(double* Input, double* Output, double* Setpoint,
|
||||
PID2::PID2(double* Input, double* Output, double* Setpoint,
|
||||
double Kp, double Ki, double Kd, int POn, int ControllerDirection)
|
||||
{
|
||||
myOutput = Output;
|
||||
@ -41,7 +41,7 @@ PID::PID(double* Input, double* Output, double* Setpoint,
|
||||
* to use Proportional on Error without explicitly saying so
|
||||
***************************************************************************/
|
||||
|
||||
PID::PID(double* Input, double* Output, double* Setpoint,
|
||||
PID2::PID2(double* Input, double* Output, double* Setpoint,
|
||||
double Kp, double Ki, double Kd, int ControllerDirection)
|
||||
:PID::PID(Input, Output, Setpoint, Kp, Ki, Kd, P_ON_E, ControllerDirection)
|
||||
{
|
||||
@ -55,7 +55,7 @@ PID::PID(double* Input, double* Output, double* Setpoint,
|
||||
* pid Output needs to be computed. returns true when the output is computed,
|
||||
* false when nothing has been done.
|
||||
**********************************************************************************/
|
||||
bool PID::Compute()
|
||||
bool PID2::Compute()
|
||||
{
|
||||
if(!inAuto) return false;
|
||||
unsigned long now = millis();
|
||||
@ -99,7 +99,7 @@ bool PID::Compute()
|
||||
* it's called automatically from the constructor, but tunings can also
|
||||
* be adjusted on the fly during normal operation
|
||||
******************************************************************************/
|
||||
void PID::SetTunings(double Kp, double Ki, double Kd, int POn)
|
||||
void PID2::SetTunings(double Kp, double Ki, double Kd, int POn)
|
||||
{
|
||||
if (Kp<0 || Ki<0 || Kd<0) return;
|
||||
|
||||
@ -124,14 +124,14 @@ void PID::SetTunings(double Kp, double Ki, double Kd, int POn)
|
||||
/* SetTunings(...)*************************************************************
|
||||
* Set Tunings using the last-rembered POn setting
|
||||
******************************************************************************/
|
||||
void PID::SetTunings(double Kp, double Ki, double Kd){
|
||||
void PID2::SetTunings(double Kp, double Ki, double Kd){
|
||||
SetTunings(Kp, Ki, Kd, pOn);
|
||||
}
|
||||
|
||||
/* SetSampleTime(...) *********************************************************
|
||||
* sets the period, in Milliseconds, at which the calculation is performed
|
||||
******************************************************************************/
|
||||
void PID::SetSampleTime(int NewSampleTime)
|
||||
void PID2::SetSampleTime(int NewSampleTime)
|
||||
{
|
||||
if (NewSampleTime > 0)
|
||||
{
|
||||
@ -151,7 +151,7 @@ void PID::SetSampleTime(int NewSampleTime)
|
||||
* want to clamp it from 0-125. who knows. at any rate, that can all be done
|
||||
* here.
|
||||
**************************************************************************/
|
||||
void PID::SetOutputLimits(double Min, double Max)
|
||||
void PID2::SetOutputLimits(double Min, double Max)
|
||||
{
|
||||
if(Min >= Max) return;
|
||||
outMin = Min;
|
||||
@ -172,7 +172,7 @@ void PID::SetOutputLimits(double Min, double Max)
|
||||
* when the transition from manual to auto occurs, the controller is
|
||||
* automatically initialized
|
||||
******************************************************************************/
|
||||
void PID::SetMode(int Mode)
|
||||
void PID2::SetMode(int Mode)
|
||||
{
|
||||
bool newAuto = (Mode == AUTOMATIC);
|
||||
if(newAuto && !inAuto)
|
||||
@ -186,7 +186,7 @@ void PID::SetMode(int Mode)
|
||||
* does all the things that need to happen to ensure a bumpless transfer
|
||||
* from manual to automatic mode.
|
||||
******************************************************************************/
|
||||
void PID::Initialize()
|
||||
void PID2::Initialize()
|
||||
{
|
||||
outputSum = *myOutput;
|
||||
lastInput = *myInput;
|
||||
@ -200,7 +200,7 @@ void PID::Initialize()
|
||||
* know which one, because otherwise we may increase the output when we should
|
||||
* be decreasing. This is called from the constructor.
|
||||
******************************************************************************/
|
||||
void PID::SetControllerDirection(int Direction)
|
||||
void PID2::SetControllerDirection(int Direction)
|
||||
{
|
||||
if(inAuto && Direction !=controllerDirection)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user