Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
Dlloydev committed Jan 5, 2022
1 parent 1f823ee commit 44fa110
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 500 deletions.
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@

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.

### Need Autotune?

#### 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)

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)

### Features

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).
Expand All @@ -16,7 +10,6 @@ Development began with a fork of the Arduino PID Library. Modifications and new

- [x] New functions added: `SetProportionalMode`, `SetDerivativeMode` and `SetAntiWindupMode`
- [x] `timer` mode for calling PID compute by an external timer function or ISR
- [x] `analogWrite()` support for ESP32 and ESP32-S2
- [x] Proportional on error `pOnError`, measurement `pOnMeas` or both `pOnErrorMeas` options
- [x] Derivative on error `dOnError` and measurement `dOnMeas` options
- [x] New PID Query Functions `GetPterm`, `GetIterm`, `GetDterm`, `GetPmode`, `GetDmode` and `GetAwMode`
Expand Down Expand Up @@ -103,3 +96,9 @@ void SetDerivativeMode(dMode dMode); // Set the dTerm, based error or
void SetAntiWindupMode(iAwMode iAwMode); // Set iTerm anti-windup to iAwCondition, iAwClamp or iAwOff
```
### Need Autotune?
#### 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)
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)
68 changes: 0 additions & 68 deletions examples/Autotune_PID_v1/Autotune_PID_v1.ino

This file was deleted.

71 changes: 0 additions & 71 deletions examples/Autotune_QuickPID/Autotune_QuickPID.ino

This file was deleted.

4 changes: 2 additions & 2 deletions library.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "QuickPID",
"version": "3.0.6",
"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.",
"version": "3.1.0",
"description": "A fast PID controller with multiple options. Various Integral anti-windup, Proportional, Derivative and timer control modes.",
"keywords": "PID, controller, signal, autotune, tuner, stune",
"repository":
{
Expand Down
6 changes: 3 additions & 3 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name=QuickPID
version=3.0.6
version=3.1.0
author=David Lloyd
maintainer=David Lloyd <dlloydev@testcor.ca>
sentence=A fast PID controller with timer mode and multiple options for Proportional, Derivative and Integral anti-windup modes of operation.
paragraph=Includes analogWrite compatibility for ESP32 and ESP32-S2.
sentence=A fast PID controller with multiple options. Various Integral anti-windup, Proportional and Derivative control modes.
paragraph=Optional external timer or ISR timing control.
category=Signal Input/Output
url=https://github.com/Dlloydev/QuickPID
architectures=*
8 changes: 4 additions & 4 deletions src/QuickPID.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**********************************************************************************
QuickPID Library for Arduino - Version 3.0.6
QuickPID Library for Arduino - Version 3.1.0
by dlloydev https://github.com/Dlloydev/QuickPID
Based on the Arduino PID_v1 Library. Licensed under the MIT License.
**********************************************************************************/
Expand All @@ -17,7 +17,7 @@
reliable defaults, so we need to have the user set them.
**********************************************************************************/
QuickPID::QuickPID(float* Input, float* Output, float* Setpoint,
float Kp, float Ki, float Kd,
float Kp = 0, float Ki = 0, float Kd = 0,
pMode pMode = pMode::pOnError,
dMode dMode = dMode::dOnMeas,
iAwMode iAwMode = iAwMode::iAwCondition,
Expand All @@ -37,7 +37,7 @@ QuickPID::QuickPID(float* Input, float* Output, float* Setpoint,
}

/* Constructor *********************************************************************
To allow using proportional on error without explicitly saying so.
To allow using pOnError, dOnMeas and iAwCondition without explicitly saying so.
**********************************************************************************/
QuickPID::QuickPID(float* Input, float* Output, float* Setpoint,
float Kp, float Ki, float Kd, Action action)
Expand All @@ -52,7 +52,7 @@ QuickPID::QuickPID(float* Input, float* Output, float* Setpoint,
Simplified constructor which uses defaults for remaining parameters.
**********************************************************************************/
QuickPID::QuickPID(float* Input, float* Output, float* Setpoint)
: QuickPID::QuickPID(Input, Output, Setpoint, defKp, defKi, defKd,
: QuickPID::QuickPID(Input, Output, Setpoint, dispKp, dispKi, dispKd,
pmode = pMode::pOnError,
dmode = dMode::dOnMeas,
iawmode = iAwMode::iAwCondition,
Expand Down
14 changes: 3 additions & 11 deletions src/QuickPID.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,9 @@ class QuickPID {

void Initialize();

static constexpr float defKp = 0; // default controller gains
static constexpr float defKi = 0;
static constexpr float defKd = 0;

float dispKp; // tuning parameters for display purposes.
float dispKi;
float dispKd;
float dispKp = 0; // for defaults and display
float dispKi = 0;
float dispKd = 0;
float pTerm;
float iTerm;
float dTerm;
Expand All @@ -110,8 +106,4 @@ class QuickPID {
float outputSum, outMin, outMax, error, lastError, lastInput;

}; // class QuickPID

#if (defined(ESP32) || defined(ARDUINO_ARCH_ESP32))
#include "analogWrite.h"
#endif
#endif // QuickPID.h
Loading

0 comments on commit 44fa110

Please sign in to comment.