forked from gaelj/thermostat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPID_AutoTune_v0.h
53 lines (45 loc) · 1.66 KB
/
PID_AutoTune_v0.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
#ifndef PID_AutoTune_v0
#define PID_AutoTune_v0
#define LIBRARY_VERSION 0.0.1
#include "Arduino.h"
class PID_ATune {
public:
//commonly used functions **************************************************************************
PID_ATune();
void Create(float*, float*); // * Constructor. links the Autotune to a given PID
int Runtime(); // * Similar to the PID Compute function, returns non 0 when done
void Cancel(); // * Stops the AutoTune
void SetOutputStep(float); // * how far above and below the starting value will the output step?
float GetOutputStep(); //
void SetControlType(int); // * Determies if the tuning parameters returned will be PI (D=0)
int GetControlType(); // or PID. (0=PI, 1=PID)
void SetLookbackSec(int); // * how far back are we looking to identify peaks
int GetLookbackSec(); //
void SetNoiseBand(float); // * the autotune will ignore signal chatter smaller than this value
float GetNoiseBand(); // this should be acurately set
float GetKp(); // * once autotune is complete, these functions contain the
float GetKi(); // computed tuning parameters.
float GetKd(); //
private:
void FinishUp();
bool isMax, isMin;
float *input, *output;
float setpoint;
float noiseBand;
int controlType;
bool running;
unsigned long peak1, peak2, lastTime;
int sampleTime;
int nLookBack;
int peakType;
float lastInputs[101];
float peaks[10];
int peakCount;
bool justchanged;
bool justevaled;
float absMax, absMin;
float oStep;
float outputStart;
float Ku, Pu;
};
#endif