made temperature_control modular ( multiple concurrent modules possible
[clinton/Smoothieware.git] / src / modules / tools / temperaturecontrol / TemperatureControl.h
CommitLineData
cd011f58 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.
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
AW
10
11#include "mbed.h"
3c132bd0 12#include "libs/Pin.h"
ded56b35
AW
13#include <math.h>
14
15#define UNDEFINED -1
16
3c132bd0
AW
17#define thermistor_checksum 41045
18#define r0_ckeckusm 5538
7dd8133c 19#define readings_per_second_ckeckusm 18645
3c132bd0
AW
20#define t0_ckeckusm 6564
21#define beta_ckeckusm 1181
22#define vadc_ckeckusm 10911
23#define vcc_ckeckusm 36157
24#define r1_ckeckusm 5795
25#define r2_ckeckusm 6052
26#define temperature_control_checksum 44054
27#define thermistor_pin_checksum 1788
28#define heater_pin_checksum 35619
7dd8133c 29
ded56b35
AW
30class TemperatureControl : public Module {
31 public:
32 TemperatureControl();
3c132bd0 33 TemperatureControl(uint16_t name);
ded56b35
AW
34
35 void on_module_loaded();
b6c86164 36 void on_main_loop(void* argument);
ded56b35 37 void on_gcode_execute(void* argument);
7dd8133c 38 void on_config_reload(void* argument);
ded56b35
AW
39 void set_desired_temperature(double desired_temperature);
40 double get_temperature();
41 double adc_value_to_temperature(double adc_value);
42 double temperature_to_adc_value(double temperature);
43 void thermistor_read_tick();
44 double new_thermistor_reading();
45 double average_adc_reading();
46
ded56b35
AW
47 double desired_adc_value;
48 double tail_adc_value;
49 double head_adc_value;
50
51 // Thermistor computation settings
52 double r0;
53 double t0;
7dd8133c
AW
54 double r1;
55 double r2;
ded56b35
AW
56 double beta;
57 double vadc;
58 double vcc;
59 double k;
60 double vs;
61 double rs;
62
63 double acceleration_factor;
64 double readings_per_second;
65
66 RingBuffer<double,16> queue; // Queue of Blocks
67 int error_count;
3c132bd0
AW
68
69 uint16_t name_checksum;
70
71 Pin* thermistor_pin;
72 Pin* heater_pin;
73
ded56b35
AW
74};
75
76#endif