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.
5 you should have received a copy of the gnu general public license along with smoothie. if not, see <http://www.gnu.org/licenses/>.
8 #ifndef temperaturecontrol_h
9 #define temperaturecontrol_h
15 #include "RingBuffer.h"
19 #include "TemperatureControlPublicAccess.h"
20 #define thermistor_checksum CHECKSUM("thermistor")
21 #define r0_checksum CHECKSUM("r0")
22 #define readings_per_second_checksum CHECKSUM("readings_per_second")
23 #define max_pwm_checksum CHECKSUM("max_pwm")
24 #define pwm_frequency_checksum CHECKSUM("pwm_frequency")
25 #define t0_checksum CHECKSUM("t0")
26 #define beta_checksum CHECKSUM("beta")
27 #define vadc_checksum CHECKSUM("vadc")
28 #define vcc_checksum CHECKSUM("vcc")
29 #define r1_checksum CHECKSUM("r1")
30 #define r2_checksum CHECKSUM("r2")
31 #define thermistor_pin_checksum CHECKSUM("thermistor_pin")
32 #define heater_pin_checksum CHECKSUM("heater_pin")
34 #define get_m_code_checksum CHECKSUM("get_m_code")
35 #define set_m_code_checksum CHECKSUM("set_m_code")
36 #define set_and_wait_m_code_checksum CHECKSUM("set_and_wait_m_code")
38 #define designator_checksum CHECKSUM("designator")
40 #define p_factor_checksum CHECKSUM("p_factor")
41 #define i_factor_checksum CHECKSUM("i_factor")
42 #define d_factor_checksum CHECKSUM("d_factor")
44 #define i_max_checksum CHECKSUM("i_max")
46 #define preset1_checksum CHECKSUM("preset1")
47 #define preset2_checksum CHECKSUM("preset2")
52 class TemperatureControlPool
;
54 class TemperatureControl
: public Module
{
57 TemperatureControl(uint16_t name
);
59 void on_module_loaded();
60 void on_main_loop(void* argument
);
61 void on_gcode_execute(void* argument
);
62 void on_gcode_received(void* argument
);
63 void on_config_reload(void* argument
);
64 void on_second_tick(void* argument
);
65 void on_get_public_data(void* argument
);
66 void on_set_public_data(void* argument
);
68 void set_desired_temperature(float desired_temperature
);
69 float get_temperature();
70 float adc_value_to_temperature(int adc_value
);
71 uint32_t thermistor_read_tick(uint32_t dummy
);
72 int new_thermistor_reading();
76 TemperatureControlPool
*pool
;
77 friend class PID_Autotuner
;
80 void pid_process(float);
82 float target_temperature
;
87 // Thermistor computation settings
104 float acceleration_factor
;
105 float readings_per_second
;
107 RingBuffer
<uint16_t,QUEUE_LEN
> queue
; // Queue of readings
108 uint16_t median_buffer
[QUEUE_LEN
];
111 uint16_t name_checksum
;
117 bool min_temp_violated
;
120 uint16_t set_and_wait_m_code
;
126 void setPIDp(float p
);
127 void setPIDi(float i
);
128 void setPIDd(float d
);