Merge remote-tracking branch 'upstream/edge' into add/delta-calibration-tweaks
[clinton/Smoothieware.git] / src / modules / tools / temperaturecontrol / PID_Autotuner.h
1 /**
2 * Based on https://github.com/br3ttb/Arduino-PID-AutoTune-Library
3 */
4
5 #ifndef _PID_AUTOTUNE_H
6 #define _PID_AUTOTUNE_H
7
8 #include <stdint.h>
9
10 #include "Module.h"
11
12 class TemperatureControl;
13 class StreamOutput;
14
15 class PID_Autotuner : public Module
16 {
17 public:
18 PID_Autotuner();
19
20 void on_module_loaded(void);
21 uint32_t on_tick(uint32_t);
22 void on_idle(void *);
23 void on_gcode_received(void *);
24
25 private:
26 void begin(float, StreamOutput *, int );
27 void abort();
28 void finishUp();
29
30 TemperatureControl *temp_control;
31 float target_temperature;
32 StreamOutput *s;
33
34 volatile bool tick;
35
36 float *peaks;
37 int requested_cycles;
38 float noiseBand;
39 unsigned long peak1, peak2;
40 int sampleTime;
41 int nLookBack;
42 int lookBackCnt;
43 int peakType;
44 float *lastInputs;
45 int peakCount;
46 bool justchanged;
47 float absMax, absMin;
48 float oStep;
49 int output;
50 volatile unsigned long tickCnt;
51 };
52
53 #endif /* _PID_AUTOTUNE_H */