Skip to content

Commit c601c20

Browse files
committed
Update
#### Version 2.3.2 - Removed fixed point calculations as the speed benefit was very minimal. - Prevent integral windup if output exceeds limits. - Added the following new functions that return the P, I and D terms of the calculation. ```c++ float GetPeTerm(); // proportional on error component of output float GetPmTerm(); // proportional on measurement component of output float GetIterm(); // integral component of output float GetDterm(); // derivative component of output ``` ####
1 parent 77c028b commit c601c20

File tree

6 files changed

+96
-152
lines changed

6 files changed

+96
-152
lines changed

README.md

Lines changed: 27 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# QuickPID [![arduino-library-badge](https://www.ardu-badge.com/badge/QuickPID.svg?)](https://www.ardu-badge.com/QuickPID)
22

3-
QuickPID is a fast fixed/floating point implementation of the Arduino PID library with built-in [AutoTune](https://github.com/Dlloydev/QuickPID/wiki/AutoTune) class as a dynamic object to reduce memory if not used, thanks to contributions by [gnalbandian (Gonzalo)](https://github.com/gnalbandian). This controller can automatically determine and set parameters `Kp, Ki, Kd`. Additionally the Ultimate Gain `Ku`, Ultimate Period `Tu`, Dead Time `td` and determine how easy the process is to control. There are 10 tuning rules available to choose from. Also available is a POn setting that controls the mix of Proportional on Error to Proportional on Measurement.
4-
5-
### About
6-
7-
This PID controller provides a shortened *read-compute-write* cycle by taking advantage of fixed point math and using a fast analog read function.
3+
QuickPID is an updated implementation of the Arduino PID library with a built-in [AutoTune](https://github.com/Dlloydev/QuickPID/wiki/AutoTune) class as a dynamic object to reduce memory if not used, thanks to contributions by [gnalbandian (Gonzalo)](https://github.com/gnalbandian). This controller can automatically determine and set parameters `Kp, Ki, Kd`. Additionally the Ultimate Gain `Ku`, Ultimate Period `Tu`, Dead Time `td` and determine how easy the process is to control. There are 10 tuning rules available to choose from. Also available is a POn setting that controls the mix of Proportional on Error to Proportional on Measurement.
84

95
### Features
106

@@ -18,7 +14,7 @@ This example allows you to experiment with the AutoTunePID class, various tuning
1814

1915
### Direct and Reverse Controller Action
2016

21-
If a positive error increases the controller's output, the controller is said to be direct acting (i.e. heating process). When a positive error decreases the controller's output, the controller is said to be reverse acting (i.e. cooling process). When the controller is set to `REVERSE` acting, the sign of the `error` and `dInput` (derivative of Input) is internally changed. All operating ranges and limits remain the same. To simulate a `REVERSE` acting process from a process that's `DIRECT` acting, the Input value needs to be "flipped". That is, if your reading from a 10-bit ADC with 0-1023 range, the input value used is (1023 - reading). See the examples `AutoTune_Filter_DIRECT.ino` and `AutoTune_Filter_REVERSE.ino` for details.
17+
If a positive error increases the controller's output, the controller is said to be direct acting (i.e. heating process). When a positive error decreases the controller's output, the controller is said to be reverse acting (i.e. cooling process). When the controller is set to `REVERSE` acting, the sign of the `error` and `dInput` (derivative of Input) is internally changed. All operating ranges and limits remain the same. To simulate a `REVERSE` acting process from a process that's `DIRECT` acting, the Input value needs to be "flipped". That is, if your reading from a 10-bit ADC with 0-1023 range, the input value used is (1023 - reading). See the examples [AutoTune_Filter_DIRECT.ino](https://github.com/Dlloydev/QuickPID/blob/master/examples/AutoTune_Filter_DIRECT/AutoTune_Filter_DIRECT.ino) and [AutoTune_Filter_REVERSE.ino](https://github.com/Dlloydev/QuickPID/blob/master/examples/AutoTune_Filter_REVERSE/AutoTune_Filter_REVERSE.ino) for details.
2218

2319
### Functions
2420

@@ -31,11 +27,11 @@ QuickPID::QuickPID(float* Input, float* Output, float* Setpoint,
3127
3228
- `Input`, `Output`, and `Setpoint` are pointers to the variables holding these values.
3329
- `Kp`, `Ki`, and `Kd` are the PID proportional, integral, and derivative gains.
34-
- `POn` is the Proportional on Error weighting value (0.0-1.0). This controls the mix of Proportional on Error (PonE) and Proportional on Measurement (PonM) that's used in the compute algorithm. Note that POn controls the PonE amount, where the remainder (1-PonE) is the PonM amount. Also, the default POn is 1
30+
- `POn` is the Proportional on Error weighting value with range 0.0-1.0 and default 1.0 (100% Proportional on Error). This controls the mix of Proportional on Error to Proportional on Measurement.
3531
3632
![image](https://user-images.githubusercontent.com/63488701/118383726-986b6e80-b5ce-11eb-94b8-fdbddd4c914e.png)
3733
38-
- `ControllerDirection` Either DIRECT or REVERSE determines which direction the output will move for a given error. DIRECT is most common.
34+
- `ControllerDirection` Either DIRECT or REVERSE determines which direction the output will move for a given error.
3935
4036
```c++
4137
QuickPID::QuickPID(float* Input, float* Output, float* Setpoint,
@@ -110,22 +106,23 @@ void QuickPID::SetControllerDirection(uint8_t Direction)
110106
111107
The PID will either be connected to a DIRECT acting process (+Output leads to +Input) or a REVERSE acting process (+Output leads to -Input.) We need to know which one, because otherwise we may increase the output when we should be decreasing. This is called from the constructor.
112108
113-
#### Display_Functions
109+
#### PID Query Functions
114110
115111
```c++
116-
float QuickPID::GetKp();
117-
float QuickPID::GetKi();
118-
float QuickPID::GetKd();
119-
float QuickPID::GetKu();
120-
float QuickPID::GetTu();
121-
float QuickPID::GetTd();
122-
uint8_t QuickPID::GetMode();
123-
uint8_t QuickPID::GetDirection();
112+
float GetKp(); // proportional gain
113+
float GetKi(); // integral gain
114+
float GetKd(); // derivative gain
115+
float GetPeTerm(); // proportional on error component of output
116+
float GetPmTerm(); // proportional on measurement component of output
117+
float GetIterm(); // integral component of output
118+
float GetDterm(); // derivative component of output
119+
mode_t GetMode(); // MANUAL (0) or AUTOMATIC (1)
120+
direction_t GetDirection(); // DIRECT (0) or REVERSE (1)
124121
```
125122

126-
These functions query the internal state of the PID. They're here for display purposes.
123+
These functions query the internal state of the PID.
127124

128-
#### Utility_Functions
125+
#### Utility Functions
129126

130127
```c++
131128
int QuickPID::analogReadFast(int ADCpin)
@@ -137,76 +134,20 @@ A faster configuration of `analogRead()`where a preset of 32 is used. If the ar
137134
138135
Use this link for reference. Note that if you're using QuickPID, there's no need to install the AnalogWrite library as this feature is already included.
139136
140-
#### Change Log
141-
142-
#### Version 2.3.1
143-
144-
- Resolved `Kp` windup as noted in issue #6. Algorithm reverts to upstream library, but with fixed point math option and newer controller direction method maintained.
145-
- Updated AutoTune examples and documentation.
146-
- Default AutoTune `outputStep` value in examples (and documentation) is now 5.
147-
148-
#### Version 2.3.0
149-
150-
- New AutoTune class added as a dynamic object to reduce memory if not used, thanks to contributions by [gnalbandian (Gonzalo)](https://github.com/gnalbandian).
151-
- AutoTune now works for a reverse acting controller.
152-
- AutoTune configuration parameters include outputStep, hysteresis, setpoint, output, direction and printOrPlotter.
153-
- Defined tuningMethod as an enum.
154-
- Updated AnalogWrite methods for ESP32/ESP32-S2.
155-
156-
#### Version 2.2.8
157-
158-
- AutoTune is now independent of the QuickPID library and can be run from a sketch. AutoTune is now non-blocking, no timeouts are required and it uses Input and Output variables directly.
159-
160-
#### Version 2.2.7
161-
162-
- Fixed REVERSE acting controller mode.
163-
- now using src folder for source code
164-
- replaced defines with enumerated types and inline functions
165-
166-
#### Version 2.2.6
167-
168-
- Changed Input, Output and Setpoint parameters to float.
169-
- Updated compatibility with the ESP32 AnalogWrite
170-
171-
#### Version 2.2.2
137+
### [Change Log](https://github.com/Dlloydev/QuickPID/wiki/Change-Log)
172138
173-
- Added compatibility with the ESP32 Arduino framework
174-
- Added full featured AnalogWrite methods for ESP32 and ESP32S2
139+
#### Latest Version 2.3.2
175140
176-
#### Version 2.2.1
141+
- Removed fixed point calculations as the speed benefit was very minimal.
142+
- Prevent integral windup if output exceeds limits.
143+
- Added the following new functions that return the P, I and D terms of the calculation.
177144
178-
- Even faster AutoTune function
179-
- AutoTune now determines the controllability of the process
180-
- Added AMIGO_PID tuning rule
181-
- Added `GetTd()` function to display dead time
182-
183-
#### Version 2.2.0
184-
185-
- Improved AutoTune function
186-
- Added 8 tuning rules
187-
- Added `GetKu()` function to display ultimate gain
188-
- Added `GetTu()` function to display ultimate period (time constant)
189-
- Updated example and documentation
190-
191-
#### Version 2.1.0
192-
193-
- Added AutoTune function and documentation
194-
195-
- Added AutoTune_RC_Filter example and documentation
196-
197-
#### Version 2.0.5
198-
199-
- Added MIT license text file
200-
- POn defaults to 1
201-
202-
#### Version 2.0.4
203-
204-
- Added `QuickPID_AdaptiveTunings.ino`, `QuickPID_Basic.ino`, `QuickPID_PonM.ino` and `QuickPID_RelayOutput.ino` to the examples folder.
205-
- `QuickPID_RelayOutput.ino` has the added feature of `minWindow` setting that sets the minimum on time for the relay.
206-
207-
#### Version 2.0.3
208-
209-
- Initial Version
145+
```c++
146+
float GetPeTerm(); // proportional on error component of output
147+
float GetPmTerm(); // proportional on measurement component of output
148+
float GetIterm(); // integral component of output
149+
float GetDterm(); // derivative component of output
150+
```
210151

211152
------
212153

keywords.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ SetSampleTimeUs KEYWORD2
2323
GetKp KEYWORD2
2424
GetKi KEYWORD2
2525
GetKd KEYWORD2
26-
GetKu KEYWORD2
27-
GetTu KEYWORD2
28-
GetTd KEYWORD2
26+
GetPeTerm KEYWORD2
27+
GetPmTerm KEYWORD2
28+
GetIterm KEYWORD2
29+
GetDterm KEYWORD2
2930
GetMode KEYWORD2
3031
GetDirection KEYWORD2
3132
analogReadFast KEYWORD2

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"keywords": "PID, controller, signal",
44
"description": "A fast fixed/floating point PID controller with AutoTune and 10 tuning rules to choose from. This controller can automatically determine and set tuning parameters. Compatible with most Arduino and ESP32 boards.",
55
"license": "MIT",
6-
"version": "2.3.1",
6+
"version": "2.3.2",
77
"url": "https://github.com/Dlloydev/QuickPID",
88
"include": "QuickPID",
99
"authors":

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=QuickPID
2-
version=2.3.1
2+
version=2.3.2
33
author=David Lloyd
44
maintainer=David Lloyd <dlloydev@testcor.ca>
55
sentence=A fast fixed/floating point PID controller with AutoTune and 10 tuning rules to choose from.

0 commit comments

Comments
 (0)