Merge remote-tracking branch 'upstream/edge' into upstream-master
[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
14 class PID_Autotuner : public Module
15 {
16 public:
17 PID_Autotuner();
18
19 void on_module_loaded(void);
20 uint32_t on_tick(uint32_t);
21 void on_idle(void *);
22 void on_gcode_received(void *);
23
24 private:
25 void begin(float, int );
26 void abort();
27 void finishUp();
28
29 TemperatureControl *temp_control;
30 float target_temperature;
31
32 float *peaks;
33 int requested_cycles;
34 float noiseBand;
35 unsigned long peak1, peak2;
36 int sampleTime;
37 int nLookBack;
38 int lookBackCnt;
39 int peakType;
40 float *lastInputs;
41 int peakCount;
42 float absMax, absMin;
43 float oStep;
44 int output;
45 volatile unsigned long tickCnt;
46 struct {
47 bool justchanged:1;
48 volatile bool tick:1;
49 bool firstPeak:1;
50 };
51 };
52
53 #endif /* _PID_AUTOTUNE_H */