Skip to content

Commit 7e48e77

Browse files
committed
Update variables and readme
1 parent f134ad8 commit 7e48e77

File tree

4 files changed

+30
-27
lines changed

4 files changed

+30
-27
lines changed

QuickPID.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
The parameters specified here are those for for which we can't set up
1919
reliable defaults, so we need to have the user set them.
2020
**********************************************************************************/
21-
QuickPID::QuickPID(int16_t* Input, uint8_t* Output, int16_t* Setpoint,
21+
QuickPID::QuickPID(int16_t* Input, int16_t* Output, int16_t* Setpoint,
2222
float Kp, float Ki, float Kd, bool POn, bool ControllerDirection)
2323
{
2424
myOutput = Output;
@@ -40,7 +40,7 @@ QuickPID::QuickPID(int16_t* Input, uint8_t* Output, int16_t* Setpoint,
4040
to use Proportional on Error without explicitly saying so.
4141
**********************************************************************************/
4242

43-
QuickPID::QuickPID(int16_t* Input, uint8_t* Output, int16_t* Setpoint,
43+
QuickPID::QuickPID(int16_t* Input, int16_t* Output, int16_t* Setpoint,
4444
float Kp, float Ki, float Kd, bool ControllerDirection)
4545
: QuickPID::QuickPID(Input, Output, Setpoint, Kp, Ki, Kd, P_ON_E, ControllerDirection)
4646
{
@@ -143,7 +143,7 @@ void QuickPID::SetSampleTimeUs(uint32_t NewSampleTimeUs)
143143
the default already, the required output limits might be unique, like using
144144
a time window of 0-8000 needing to clamp it from 0-125.
145145
******************************************************************************/
146-
void QuickPID::SetOutputLimits(uint8_t Min, uint8_t Max)
146+
void QuickPID::SetOutputLimits(int16_t Min, int16_t Max)
147147
{
148148
if (Min >= Max) return;
149149
outMin = Min;

QuickPID.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ class QuickPID
1818
// commonly used functions ************************************************************************************
1919

2020
// Constructor. Links the PID to Input, Output, Setpoint and initial Tuning Parameters.
21-
QuickPID(int16_t*, uint8_t*, int16_t*, float, float, float, bool, bool);
21+
QuickPID(int16_t*, int16_t*, int16_t*, float, float, float, bool, bool);
2222

2323
// Overload constructor with proportional mode. Links the PID to Input, Output, Setpoint and Tuning Parameters.
24-
QuickPID(int16_t*, uint8_t*, int16_t*, float, float, float, bool);
24+
QuickPID(int16_t*, int16_t*, int16_t*, float, float, float, bool);
2525

2626
// Sets PID to either Manual (0) or Auto (non-0).
2727
void SetMode(bool Mode);
@@ -32,7 +32,7 @@ class QuickPID
3232

3333
// Clamps the output to a specific range. 0-255 by default, but it's likely the user will want to change this
3434
// depending on the application.
35-
void SetOutputLimits(uint8_t, uint8_t);
35+
void SetOutputLimits(int16_t, int16_t);
3636

3737
// available but not commonly used functions ******************************************************************
3838

@@ -78,14 +78,13 @@ class QuickPID
7878
bool pOn;
7979

8080
int16_t *myInput; // Pointers to the Input, Output, and Setpoint variables. This creates a
81-
uint8_t *myOutput; // hard link between the variables and the PID, freeing the user from having
81+
int16_t *myOutput; // hard link between the variables and the PID, freeing the user from having
8282
int16_t *mySetpoint; // to constantly tell us what these values are. With pointers we'll just know.
8383

8484
uint32_t SampleTimeUs, lastTime;
85+
int16_t outMin, outMax, error;
8586
int16_t lastInput, outputSum;
86-
uint8_t outMin, outMax;
8787
bool inAuto, pOnE;
88-
int32_t error;
8988
};
9089

9190
#endif

README.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,26 @@ This API (version 2.02) follows the [ArduinoPID](https://github.com/br3ttb/Ardui
1818
| QuickPID | 2.0 | 5.0 | 0.2 | 132 |
1919
| Arduino PID | 2.0 | 5.0 | 0.2 | 224 |
2020

21+
#### Self Test Example (RC Filter): P_ON_M
22+
23+
![pid_self_test_pom](https://user-images.githubusercontent.com/63488701/104115407-2cee5900-52dd-11eb-9b24-ff06d39fd2d6.gif)
24+
2125
### Variables
2226

2327

24-
| Variable | Arduino PID | QuickPID | Data Type | Min | Max |
25-
| :----------- | :---------- | :------- | :-------- | :--------- | :--------- |
26-
| Setpoint | double | int16_t | Binary | 0 | 1023 |
27-
| Input | double | int16_t | Binary | 0 | 1023 |
28-
| Output | double | uint8_t | Binary | 0 | 255 |
29-
| Kp | double | float | float | -3.402E+38 | 3.402E+38 |
30-
| Ki | double | float | float | -3.402E+38 | 3.402E+38 |
31-
| Kd | double | float | float | -3.402E+38 | 3.402E+38 |
32-
| ratio | double | float | float | -3.402E+38 | 3.402E+38 |
33-
| SampleTimeUs | double | uint32_t | Binary | 0 | 4294967295 |
34-
| outputSum | double | int16_t | Binary | 0 | 255 |
35-
| error | double | int32_t | Binary | -1023 | 1023 |
36-
| dInput | double | int32_t | Binary | -1023 | 1023 |
28+
| Variable | Arduino PID | QuickPID |
29+
| :----------- | :---------- | :------- |
30+
| Setpoint | double | int16_t |
31+
| Input | double | int16_t |
32+
| Output | double | int16_t |
33+
| Kp | double | float |
34+
| Ki | double | float |
35+
| Kd | double | float |
36+
| ratio | double | float |
37+
| SampleTimeUs | double | uint32_t |
38+
| outputSum | double | int16_t |
39+
| error | double | int16_t |
40+
| dInput | double | int16_t |
3741

3842
### Original README
3943

examples/QuickPID_Self_Test/QuickPID_Self_Test.ino

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
#define PIN_OUTPUT 3
1212

1313
//Define Variables
14-
int16_t Setpoint = 700;
15-
int16_t Input;
16-
uint8_t Output;
14+
int Setpoint = 700;
15+
int Input;
16+
int Output;
1717

18-
uint32_t before, after;
19-
uint16_t cnt = 0;
18+
unsigned long before, after;
19+
int cnt = 0;
2020

2121
//Specify the initial tuning parameters
2222
float Kp = 2.0, Ki = 15.0, Kd = 0.05;

0 commit comments

Comments
 (0)