Commit | Line | Data |
---|---|---|
df27a6a3 | 1 | /* |
3c132bd0 AW |
2 | this file is part of smoothie (http://smoothieware.org/). the motion control part is heavily based on grbl (https://github.com/simen/grbl). |
3 | smoothie is free software: you can redistribute it and/or modify it under the terms of the gnu general public license as published by the free software foundation, either version 3 of the license, or (at your option) any later version. | |
4 | smoothie is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. see the gnu general public license for more details. | |
df27a6a3 | 5 | you should have received a copy of the gnu general public license along with smoothie. if not, see <http://www.gnu.org/licenses/>. |
cd011f58 AW |
6 | */ |
7 | ||
3c132bd0 AW |
8 | #ifndef temperaturecontrol_h |
9 | #define temperaturecontrol_h | |
ded56b35 | 10 | |
aa4d694a | 11 | #include "Module.h" |
827a49ca | 12 | #include "Pwm.h" |
9d955060 | 13 | #include "TempSensor.h" |
2fa50ca0 | 14 | #include "TemperatureControlPublicAccess.h" |
e84c3be3 | 15 | |
ded56b35 | 16 | class TemperatureControl : public Module { |
47339e4a | 17 | |
b19aa09d | 18 | public: |
8e8b938e | 19 | TemperatureControl(uint16_t name, int index); |
d8baddd9 | 20 | ~TemperatureControl(); |
907d5e8a | 21 | |
ded56b35 | 22 | void on_module_loaded(); |
b6c86164 | 23 | void on_main_loop(void* argument); |
ded56b35 | 24 | void on_gcode_execute(void* argument); |
b0be67b5 | 25 | void on_gcode_received(void* argument); |
8ccab7cf | 26 | void on_second_tick(void* argument); |
b19aa09d | 27 | void on_get_public_data(void* argument); |
77047e76 | 28 | void on_set_public_data(void* argument); |
3d1a4519 | 29 | void on_halt(void* argument); |
8ccab7cf | 30 | |
1ad23cd3 | 31 | void set_desired_temperature(float desired_temperature); |
10e66797 | 32 | |
8e8b938e JM |
33 | float get_temperature(); |
34 | ||
10e66797 JM |
35 | friend class PID_Autotuner; |
36 | ||
37 | private: | |
71cc73eb | 38 | void load_config(); |
d8baddd9 | 39 | uint32_t thermistor_read_tick(uint32_t dummy); |
1ad23cd3 | 40 | void pid_process(float); |
907d5e8a | 41 | |
8e8b938e JM |
42 | int pool_index; |
43 | ||
1ad23cd3 | 44 | float target_temperature; |
7d4baeee | 45 | float max_temp; |
ded56b35 | 46 | |
1ad23cd3 MM |
47 | float preset1; |
48 | float preset2; | |
f4bd4fc3 | 49 | |
d8baddd9 | 50 | TempSensor *sensor; |
2fa50ca0 | 51 | |
907d5e8a | 52 | // PID runtime |
1ad23cd3 | 53 | float i_max; |
907d5e8a | 54 | |
907d5e8a MM |
55 | int o; |
56 | ||
1ad23cd3 | 57 | float last_reading; |
907d5e8a | 58 | |
1ad23cd3 | 59 | float readings_per_second; |
ded56b35 | 60 | |
3c132bd0 AW |
61 | uint16_t name_checksum; |
62 | ||
7dee00e4 | 63 | Pwm heater_pin; |
907d5e8a | 64 | |
86fa0b93 JM |
65 | struct { |
66 | bool use_bangbang:1; | |
67 | bool waiting:1; | |
68 | bool min_temp_violated:1; | |
69 | bool link_to_tool:1; | |
70 | bool active:1; | |
71cc73eb | 71 | bool readonly:1; |
86fa0b93 | 72 | }; |
3c132bd0 | 73 | |
1306ba99 AW |
74 | uint16_t set_m_code; |
75 | uint16_t set_and_wait_m_code; | |
76 | uint16_t get_m_code; | |
2fa50ca0 | 77 | struct pad_temperature public_data_return; |
7b625dcc | 78 | |
e0d0ea84 | 79 | std::string designator; |
3c308aeb | 80 | |
1ad23cd3 MM |
81 | void setPIDp(float p); |
82 | void setPIDi(float i); | |
83 | void setPIDd(float d); | |
201e6dcf | 84 | |
989d0e94 | 85 | float hysteresis; |
1ad23cd3 MM |
86 | float iTerm; |
87 | float lastInput; | |
201e6dcf | 88 | // PID settings |
1ad23cd3 MM |
89 | float p_factor; |
90 | float i_factor; | |
91 | float d_factor; | |
92 | float PIDdt; | |
ded56b35 AW |
93 | }; |
94 | ||
95 | #endif |