Skip to content

Commit d264af5

Browse files
committed
Update
Assorted minor updates
1 parent bae8299 commit d264af5

File tree

7 files changed

+35
-31
lines changed

7 files changed

+35
-31
lines changed

README.md

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

33
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 are POn and DOn settings where POn controls the mix of Proportional on Error to Proportional on Measurement and DOn controls the mix of Derivative on Error to Derivative on Measurement.
44

5+
#### [QuickPID WiKi ...](https://github.com/Dlloydev/QuickPID/wiki)
6+
57
### Features
68

79
Development began with a fork of the Arduino PID Library. Modifications and new features have been added as described in the [change log](https://github.com/Dlloydev/QuickPID/wiki/Change-Log).
@@ -27,15 +29,15 @@ Development began with a fork of the Arduino PID Library. Modifications and new
2729
- [x] Determines how easy the process is to control
2830
- [x] Determines ultimate period `Tu`, dead time `td`, ultimate gain `Ku`, and tuning parameters `Kp, Ki, Kd`
2931

30-
### [AutoTune RC Filter](https://github.com/Dlloydev/QuickPID/wiki/AutoTune_RC_Filter)
32+
### [AutoTune](https://github.com/Dlloydev/QuickPID/wiki/AutoTune)
3133

32-
This example allows you to experiment with the AutoTunePID class, various tuning rules and the POn and DOn controls using ADC and PWM with RC filter. It automatically determines and sets the tuning parameters and works with both DIRECT and REVERSE acting controllers.
34+
#### [AutoTune Filter Examples](https://github.com/Dlloydev/QuickPID/wiki/AutoTune-Filter-Examples)
3335

34-
#### [QuickPID WiKi ...](https://github.com/Dlloydev/QuickPID/wiki)
36+
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) allow you to experiment with the AutoTunePID class, various tuning rules and the POn and DOn controls using ADC and PWM with RC filter. It automatically determines and sets the tuning parameters and works with both `DIRECT` and `REVERSE` acting controllers.
3537

36-
### Direct and Reverse Controller Action
38+
#### Direct and Reverse Controller Action
3739

38-
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.
40+
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).
3941

4042
### Functions
4143

@@ -70,10 +72,6 @@ bool QuickPID::Compute();
7072

7173
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.
7274

73-
#### [AutoTune](https://github.com/Dlloydev/QuickPID/wiki/AutoTune)
74-
75-
For examples using AutoTune, please refer to the examples folder.
76-
7775
#### SetTunings
7876

7977
```c++

examples/AutoTune_AVR_Interrupt_TIMER/AutoTune_AVR_Interrupt_TIMER.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ int output = 85; // 1/3 of range for symetrical waveform
2424
float Input, Output, Setpoint;
2525
float Kp = 0, Ki = 0, Kd = 0;
2626
bool pidLoop = false;
27-
static boolean computeNow = false;
27+
volatile bool computeNow = false;
2828

2929
QuickPID _myPID = QuickPID(&Input, &Output, &Setpoint, Kp, Ki, Kd, POn, DOn, QuickPID::DIRECT);
3030

examples/PID_AVR_Basic_Interrupt_TIMER/PID_AVR_Basic_Interrupt_TIMER.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#define PIN_INPUT 0
99
#define PIN_OUTPUT 3
1010
const uint32_t sampleTimeUs = 100000; // 100ms
11-
static boolean computeNow = false;
11+
volatile bool computeNow = false;
1212

1313
//Define Variables we'll be connecting to
1414
float Setpoint, Input, Output;

library.json

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
{
22
"name": "QuickPID",
3+
"version": "2.4.2",
4+
"description": "A fast PID controller with an AutoTune dynamic object, 10 tunung rules, Integral anti-windup, TIMER Mode, variable Proportional and Derivative on Error to Measurement and full-featured Arduino analogWrite compatibility for ESP32 and ESP32-S2.",
35
"keywords": "PID, controller, signal",
4-
"description": "A fast PID controller with AutoTune and 10 tuning rules. Compatible with most Arduino and ESP32 boards.",
5-
"license": "MIT",
6-
"version": "2.4.1",
7-
"url": "https://github.com/Dlloydev/QuickPID",
8-
"include": "QuickPID",
6+
"repository":
7+
{
8+
"type": "git",
9+
"url": "https://github.com/Dlloydev/QuickPID"
10+
},
911
"authors":
1012
[
1113
{
1214
"name": "David Lloyd"
15+
"email": "[email protected]",
16+
"url": "https://github.com/Dlloydev/QuickPID",
17+
"maintainer": true
1318
}
1419
],
15-
"repository":
16-
{
17-
"type": "git",
18-
"url": "https://github.com/Dlloydev/QuickPID"
20+
"license": "MIT",
21+
"homepage": "https://github.com/Dlloydev/QuickPID",
22+
"dependencies": {
23+
"QuickPID": "~2.4.2"
1924
},
20-
"frameworks": "arduino"
25+
"frameworks": "*",
26+
"platforms": "*"
2127
}

library.properties

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
name=QuickPID
2-
version=2.4.1
2+
version=2.4.2
33
author=David Lloyd
44
maintainer=David Lloyd <[email protected]>
5-
sentence=A fast PID controller with AutoTune and 10 tuning rules.
6-
paragraph=This controller can automatically determine and set tuning parameters. Compatible with most Arduino and ESP32 boards.
5+
sentence=A fast PID controller with AutoTune, integral anti-windup and variable controls for Proportional and Derivative on Error to Measurement.
6+
paragraph=A fast PID controller with an AutoTune dynamic object, 10 tunung rules, Integral anti-windup, TIMER Mode, variable Proportional and Derivative on Error to Measurement and full-featured Arduino analogWrite compatibility for ESP32 and ESP32-S2.
77
category=Signal Input/Output
88
url=https://github.com/Dlloydev/QuickPID
99
architectures=*
10-
includes=QuickPID.h
10+
includes=QuickPID.h,analogWrite.h

src/QuickPID.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**********************************************************************************
2-
QuickPID Library for Arduino - Version 2.4.1
2+
QuickPID Library for Arduino - Version 2.4.2
33
by dlloydev https://github.com/Dlloydev/QuickPID
44
Based on the Arduino PID Library and work on AutoTunePID class
55
by gnalbandian (Gonzalo). Licensed under the MIT License.
@@ -66,7 +66,7 @@ bool QuickPID::Compute() {
6666
deTerm = -kde * error;
6767

6868
outputSum += iTerm;
69-
if (outputSum > outMax) iTerm -= outputSum - outMax; // prevent integral windup
69+
if (outputSum > outMax) iTerm -= outputSum - outMax; // integral anti-windup
7070
else if (outputSum < outMin) iTerm += outMin - outputSum;
7171

7272
float output = peTerm;
@@ -358,9 +358,9 @@ byte AutoTunePID::autoTuneLoop() {
358358
_ki = _kp / Ti;
359359
_kd = Td * _kp;
360360
} else { //other rules
361-
_kp = RulesContants[static_cast<uint8_t>(_tuningRule)][0] / 1000.0 * _Ku;
362-
_ki = RulesContants[static_cast<uint8_t>(_tuningRule)][1] / 1000.0 * _Ku / _Tu;
363-
_kd = RulesContants[static_cast<uint8_t>(_tuningRule)][2] / 1000.0 * _Ku * _Tu;
361+
_kp = (float)(RulesContants[static_cast<uint8_t>(_tuningRule)][0] / 1000.0) * _Ku;
362+
_ki = (float)(RulesContants[static_cast<uint8_t>(_tuningRule)][1] / 1000.0) * (_Ku / _Tu);
363+
_kd = (float)(RulesContants[static_cast<uint8_t>(_tuningRule)][2] / 1000.0) * (_Ku * _Tu);
364364
}
365365
if (_printOrPlotter == 1) {
366366
// Controllability https://blog.opticontrols.com/wp-content/uploads/2011/06/td-versus-tau.png

src/QuickPID.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class AutoTunePID {
5757
{ 0, 0, 0 }, // AMIGOF_PID
5858
{ 700, 1750, 105 }, // PESSEN_INTEGRAL_PID
5959
{ 333, 667, 111 }, // SOME_OVERSHOOT_PID
60-
{ 200, 400, 67 }, // NO_OVERSHOOT_PID
60+
{ 333, 100, 67 } // NO_OVERSHOOT_PID
6161
};
6262

6363
}; // class AutoTunePID

0 commit comments

Comments
 (0)