|
1 | 1 | # QuickPID
|
2 | 2 |
|
3 |
| -The API follows the [ArduinoPID](https://github.com/br3ttb/Arduino-PID-Library) library, however there have been some significant updates as follows: |
| 3 | +This API (version 2.01) follows the [ArduinoPID](https://github.com/br3ttb/Arduino-PID-Library) library, however there have been some significant updates as follows: |
4 | 4 |
|
5 | 5 | - Library named as **QuickPID** and can run concurrently with Arduino **PID**
|
6 |
| -- Fixed-point calculations are used in `Compute()` to improve performance |
7 |
| -- `analogReadFast()` added to provide further performance improvement |
8 |
| -- `GetError()`added for diagnostics |
| 6 | +- Reorganized and more efficient PID algorithms |
| 7 | +- Fast fixed-point calculations for smaller coefficients, floating point calculations for larger coefficients |
| 8 | +- Faster analog read function |
| 9 | +- `GetError()`function added for diagnostics |
9 | 10 |
|
10 | 11 | ### Performance
|
11 | 12 |
|
12 |
| -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. |
13 |
| - |
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 | |
21 |
| - |
22 |
| -### Execution Frequency |
23 |
| - |
24 |
| -A future version will provide further performance improvements by pre-calculating (scaling) the terms and providing direct timer with ISR support. |
| 13 | +| Compute | Kp | Ki | Kd | Step Time (µS) | |
| 14 | +| :----------------------------------- | ---- | ---- | ---- | -------------- | |
| 15 | +| QuickPID | 2.0 | 15.0 | 0.05 | 72 | |
| 16 | +| Arduino PID | 2.0 | 15.0 | 0.05 | 104 | |
| 17 | +| **analogRead, Compute, analogWrite** | | | | | |
| 18 | +| QuickPID | 2.0 | 5.0 | 0.2 | 132 | |
| 19 | +| Arduino PID | 2.0 | 5.0 | 0.2 | 224 | |
25 | 20 |
|
26 | 21 | ### Variables
|
27 | 22 |
|
28 | 23 |
|
29 |
| -| Variable | Arduino PID | QuickPID | Data Type | Resolution | Bits Used | Min | Max | |
30 |
| -| ------------ | ----------- | ---------------- | ------------ | ---------- | --------- | ----- | ---------- | |
31 |
| -| Setpoint | double | int16_t | Binary | 1 | 10 | 0 | 1023 | |
32 |
| -| Input | double | int16_t | Binary | 1 | 10 | 0 | 1023 | |
33 |
| -| Output | double | uint8_t | Binary | 1 | 8 | 0 | 255 | |
34 |
| -| Kp | double | int32_t, int64_t | s23.8, s55.8 | 0.00390625 | 10.8 | <-1m | >1m | |
35 |
| -| Ki | double | int32_t, int64_t | s23.8, s55.8 | 0.00390625 | 10.8 | <-1m | >1m | |
36 |
| -| Kd | double | int32_t | s23.8 | 0.00390625 | 5.8 | -32 | 31.984375 | |
37 |
| -| ratio | double | int32_t | s23.8 | 0.00390625 | 5.8 | -32 | 31.984375 | |
38 |
| -| SampleTimeUs | double | uint32_t | Binary | 1 | 32 | 0 | 4294967295 | |
39 |
| -| outputSum | double | int16_t | Binary | 1 | 10 | 0 | 1023 | |
40 |
| -| error | double | int32_t | Binary | 1 | s10 | -1023 | 1023 | |
41 |
| -| dInput | double | int32_t | Binary | 1 | s10 | -1023 | 1023 | |
| 24 | +| Variable | Arduino PID | QuickPID | Data Type | Resolution | Bits Used | Min | Max | |
| 25 | +| ------------ | ----------- | -------------- | ------------ | -------------------- | --------- | ----------- | ----------- | |
| 26 | +| Setpoint | double | int16_t | Binary | 1 | 10 | 0 | 1023 | |
| 27 | +| Input | double | int16_t | Binary | 1 | 10 | 0 | 1023 | |
| 28 | +| Output | double | uint8_t | Binary | 1 | 8 | 0 | 255 | |
| 29 | +| Kp | double | int32_t, float | s23.8, float | 6-7 digits precision | 4 bytes | | | |
| 30 | +| Ki | double | int32_t, float | s23.8, float | 6-7 digits precision | 4 bytes | | | |
| 31 | +| Kd | double | int32_t, float | s23.8, float | 6-7 digits precision | 4 bytes | | | |
| 32 | +| ratio | double | float | float | 6-7 digits precision | 4 bytes | | | |
| 33 | +| SampleTimeUs | double | uint32_t | Binary | 1 | 32 | 0 | 4294967295 | |
| 34 | +| outputSum | double | int16_t | Binary | 1 | 8 | 0 (limit) | 255 (limit) | |
| 35 | +| error | double | int32_t | Binary | 1 | 32 | -2147483648 | 2147483647 | |
| 36 | +| dInput | double | int32_t | Binary | 1 | 32 | -2147483648 | 2147483647 | |
42 | 37 |
|
43 | 38 | ### Original README
|
44 | 39 |
|
|
0 commit comments