Skip to content

Commit f3227e0

Browse files
committed
Minor cleanup
1 parent 9c798fd commit f3227e0

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

QuickPID.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,12 @@ bool QuickPID::Compute()
6767
int32_t dInput = (int32_t)input - (int32_t)lastInput;
6868

6969
/* outputSum+= (ki * error); */
70-
//outputSum += (ki * error);
7170
if (ki < 31) outputSum += FX_INT(FX_MUL(FL_FX(ki), INT_FX(error)));
7271
else outputSum += FX_INT(FX_MUL(FL__FX(ki), INT_FX(error)));
7372

7473
/*Add Proportional on Measurement, if P_ON_M is specified*/
7574
/* outputSum -= kp * dInput; */
7675
if (!pOnE) {
77-
//outputSum -= kp * dInput;
7876
if (kp < 31) outputSum -= FX_INT(FX_MUL(FL_FX(kp), INT_FX(dInput)));
7977
else outputSum -= FX_INT(FX_MUL(FL__FX(kp), INT_FX(dInput)));
8078
}
@@ -86,15 +84,13 @@ bool QuickPID::Compute()
8684
/* if (pOnE) output = (kp * (float)error); */
8785
uint16_t output;
8886
if (pOnE) {
89-
//output = (kp * (float)error);
9087
if (kp < 31) output = FX_INT(FX_MUL(FL_FX(kp), INT_FX(error)));
9188
else output = FX_INT(FX_MUL(FL__FX(kp), INT_FX(error)));
9289
}
9390
else output = 0;
9491

9592
/*Compute Rest of PID output*/
9693
/* output += outputSum - (kd * dInput); */
97-
//output += outputSum - (kd * dInput);
9894
output += outputSum - FX_INT(FX_MUL(FL_FX(kd), INT_FX(dInput)));
9995

10096
if (output > outMax) output = outMax;
@@ -248,7 +244,7 @@ bool QuickPID::GetDirection() {
248244
return controllerDirection;
249245
}
250246

251-
// Utility functions ********************************************************************************
247+
// Utility functions **********************************************************
252248

253249
int QuickPID::analogReadFast(int ADCpin) {
254250
#if defined(__AVR_ATmega328P__)

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ The API follows the [ArduinoPID](https://github.com/br3ttb/Arduino-PID-Library)
1111

1212
PID performance varies depending on how many coefficients are used. When a coefficient is zero, less calculation is done. The controller was benchmarked using an Arduino UNO. QuickPID was benchmarked using analogReadFast() code.
1313

14-
| P_ON_M Compute() | Kp | Ki | Kd | Step Time (µS) |
15-
| ---------------------------------------------------------- | ---- | ---- | ---- | -------------- |
16-
| QuickPID | 2.0 | 5.0 | 0.0 | 88 |
17-
| Arduino PID | 2.0 | 5.0 | 0.0 | 104 |
18-
| **P_ON_M `analogRead(), `Compute(),** **analogWrite()** | | | | |
19-
| QuickPID | 2.0 | 5.0 | 0.2 | 164 |
20-
| Arduino PID | 2.0 | 5.0 | 0.2 | 224 |
14+
| P_ON_M Compute | Kp | Ki | Kd | Step Time (µS) |
15+
| :-------------------------------------------- | ---- | ---- | ---- | -------------- |
16+
| QuickPID | 2.0 | 5.0 | 0.0 | 88 |
17+
| Arduino PID | 2.0 | 5.0 | 0.0 | 104 |
18+
| **P_ON_M analogRead, Compute, analogWrite** | | | | |
19+
| QuickPID | 2.0 | 5.0 | 0.2 | 164 |
20+
| Arduino PID | 2.0 | 5.0 | 0.2 | 224 |
2121

2222
### Execution Frequency
2323

2424
A future version will provide further performance improvements by pre-calculating (scaling) the terms and providing direct timer with ISR support.
2525

26-
#### Variables
26+
### Variables
2727

2828

2929
| Variable | Arduino PID | QuickPID | Data Type | Resolution | Bits Used | Min | Max |

0 commit comments

Comments
 (0)