Merge pull request #136 from bgamari/fix-homing
[clinton/Smoothieware.git] / src / modules / tools / temperaturecontrol / PID_Autotuner.h
1 #ifndef _PID_AUTOTUNE_H
2 #define _PID_AUTOTUNE_H
3
4 #include <stdint.h>
5
6 #include "Module.h"
7 #include "TemperatureControl.h"
8 #include "StreamOutput.h"
9
10 #define PID_AUTOTUNER_CYCLES 8
11
12 class PID_Autotuner : public Module
13 {
14 public:
15 PID_Autotuner();
16 void begin(TemperatureControl*, double, StreamOutput*);
17 void abort();
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 TemperatureControl *t;
25
26 double target_temperature;
27
28 int cycle;
29 bool output;
30 bool last_output;
31 StreamOutput *s;
32
33 volatile bool tick;
34
35 struct {
36 double t_max;
37 double t_min;
38 int ticks_low;
39 int ticks_high;
40 } cycles[PID_AUTOTUNER_CYCLES];
41
42 int bias, d;
43 };
44
45 #endif /* _PID_AUTOTUNE_H */