Skip to content

Commit

Permalink
Fix #2
Browse files Browse the repository at this point in the history
  • Loading branch information
Dlloydev committed Mar 29, 2021
1 parent 12697fc commit 50c2f8b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
12 changes: 6 additions & 6 deletions QuickPID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
reliable defaults, so we need to have the user set them.
**********************************************************************************/
QuickPID::QuickPID(int16_t* Input, int16_t* Output, int16_t* Setpoint,
float Kp, float Ki, float Kd, float POn = 1, bool ControllerDirection = 0)
float Kp, float Ki, float Kd, float POn = 1, uint8_t ControllerDirection = 0)
{
myOutput = Output;
myInput = Input;
Expand All @@ -41,7 +41,7 @@ QuickPID::QuickPID(int16_t* Input, int16_t* Output, int16_t* Setpoint,
**********************************************************************************/

QuickPID::QuickPID(int16_t* Input, int16_t* Output, int16_t* Setpoint,
float Kp, float Ki, float Kd, bool ControllerDirection)
float Kp, float Ki, float Kd, uint8_t ControllerDirection)
: QuickPID::QuickPID(Input, Output, Setpoint, Kp, Ki, Kd, pOn = 1, ControllerDirection = 0)
{

Expand Down Expand Up @@ -222,7 +222,7 @@ void QuickPID::SetOutputLimits(int16_t Min, int16_t Max)
when the transition from manual to auto occurs, the controller is
automatically initialized
******************************************************************************/
void QuickPID::SetMode(bool Mode)
void QuickPID::SetMode(uint8_t Mode)
{
bool newAuto = (Mode == AUTOMATIC);
if (newAuto && !inAuto)
Expand All @@ -249,7 +249,7 @@ void QuickPID::Initialize()
know which one, because otherwise we may increase the output when we should
be decreasing. This is called from the constructor.
******************************************************************************/
void QuickPID::SetControllerDirection(bool Direction)
void QuickPID::SetControllerDirection(uint8_t Direction)
{
if (inAuto && Direction != controllerDirection)
{
Expand Down Expand Up @@ -283,10 +283,10 @@ float QuickPID::GetTu() {
float QuickPID::GetTd() {
return dispTd;
}
bool QuickPID::GetMode() {
uint8_t QuickPID::GetMode() {
return inAuto ? AUTOMATIC : MANUAL;
}
bool QuickPID::GetDirection() {
uint8_t QuickPID::GetDirection() {
return controllerDirection;
}

Expand Down
14 changes: 7 additions & 7 deletions QuickPID.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ class QuickPID
// commonly used functions ************************************************************************************

// Constructor. Links the PID to Input, Output, Setpoint and initial Tuning Parameters.
QuickPID(int16_t*, int16_t*, int16_t*, float, float, float, float, bool);
QuickPID(int16_t*, int16_t*, int16_t*, float, float, float, float, uint8_t);

// Overload constructor with proportional mode. Links the PID to Input, Output, Setpoint and Tuning Parameters.
QuickPID(int16_t*, int16_t*, int16_t*, float, float, float, bool);
QuickPID(int16_t*, int16_t*, int16_t*, float, float, float, uint8_t);

// Sets PID to either Manual (0) or Auto (non-0).
void SetMode(bool Mode);
void SetMode(uint8_t Mode);

// Performs the PID calculation. It should be called every time loop() cycles. ON/OFF and calculation frequency
// can be set using SetMode and SetSampleTime respectively.
Expand All @@ -47,7 +47,7 @@ class QuickPID

// Sets the Direction, or "Action" of control. DIRECT 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 SetControllerDirection(bool);
void SetControllerDirection(uint8_t);

// Sets the sample time in milliseconds with which each PID calculation is performed. Default is 100.
void SetSampleTimeUs(uint32_t);
Expand All @@ -59,8 +59,8 @@ class QuickPID
float GetKu(); // Ultimate Gain
float GetTu(); // Ultimate Period
float GetTd(); // Dead Time
bool GetMode();
bool GetDirection();
uint8_t GetMode();
uint8_t GetDirection();

// Utility functions ******************************************************************************************
int analogReadFast(int);
Expand Down Expand Up @@ -88,7 +88,7 @@ class QuickPID
float kpi; // proportional on error amount
float kpd; // proportional on measurement amount

bool controllerDirection;
uint8_t controllerDirection;

int16_t *myInput; // Pointers to the Input, Output, and Setpoint variables. This creates a
int16_t *myOutput; // hard link between the variables and the PID, freeing the user from having
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "QuickPID",
"keywords": "PID, controller, signal",
"description": "A fast fixed/floating point PID controller with AutoTune and 8 tuning rules to choose from. This controller can automatically determine and set tuning parameters. An added feature is contolling the mix of Proportional on Error to Proportional on Measurement.",
"description": "A fast fixed/floating point PID controller with AutoTune and 9 tuning rules to choose from. This controller can automatically determine and set tuning parameters. An added feature is contolling the mix of Proportional on Error to Proportional on Measurement.",
"url": "https://github.com/Dlloydev/QuickPID",
"include": "QuickPID",
"authors":
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name=QuickPID
version=2.2.1
author=David Lloyd
maintainer=David Lloyd <dlloydev@testcor.ca>
sentence=A fast fixed/floating point PID controller with AutoTune and 8 tuning rules to choose from.
sentence=A fast fixed/floating point PID controller with AutoTune and 9 tuning rules to choose from.
paragraph=This controller can automatically determine and set tuning parameters. An added feature is contolling the mix of Proportional on Error to Proportional on Measurement.
category=Signal Input/Output
url=https://github.com/Dlloydev/QuickPID
Expand Down

0 comments on commit 50c2f8b

Please sign in to comment.