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 #define thermistor_checksum CHECKSUM("thermistor")
20 #define r0_checksum CHECKSUM("r0")
21 #define readings_per_second_checksum CHECKSUM("readings_per_second")
22 #define max_pwm_checksum CHECKSUM("max_pwm")
23 #define t0_checksum CHECKSUM("t0")
24 #define beta_checksum CHECKSUM("beta")
25 #define vadc_checksum CHECKSUM("vadc")
26 #define vcc_checksum CHECKSUM("vcc")
27 #define r1_checksum CHECKSUM("r1")
28 #define r2_checksum CHECKSUM("r2")
29 #define temperature_control_checksum CHECKSUM("temperature_control")
30 #define thermistor_pin_checksum CHECKSUM("thermistor_pin")
31 #define heater_pin_checksum CHECKSUM("heater_pin")
33 #define get_m_code_checksum CHECKSUM("get_m_code")
34 #define set_m_code_checksum CHECKSUM("set_m_code")
35 #define set_and_wait_m_code_checksum CHECKSUM("set_and_wait_m_code")
37 #define designator_checksum CHECKSUM("designator")
39 #define p_factor_checksum CHECKSUM("p_factor")
40 #define i_factor_checksum CHECKSUM("i_factor")
41 #define d_factor_checksum CHECKSUM("d_factor")
43 #define i_max_checksum CHECKSUM("i_max")
47 class TemperatureControlPool
;
49 class TemperatureControl
: public Module
{
52 TemperatureControl(uint16_t name
);
54 void on_module_loaded();
55 void on_main_loop(void* argument
);
56 void on_gcode_execute(void* argument
);
57 void on_gcode_received(void* argument
);
58 void on_config_reload(void* argument
);
59 void on_second_tick(void* argument
);
61 void set_desired_temperature(double desired_temperature
);
62 double get_temperature();
63 double adc_value_to_temperature(int adc_value
);
64 uint32_t thermistor_read_tick(uint32_t dummy
);
65 int new_thermistor_reading();
67 void pid_process(double);
69 double target_temperature
;
71 // Thermistor computation settings
95 double acceleration_factor
;
96 double readings_per_second
;
98 RingBuffer
<uint16_t,QUEUE_LEN
> queue
; // Queue of readings
99 uint16_t median_buffer
[QUEUE_LEN
];
102 uint16_t name_checksum
;
110 uint16_t set_and_wait_m_code
;
115 TemperatureControlPool
*pool
;