You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+38-15Lines changed: 38 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# QuickPID
2
2
3
-
A fast hybrid fixed-point and floating-point PID controller for Arduino.
3
+
QuickPID is a fast fixed/floating point implementation of the Arduino PID library with built-in AutoTune function. This controller can automatically determine and set parameters (Kp, Ki, Kd). The POn setting controls the mix of Proportional on Errror to Proportional on Measurement and can be used to set the desired amount of overshoot.
4
4
5
5
### About
6
6
@@ -11,7 +11,8 @@ This PID controller provides a faster *read-compute-write* cycle than alternativ
11
11
Development began with a fork of the Arduino PID Library. Some modifications and new features have been added as follows:
12
12
13
13
- Quicker hybrid fixed/floating point math in compute function
14
-
-`POn` parameter now controls the setpoint weighting of Proportional on Error and Proportional on Measurement
14
+
- Built-in `AutoTune()` function automatically determines and sets `Kp`, `Ki` and `Kd`. Also determines critical gain `Ku` and critical period `Tu` of the control system
15
+
-`POn` parameter now controls the setpoint weighting and mix of Proportional on Error to Proportional on Measurement
15
16
- Reorganized and more efficient PID algorithm
16
17
- micros() timing resolution
17
18
- Faster analog read function
@@ -30,15 +31,15 @@ Development began with a fork of the Arduino PID Library. Some modifications and
30
31
31
32
### Self Test Example (RC Filter):
32
33
33
-
[This example](https://github.com/Dlloydev/QuickPID/wiki/QuickPID_RC_Filter) allows you to experiment with the four tuning parameters.
34
+
[This example](https://github.com/Dlloydev/QuickPID/wiki/AutoTune_RC_Filter) allows you to experiment with the AutoTune and POn control on an RC filter.
34
35
35
36
### Simplified PID Algorithm
36
37
37
38
```c++
38
39
outputSum += (kpi * error) - (kpd * dInput);
39
40
```
40
41
41
-
The new `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 pOn variable controls the setpoint weighting of Proportional on Error and Proportional on Measurement. The gains for `error` (`kpi`) and measurement `dInput` (`kpd`) are calculated as follows:
42
+
The new `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 pOn variable controls the setpoint weighting of Proportional on Error and Proportional on Measurement. The gains for `error` (`kpi`) and measurement `dInput` (`kpd`) are calculated as follows:
42
43
43
44
```c++
44
45
kpi = kp * pOn + ki;
@@ -77,6 +78,33 @@ bool QuickPID::Compute()
77
78
78
79
This function contains the PID algorithm and it should be called once every loop(). Most of the time it will just return false without doing anything. However, at a frequency specified by `SetSampleTime` it will calculate a new Output and return true.
79
80
81
+
#### AutoTune
82
+
83
+
```c++
84
+
voidQuickPID::AutoTune(int inputPin, int outputPin, int tuningRule, int Print = 0, uint32_t timeout = 30)
85
+
```
86
+
87
+
The `AutoTune()` function automatically determines and sets `Kp`, `Ki` and `Kd`. It also determines the critical gain `Ku` and critical period `Tu` of the control system.
88
+
89
+
`int tuningRule = 0; // PID(0), PI(1)`
90
+
91
+
Selects the appropriate Ziegler–Nichols tuning rule for the PID or PI type controller.
| PID | `0.6 * Ku` | `1.2 * Ku / Tu` | `0.075 * Ku * Tu` |
97
+
98
+
`int Print = 0; // on(1), off(0)`
99
+
100
+
When using Serial Monitor, turn on serial print output to view the AutoTune status and results. When using the Serial Plotter, turn off the AutoTune print output to prevent plot labels from being overwritten.
101
+
102
+
`uint32_t timeout = 30`
103
+
104
+
Sets the AutoTune timeout where the default is 30 seconds.
105
+
106
+
For more inormation, see [QuickPID AutoTune.](https://github.com/Dlloydev/QuickPID/wiki/AutoTune)
107
+
80
108
#### SetTunings
81
109
82
110
```c++
@@ -150,21 +178,16 @@ These functions query the internal state of the PID. They're here for display pu
150
178
intQuickPID::analogReadFast(int ADCpin)
151
179
```
152
180
153
-
A faster configuration of `analogRead()`where a preset of 32 is used. Works with the following defines:
154
-
155
-
`__AVR_ATmega328P__`
181
+
A faster configuration of `analogRead()`where a preset of 32 is used. If the architecture definition isn't found, normal `analogRead()`is used to return a value.
156
182
157
-
`__AVR_ATtiny_Zero_One__`
158
-
159
-
`__AVR_ATmega_Zero__`
160
-
161
-
`__AVR_DA__`
183
+
### Change Log
162
184
163
-
If the definition isn't found, normal `analogRead()`is used to return a value.
185
+
#### Version 2.1.0 (latest)
164
186
165
-
### Change Log
187
+
- Added AutoTune function and documentation
188
+
- Added AutoTune_RC_Filter example and documentation
0 commit comments