|
1 | 1 | # QuickPID [](https://www.ardu-badge.com/QuickPID)
|
2 | 2 |
|
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. |
| 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 | 4 |
|
5 | 5 | ### About
|
6 | 6 |
|
7 |
| -This PID controller provides a shortened *read-compute-write* cycle by using a reduced PID algorithm, taking advantage of fixed point math and using a fast analog read function. The `Ki` and `Kd` are scaled by time (µs) and the new `kpi` and `kpd` parameters are calculated in the `SetTunings()` function resulting in only two multiply operations required in `Compute()`. |
| 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. |
8 | 8 |
|
9 | 9 | ### Features
|
10 | 10 |
|
11 |
| -Development began with a fork of the Arduino PID Library. Modifications and new features have been added as described in the change log and below: |
12 |
| - |
13 |
| -- Quicker hybrid fixed/floating point math, efficient PID algorithm and micros() timing resolution. |
14 |
| -- Built-in `AutoTunePID` class as a dynamic object. AutoTune automatically determines and applies `Kp`, `Ki` and `Kd` tuning parameters and has 10 tuning rules to choose from. |
15 |
| -- Variable `POn` parameter controls the setpoint weighting and mix of Proportional on Error to Proportional on Measurement. |
16 |
| -- Includes [analogWrite](https://github.com/Dlloydev/ESP32-ESP32S2-AnalogWrite) for ESP32 boards. |
17 |
| - |
18 |
| -### Performance (16MHz ATmega328P) |
19 |
| - |
20 |
| -| `Compute()` | Kp | Ki | Kd | Step Time (µS) | |
21 |
| -| :---------- | ---- | ---- | ---- | -------------- | |
22 |
| -| QuickPID | 2.0 | 5.0 | 1.0 | 72 | |
23 |
| -| Arduino PID | 2.0 | 5.0 | 1.0 | 104 | |
| 11 | +Development began with a fork of the Arduino PID Library. Modifications and new features have been added as described in the change log. |
24 | 12 |
|
25 | 13 | ### [AutoTune RC Filter](https://github.com/Dlloydev/QuickPID/wiki/AutoTune_RC_Filter)
|
26 | 14 |
|
27 | 15 | This example allows you to experiment with the AutoTunePID class, various tuning rules and the POn control using ADC and PWM with RC filter. It automatically determines and sets the tuning parameters and works with both DIRECT and REVERSE acting controllers.
|
28 | 16 |
|
29 | 17 | #### [QuickPID WiKi ...](https://github.com/Dlloydev/QuickPID/wiki)
|
30 | 18 |
|
31 |
| -### Simplified PID Algorithm |
32 |
| - |
33 |
| -```c++ |
34 |
| -outputSum += (kpi * error) - (kpd * dInput); |
35 |
| -``` |
36 |
| - |
37 |
| -The `kpi` and `kpd` parameters are calculated in the `SetTunings()` function. This results in a simple and fast algorithm with only two multiply operations required. The gains for `error` (`kpi`) and measurement `dInput` (`kpd`) are calculated as follows: |
38 |
| - |
39 |
| -```c++ |
40 |
| - kpi = kp * pOn + ki; |
41 |
| - kpd = kp * (1 - pOn) + kd; |
42 |
| -``` |
43 |
| - |
44 | 19 | ### Direct and Reverse Controller Action
|
45 | 20 |
|
46 | 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.
|
@@ -79,7 +54,7 @@ This function contains the PID algorithm and it should be called once every loop
|
79 | 54 |
|
80 | 55 | #### [AutoTune](https://github.com/Dlloydev/QuickPID/wiki/AutoTune)
|
81 | 56 |
|
82 |
| -For use of AutoTune, refer to the examples `AutoTune_Filter_DIRECT.ino` and `AutoTune_Filter_REVERSE.ino` |
| 57 | +For use of AutoTune, refer to 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) |
83 | 58 |
|
84 | 59 | #### SetTunings
|
85 | 60 |
|
@@ -164,6 +139,12 @@ Use this link for reference. Note that if you're using QuickPID, there's no need
|
164 | 139 |
|
165 | 140 | #### Change Log
|
166 | 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 | +
|
167 | 148 | #### Version 2.3.0
|
168 | 149 |
|
169 | 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).
|
|
0 commit comments