Tighten up autopid to produce better results
[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 float *peaks;
35 int requested_cycles;
36 float noiseBand;
37 unsigned long peak1, peak2;
38 int sampleTime;
39 int nLookBack;
40 int lookBackCnt;
41 int peakType;
42 float *lastInputs;
43 int peakCount;
44 float absMax, absMin;
45 float oStep;
46 int output;
47 volatile unsigned long tickCnt;
48 struct {
49 bool justchanged:1;
50 volatile bool tick:1;
51 bool firstPeak:1;
52 };
53 };
54
55 #endif /* _PID_AUTOTUNE_H */