From ec2ecdd97ade76cb233290ae6d2c72b18e58e5ea Mon Sep 17 00:00:00 2001 From: Dlloydev Date: Mon, 29 Mar 2021 00:04:52 -0400 Subject: [PATCH] Fix #1 --- QuickPID.cpp | 12 ++++++------ QuickPID.h | 14 +++++++------- library.json | 2 +- library.properties | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/QuickPID.cpp b/QuickPID.cpp index afc5680..59b2240 100644 --- a/QuickPID.cpp +++ b/QuickPID.cpp @@ -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; @@ -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) { @@ -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) @@ -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) { @@ -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; } diff --git a/QuickPID.h b/QuickPID.h index 77cd489..959c2b9 100644 --- a/QuickPID.h +++ b/QuickPID.h @@ -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. @@ -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); @@ -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); @@ -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 diff --git a/library.json b/library.json index e003537..d01749f 100644 --- a/library.json +++ b/library.json @@ -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": diff --git a/library.properties b/library.properties index 870bc40..6479169 100644 --- a/library.properties +++ b/library.properties @@ -2,7 +2,7 @@ name=QuickPID version=2.2.1 author=David Lloyd maintainer=David Lloyd -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