Skip to content

Commit 44fa110

Browse files
committed
Update
- Since [ESP32 Arduino 2.0.1](https://github.com/espressif/arduino-esp32/releases/tag/2.0.1) or newer has analogWrite basic support based on LEDC, the included library [ESP32-ESP32S2-AnalogWrite](https://github.com/Dlloydev/ESP32-ESP32S2-AnalogWrite) has been removed from QuickPID. Please Install SP32-ESP32S2-AnalogWrite separately if you require its advanced pin management or other unique features. - Uses dispKp = 0, dispKi = 0 and dispKd = 0 for both display purposes and defaults. Removed defKp, defKi and defKd. - [Autotune_QuickPID.ino](https://github.com/Dlloydev/sTune/blob/main/examples/Autotune_QuickPID/Autotune_QuickPID.ino) example is now at the [sTune](https://github.com/Dlloydev/sTune) repository.
1 parent 1f823ee commit 44fa110

File tree

9 files changed

+18
-500
lines changed

9 files changed

+18
-500
lines changed

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22

33
QuickPID is an updated implementation of the Arduino PID library with additional features for PID control. By default, this implementation closely follows the method of processing the p,i,d terms as in the PID_v1 library except for using a more advanced anti-windup mode. Integral anti-windup can be based on conditionally using PI terms to provide some integral correction, prevent deep saturation and reduce overshoot. Anti-windup can also be based on clamping only, or it can be turned completely off. Also, the proportional term can be based on error, measurement, or both. The derivative term can be based on error or measurement. PID controller modes include timer, which allows external timer or ISR timing control.
44

5-
### Need Autotune?
6-
7-
#### Get [sTune](https://github.com/Dlloydev/sTune) [![arduino-library-badge](https://camo.githubusercontent.com/2f6685943640fc03f25d1851ccbb5dbcd5963d9e3c26341c9f2b1c0f564c9016/68747470733a2f2f7777772e617264752d62616467652e636f6d2f62616467652f7354756e652e7376673f)](https://www.ardu-badge.com/sTune) [![PlatformIO Registry](https://camo.githubusercontent.com/269bbd52c6be846bab52a8afe727604d3bce8e7f068e317e36042fe3c9330203/68747470733a2f2f6261646765732e72656769737472792e706c6174666f726d696f2e6f72672f7061636b616765732f646c6c6f796465762f6c6962726172792f7354756e652e737667)](https://registry.platformio.org/packages/libraries/dlloydev/sTune)
8-
9-
A very fast autotuner that's capable of on-the-fly tunings. Example: [Autotune_QuickPID.ino](https://github.com/Dlloydev/QuickPID/blob/master/examples/Autotune_QuickPID/Autotune_QuickPID.ino)
10-
115
### Features
126

137
Development began with a fork of the Arduino PID Library. Modifications and new features have been added as described in the [releases](https://github.com/Dlloydev/QuickPID/releases).
@@ -16,7 +10,6 @@ Development began with a fork of the Arduino PID Library. Modifications and new
1610

1711
- [x] New functions added: `SetProportionalMode`, `SetDerivativeMode` and `SetAntiWindupMode`
1812
- [x] `timer` mode for calling PID compute by an external timer function or ISR
19-
- [x] `analogWrite()` support for ESP32 and ESP32-S2
2013
- [x] Proportional on error `pOnError`, measurement `pOnMeas` or both `pOnErrorMeas` options
2114
- [x] Derivative on error `dOnError` and measurement `dOnMeas` options
2215
- [x] New PID Query Functions `GetPterm`, `GetIterm`, `GetDterm`, `GetPmode`, `GetDmode` and `GetAwMode`
@@ -103,3 +96,9 @@ void SetDerivativeMode(dMode dMode); // Set the dTerm, based error or
10396
void SetAntiWindupMode(iAwMode iAwMode); // Set iTerm anti-windup to iAwCondition, iAwClamp or iAwOff
10497
```
10598
99+
### Need Autotune?
100+
101+
#### Get [sTune](https://github.com/Dlloydev/sTune) [![arduino-library-badge](https://www.ardu-badge.com/badge/sTune.svg?)](https://www.ardu-badge.com/sTune) [![PlatformIO Registry](https://badges.registry.platformio.org/packages/dlloydev/library/sTune.svg)](https://registry.platformio.org/packages/libraries/dlloydev/sTune)
102+
103+
A very fast autotuner capable of on-the-fly tunings and more. Example: [Autotune_QuickPID.ino](https://github.com/Dlloydev/sTune/blob/main/examples/Autotune_QuickPID/Autotune_QuickPID.ino)
104+

examples/Autotune_PID_v1/Autotune_PID_v1.ino

Lines changed: 0 additions & 68 deletions
This file was deleted.

examples/Autotune_QuickPID/Autotune_QuickPID.ino

Lines changed: 0 additions & 71 deletions
This file was deleted.

library.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "QuickPID",
3-
"version": "3.0.6",
4-
"description": "A fast PID controller with timer mode and multiple options for Proportional, Derivative and Integral anti-windup modes of operation. Includes analogWrite compatibility for ESP32 and ESP32-S2.",
3+
"version": "3.1.0",
4+
"description": "A fast PID controller with multiple options. Various Integral anti-windup, Proportional, Derivative and timer control modes.",
55
"keywords": "PID, controller, signal, autotune, tuner, stune",
66
"repository":
77
{

library.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name=QuickPID
2-
version=3.0.6
2+
version=3.1.0
33
author=David Lloyd
44
maintainer=David Lloyd <[email protected]>
5-
sentence=A fast PID controller with timer mode and multiple options for Proportional, Derivative and Integral anti-windup modes of operation.
6-
paragraph=Includes analogWrite compatibility for ESP32 and ESP32-S2.
5+
sentence=A fast PID controller with multiple options. Various Integral anti-windup, Proportional and Derivative control modes.
6+
paragraph=Optional external timer or ISR timing control.
77
category=Signal Input/Output
88
url=https://github.com/Dlloydev/QuickPID
99
architectures=*

src/QuickPID.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**********************************************************************************
2-
QuickPID Library for Arduino - Version 3.0.6
2+
QuickPID Library for Arduino - Version 3.1.0
33
by dlloydev https://github.com/Dlloydev/QuickPID
44
Based on the Arduino PID_v1 Library. Licensed under the MIT License.
55
**********************************************************************************/
@@ -17,7 +17,7 @@
1717
reliable defaults, so we need to have the user set them.
1818
**********************************************************************************/
1919
QuickPID::QuickPID(float* Input, float* Output, float* Setpoint,
20-
float Kp, float Ki, float Kd,
20+
float Kp = 0, float Ki = 0, float Kd = 0,
2121
pMode pMode = pMode::pOnError,
2222
dMode dMode = dMode::dOnMeas,
2323
iAwMode iAwMode = iAwMode::iAwCondition,
@@ -37,7 +37,7 @@ QuickPID::QuickPID(float* Input, float* Output, float* Setpoint,
3737
}
3838

3939
/* Constructor *********************************************************************
40-
To allow using proportional on error without explicitly saying so.
40+
To allow using pOnError, dOnMeas and iAwCondition without explicitly saying so.
4141
**********************************************************************************/
4242
QuickPID::QuickPID(float* Input, float* Output, float* Setpoint,
4343
float Kp, float Ki, float Kd, Action action)
@@ -52,7 +52,7 @@ QuickPID::QuickPID(float* Input, float* Output, float* Setpoint,
5252
Simplified constructor which uses defaults for remaining parameters.
5353
**********************************************************************************/
5454
QuickPID::QuickPID(float* Input, float* Output, float* Setpoint)
55-
: QuickPID::QuickPID(Input, Output, Setpoint, defKp, defKi, defKd,
55+
: QuickPID::QuickPID(Input, Output, Setpoint, dispKp, dispKi, dispKd,
5656
pmode = pMode::pOnError,
5757
dmode = dMode::dOnMeas,
5858
iawmode = iAwMode::iAwCondition,

src/QuickPID.h

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,9 @@ class QuickPID {
8181

8282
void Initialize();
8383

84-
static constexpr float defKp = 0; // default controller gains
85-
static constexpr float defKi = 0;
86-
static constexpr float defKd = 0;
87-
88-
float dispKp; // tuning parameters for display purposes.
89-
float dispKi;
90-
float dispKd;
84+
float dispKp = 0; // for defaults and display
85+
float dispKi = 0;
86+
float dispKd = 0;
9187
float pTerm;
9288
float iTerm;
9389
float dTerm;
@@ -110,8 +106,4 @@ class QuickPID {
110106
float outputSum, outMin, outMax, error, lastError, lastInput;
111107

112108
}; // class QuickPID
113-
114-
#if (defined(ESP32) || defined(ARDUINO_ARCH_ESP32))
115-
#include "analogWrite.h"
116-
#endif
117109
#endif // QuickPID.h

0 commit comments

Comments
 (0)