This commit is contained in:
clplaneguy 2019-04-21 12:37:55 +00:00 committed by GitHub
commit 3df9c635dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 37 additions and 37 deletions

View File

@ -1,5 +1,5 @@
/**********************************************************************************************
* Arduino PID Library - Version 1.2.1
* Arduino Makeblock PID Library - Version 0.0.1
* by Brett Beauregard <br3ttb@gmail.com> brettbeauregard.com
*
* This Library is licensed under the MIT License
@ -14,10 +14,10 @@
#include <PID_v1.h>
/*Constructor (...)*********************************************************
* The parameters specified here are those for for which we can't set up
* The parameters specified here are those 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;
@ -25,13 +25,13 @@ PID::PID(double* Input, double* Output, double* Setpoint,
mySetpoint = Setpoint;
inAuto = false;
PID::SetOutputLimits(0, 255); //default output limit corresponds to
//the arduino pwm limits
PID2::SetOutputLimits(0, 255); //default output limit corresponds to
//the arduino pwm limits
SampleTime = 100; //default Controller Sample Time is 0.1 seconds
SampleTime = 100; //default Controller Sample Time is 0.1 seconds
PID::SetControllerDirection(ControllerDirection);
PID::SetTunings(Kp, Ki, Kd, POn);
PID2::SetControllerDirection(ControllerDirection);
PID2::SetTunings(Kp, Ki, Kd, POn);
lastTime = millis()-SampleTime;
}
@ -41,9 +41,9 @@ 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)
:PID2::PID2(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();
@ -75,7 +75,7 @@ bool PID::Compute()
else if(outputSum < outMin) outputSum= outMin;
/*Add Proportional on Error, if P_ON_E is specified*/
double output;
double output;
if(pOnE) output = kp * error;
else output = 0;
@ -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,12 +172,12 @@ 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)
{ /*we just went from manual to auto*/
PID::Initialize();
PID2::Initialize();
}
inAuto = newAuto;
}
@ -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,11 +200,11 @@ 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)
{
kp = (0 - kp);
kp = (0 - kp);
ki = (0 - ki);
kd = (0 - kd);
}
@ -216,9 +216,9 @@ void PID::SetControllerDirection(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::GetKp(){ return dispKp; }
double PID::GetKi(){ return dispKi;}
double PID::GetKd(){ return dispKd;}
int PID::GetMode(){ return inAuto ? AUTOMATIC : MANUAL;}
int PID::GetDirection(){ return controllerDirection;}
double PID2::GetKp(){ return dispKp; }
double PID2::GetKi(){ return dispKi;}
double PID2::GetKd(){ return dispKd;}
int PID2::GetMode(){ return inAuto ? AUTOMATIC : MANUAL;}
int PID2::GetDirection(){ return controllerDirection;}

View File

@ -1,8 +1,8 @@
#ifndef PID_v1_h
#define PID_v1_h
#define LIBRARY_VERSION 1.2.1
#define LIBRARY_VERSION 1.2.2
class PID
class PID2
{
@ -17,11 +17,11 @@ class PID
#define P_ON_E 1
//commonly used functions **************************************************************************
PID(double*, double*, double*, // * constructor. links the PID to the Input, Output, and
PID2(double*, double*, double*, // * constructor. links the PID to the Input, Output, and
double, double, double, int, int);// Setpoint. Initial tuning parameters are also set here.
// (overload for specifying proportional mode)
PID(double*, double*, double*, // * constructor. links the PID to the Input, Output, and
PID2(double*, double*, double*, // * constructor. links the PID to the Input, Output, and
double, double, double, int); // Setpoint. Initial tuning parameters are also set here
void SetMode(int Mode); // * sets PID to either Manual (0) or Auto (non-0)

View File

@ -1,5 +1,5 @@
***************************************************************
* Arduino PID Library - Version 1.2.1
* Arduino Makeblock PID Library - Version 0.0.1
* by Brett Beauregard <br3ttb@gmail.com> brettbeauregard.com
*
* This Library is licensed under the MIT License

View File

@ -1,4 +1,4 @@
#######################################
####################################### PID2 0.0.1
# Syntax Coloring Map For PID Library
#######################################

View File

@ -1,5 +1,5 @@
{
"name": "PID",
"name": "PID2",
"keywords": "PID, controller, signal",
"description": "A PID controller seeks to keep some input variable close to a desired setpoint by adjusting an output. The way in which it does this can be 'tuned' by adjusting three parameters (P,I,D).",
"url": "http://playground.arduino.cc/Code/PIDLibrary",

View File

@ -1,9 +1,9 @@
name=PID
version=1.2.1
name=PID2
version=0.0.1
author=Brett Beauregard
maintainer=Brett Beauregard
maintainer=r2d2orc2po@yahoo.com
sentence=PID controller
paragraph=A PID controller seeks to keep some input variable close to a desired setpoint by adjusting an output. The way in which it does this can be 'tuned' by adjusting three parameters (P,I,D).
category=Signal Input/Output
category=Input/Output
url=http://playground.arduino.cc/Code/PIDLibrary
architectures=*