Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Name uniquness #91

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 26 additions & 26 deletions PID_v1.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**********************************************************************************************
* Arduino PID Library - Version 1.2.1
* Arduino Makeblock PID Library - Version 0.0.1
* by Brett Beauregard <[email protected]> brettbeauregard.com
*
* This Library is licensed under the MIT License
Expand All @@ -14,24 +14,24 @@
#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;
myInput = Input;
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;
}
Expand All @@ -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)
{

}
Expand All @@ -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();
Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -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)
{
Expand All @@ -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;
Expand All @@ -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;
}
Expand All @@ -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;
Expand All @@ -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);
}
Expand All @@ -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;}

8 changes: 4 additions & 4 deletions PID_v1.h
Original file line number Diff line number Diff line change
@@ -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
{


Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion README.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
***************************************************************
* Arduino PID Library - Version 1.2.1
* Arduino Makeblock PID Library - Version 0.0.1
* by Brett Beauregard <[email protected]> brettbeauregard.com
*
* This Library is licensed under the MIT License
Expand Down
2 changes: 1 addition & 1 deletion keywords.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#######################################
####################################### PID2 0.0.1
# Syntax Coloring Map For PID Library
#######################################

Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 4 additions & 4 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name=PID
version=1.2.1
name=PID2
version=0.0.1
author=Brett Beauregard
maintainer=Brett Beauregard
maintainer=[email protected]
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=*