-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPIDController.h
62 lines (51 loc) · 1.22 KB
/
PIDController.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef PIDControllerLib
#define PIDControllerLib
#if (ARDUINO >= 100)
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#define GRAPH "graph"
#define NOGRAPH "nograph"
#define VERBOSE "verbose"
#define NOVERBOSE "noverbose"
class PIDController {
public:
// Constructor
PIDController();
// Methods - double
double compute(double input, String graph = NOGRAPH, String verbose = NOVERBOSE);
// Methods - void
void begin();
void tune(double _Kp, double _Ki, double _Kd);
void limit(double min, double max);
void setpoint(double newSetpoint);
void minimize(double newMinimize);
// Methods - double, getters
double getOutput();
private:
// Methods
void printGraph(double sensorInput, String verbose);
// Variables - long
unsigned long lastTime;
// Variables - double
double output;
double lastErr;
double timeChanged;
// Variables - double, error variables
double error;
double errSum;
double dErr;
// Variables - bool
bool doLimit;
bool init;
// Variables - double - tuining
double Kp;
double Ki;
double Kd;
double divisor;
double minOut;
double maxOut;
double setPoint;
};
#endif