Prusa MINI Firmware overview
thermistors.h
Go to the documentation of this file.
1 /**
2  * Marlin 3D Printer Firmware
3  * Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4  *
5  * Based on Sprinter and grbl.
6  * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 #pragma once
23 
24 #include "../../inc/MarlinConfig.h"
25 
26 #define OVERSAMPLENR 16
27 #define OV(N) int16_t((N) * (OVERSAMPLENR))
28 
29 #define ANY_THERMISTOR_IS(n) (THERMISTOR_HEATER_0 == n || THERMISTOR_HEATER_1 == n || THERMISTOR_HEATER_2 == n || THERMISTOR_HEATER_3 == n || THERMISTOR_HEATER_4 == n || THERMISTOR_HEATER_5 == n || THERMISTORBED == n || THERMISTORCHAMBER == n)
30 
31 // Pt1000 and Pt100 handling
32 //
33 // Rt=R0*(1+a*T+b*T*T) [for T>0]
34 // a=3.9083E-3, b=-5.775E-7
35 #define PtA 3.9083E-3
36 #define PtB -5.775E-7
37 #define PtRt(T,R0) ((R0) * (1.0 + (PtA) * (T) + (PtB) * (T) * (T)))
38 #define PtAdVal(T,R0,Rup) (short)(1024 / (Rup / PtRt(T, R0) + 1))
39 #define PtLine(T,R0,Rup) { OV(PtAdVal(T, R0, Rup)), T }
40 
41 #if ANY_THERMISTOR_IS(1) // beta25 = 4092 K, R25 = 100 kOhm, Pull-up = 4.7 kOhm, "EPCOS"
42  #include "thermistor_1.h"
43 #endif
44 #if ANY_THERMISTOR_IS(2) // 4338 K, R25 = 200 kOhm, Pull-up = 4.7 kOhm, "ATC Semitec 204GT-2"
45  #include "thermistor_2.h"
46 #endif
47 #if ANY_THERMISTOR_IS(3) // beta25 = 4120 K, R25 = 100 kOhm, Pull-up = 4.7 kOhm, "Mendel-parts"
48  #include "thermistor_3.h"
49 #endif
50 #if ANY_THERMISTOR_IS(4) // beta25 = 3950 K, R25 = 10 kOhm, Pull-up = 4.7 kOhm, "Generic"
51  #include "thermistor_4.h"
52 #endif
53 #if ANY_THERMISTOR_IS(5) // beta25 = 4267 K, R25 = 100 kOhm, Pull-up = 4.7 kOhm, "ParCan, ATC 104GT-2"
54  #include "thermistor_5.h"
55 #endif
56 #if ANY_THERMISTOR_IS(501) // 100K Zonestar thermistor
57  #include "thermistor_501.h"
58 #endif
59 #if ANY_THERMISTOR_IS(512) // 100k thermistor in RPW-Ultra hotend, Pull-up = 4.7 kOhm, "unknown model"
60  #include "thermistor_512.h"
61 #endif
62 #if ANY_THERMISTOR_IS(6) // beta25 = 4092 K, R25 = 100 kOhm, Pull-up = 8.2 kOhm, "EPCOS ?"
63  #include "thermistor_6.h"
64 #endif
65 #if ANY_THERMISTOR_IS(7) // beta25 = 3974 K, R25 = 100 kOhm, Pull-up = 4.7 kOhm, "Honeywell 135-104LAG-J01"
66  #include "thermistor_7.h"
67 #endif
68 #if ANY_THERMISTOR_IS(71) // beta25 = 3974 K, R25 = 100 kOhm, Pull-up = 4.7 kOhm, "Honeywell 135-104LAF-J01"
69  #include "thermistor_71.h"
70 #endif
71 #if ANY_THERMISTOR_IS(8) // beta25 = 3950 K, R25 = 100 kOhm, Pull-up = 10 kOhm, "Vishay E3104FHT"
72  #include "thermistor_8.h"
73 #endif
74 #if ANY_THERMISTOR_IS(9) // beta25 = 3960 K, R25 = 100 kOhm, Pull-up = 4.7 kOhm, "GE Sensing AL03006-58.2K-97-G1"
75  #include "thermistor_9.h"
76 #endif
77 #if ANY_THERMISTOR_IS(10) // beta25 = 3960 K, R25 = 100 kOhm, Pull-up = 4.7 kOhm, "RS 198-961"
78  #include "thermistor_10.h"
79 #endif
80 #if ANY_THERMISTOR_IS(11) // beta25 = 3950 K, R25 = 100 kOhm, Pull-up = 4.7 kOhm, "QU-BD silicone bed, QWG-104F-3950"
81  #include "thermistor_11.h"
82 #endif
83 #if ANY_THERMISTOR_IS(13) // beta25 = 4100 K, R25 = 100 kOhm, Pull-up = 4.7 kOhm, "Hisens"
84  #include "thermistor_13.h"
85 #endif
86 #if ANY_THERMISTOR_IS(15) // JGAurora A5 thermistor calibration
87  #include "thermistor_15.h"
88 #endif
89 #if ANY_THERMISTOR_IS(18) // ATC Semitec 204GT-2 (4.7k pullup) Dagoma.Fr - MKS_Base_DKU001327
90  #include "thermistor_18.h"
91 #endif
92 #if ANY_THERMISTOR_IS(20) // Pt100 with INA826 amp on Ultimaker v2.0 electronics
93  #include "thermistor_20.h"
94 #endif
95 #if ANY_THERMISTOR_IS(51) // beta25 = 4092 K, R25 = 100 kOhm, Pull-up = 1 kOhm, "EPCOS"
96  #include "thermistor_51.h"
97 #endif
98 #if ANY_THERMISTOR_IS(52) // beta25 = 4338 K, R25 = 200 kOhm, Pull-up = 1 kOhm, "ATC Semitec 204GT-2"
99  #include "thermistor_52.h"
100 #endif
101 #if ANY_THERMISTOR_IS(55) // beta25 = 4267 K, R25 = 100 kOhm, Pull-up = 1 kOhm, "ATC Semitec 104GT-2 (Used on ParCan)"
102  #include "thermistor_55.h"
103 #endif
104 #if ANY_THERMISTOR_IS(60) // beta25 = 3950 K, R25 = 100 kOhm, Pull-up = 4.7 kOhm, "Maker's Tool Works Kapton Bed"
105  #include "thermistor_60.h"
106 #endif
107 #if ANY_THERMISTOR_IS(61) // beta25 = 3950 K, R25 = 100 kOhm, Pull-up = 4.7 kOhm, "Formbot 350°C Thermistor"
108  #include "thermistor_61.h"
109 #endif
110 #if ANY_THERMISTOR_IS(66) // beta25 = 4500 K, R25 = 2.5 MOhm, Pull-up = 4.7 kOhm, "DyzeDesign 500 °C Thermistor"
111  #include "thermistor_66.h"
112 #endif
113 #if ANY_THERMISTOR_IS(67) // R25 = 500 KOhm, beta25 = 3800 K, 4.7 kOhm pull-up, SliceEngineering 450 °C Thermistor
114  #include "thermistor_67.h"
115 #endif
116 #if ANY_THERMISTOR_IS(12) // beta25 = 4700 K, R25 = 100 kOhm, Pull-up = 4.7 kOhm, "Personal calibration for Makibox hot bed"
117  #include "thermistor_12.h"
118 #endif
119 #if ANY_THERMISTOR_IS(70) // beta25 = 4100 K, R25 = 100 kOhm, Pull-up = 4.7 kOhm, "Hephestos 2, bqh2 stock thermistor"
120  #include "thermistor_70.h"
121 #endif
122 #if ANY_THERMISTOR_IS(75) // beta25 = 4100 K, R25 = 100 kOhm, Pull-up = 4.7 kOhm, "MGB18-104F39050L32 thermistor"
123  #include "thermistor_75.h"
124 #endif
125 #if ANY_THERMISTOR_IS(99) // 100k bed thermistor with a 10K pull-up resistor (on some Wanhao i3 models)
126  #include "thermistor_99.h"
127 #endif
128 #if ANY_THERMISTOR_IS(110) // Pt100 with 1k0 pullup
129  #include "thermistor_110.h"
130 #endif
131 #if ANY_THERMISTOR_IS(147) // Pt100 with 4k7 pullup
132  #include "thermistor_147.h"
133 #endif
134 #if ANY_THERMISTOR_IS(201) // Pt100 with LMV324 Overlord
135  #include "thermistor_201.h"
136 #endif
137 #if ANY_THERMISTOR_IS(331) // Like table 1, but with 3V3 as input voltage
138  #include "thermistor_331.h"
139 #endif
140 #if ANY_THERMISTOR_IS(666) // beta25 = UNK, R25 = 200K, Pull-up = 10 kOhm, "Unidentified 200K NTC thermistor (Einstart S)"
141  #include "thermistor_666.h"
142 #endif
143 #if ANY_THERMISTOR_IS(1010) // Pt1000 with 1k0 pullup
144  #include "thermistor_1010.h"
145 #endif
146 #if ANY_THERMISTOR_IS(1047) // Pt1000 with 4k7 pullup
147  #include "thermistor_1047.h"
148 #endif
149 #if ANY_THERMISTOR_IS(998) // User-defined table 1
150  #include "thermistor_998.h"
151 #endif
152 #if ANY_THERMISTOR_IS(999) // User-defined table 2
153  #include "thermistor_999.h"
154 #endif
155 #if ANY_THERMISTOR_IS(1000) // Custom
156  const short temptable_1000[][2] PROGMEM = { { 0, 0 } };
157 #endif
158 
159 #define _TT_NAME(_N) temptable_ ## _N
160 #define TT_NAME(_N) _TT_NAME(_N)
161 
162 #if THERMISTOR_HEATER_0
163  #define HEATER_0_TEMPTABLE TT_NAME(THERMISTOR_HEATER_0)
164  #define HEATER_0_TEMPTABLE_LEN COUNT(HEATER_0_TEMPTABLE)
165 #elif defined(HEATER_0_USES_THERMISTOR)
166  #error "No heater 0 thermistor table specified"
167 #else
168  #define HEATER_0_TEMPTABLE nullptr
169  #define HEATER_0_TEMPTABLE_LEN 0
170 #endif
171 
172 #if THERMISTOR_HEATER_1
173  #define HEATER_1_TEMPTABLE TT_NAME(THERMISTOR_HEATER_1)
174  #define HEATER_1_TEMPTABLE_LEN COUNT(HEATER_1_TEMPTABLE)
175 #elif defined(HEATER_1_USES_THERMISTOR)
176  #error "No heater 1 thermistor table specified"
177 #else
178  #define HEATER_1_TEMPTABLE nullptr
179  #define HEATER_1_TEMPTABLE_LEN 0
180 #endif
181 
182 #if THERMISTOR_HEATER_2
183  #define HEATER_2_TEMPTABLE TT_NAME(THERMISTOR_HEATER_2)
184  #define HEATER_2_TEMPTABLE_LEN COUNT(HEATER_2_TEMPTABLE)
185 #elif defined(HEATER_2_USES_THERMISTOR)
186  #error "No heater 2 thermistor table specified"
187 #else
188  #define HEATER_2_TEMPTABLE nullptr
189  #define HEATER_2_TEMPTABLE_LEN 0
190 #endif
191 
192 #if THERMISTOR_HEATER_3
193  #define HEATER_3_TEMPTABLE TT_NAME(THERMISTOR_HEATER_3)
194  #define HEATER_3_TEMPTABLE_LEN COUNT(HEATER_3_TEMPTABLE)
195 #elif defined(HEATER_3_USES_THERMISTOR)
196  #error "No heater 3 thermistor table specified"
197 #else
198  #define HEATER_3_TEMPTABLE nullptr
199  #define HEATER_3_TEMPTABLE_LEN 0
200 #endif
201 
202 #if THERMISTOR_HEATER_4
203  #define HEATER_4_TEMPTABLE TT_NAME(THERMISTOR_HEATER_4)
204  #define HEATER_4_TEMPTABLE_LEN COUNT(HEATER_4_TEMPTABLE)
205 #elif defined(HEATER_4_USES_THERMISTOR)
206  #error "No heater 4 thermistor table specified"
207 #else
208  #define HEATER_4_TEMPTABLE nullptr
209  #define HEATER_4_TEMPTABLE_LEN 0
210 #endif
211 
212 #if THERMISTOR_HEATER_5
213  #define HEATER_5_TEMPTABLE TT_NAME(THERMISTOR_HEATER_5)
214  #define HEATER_5_TEMPTABLE_LEN COUNT(HEATER_5_TEMPTABLE)
215 #elif defined(HEATER_5_USES_THERMISTOR)
216  #error "No heater 5 thermistor table specified"
217 #else
218  #define HEATER_5_TEMPTABLE nullptr
219  #define HEATER_5_TEMPTABLE_LEN 0
220 #endif
221 
222 #ifdef THERMISTORBED
223  #define BED_TEMPTABLE TT_NAME(THERMISTORBED)
224  #define BED_TEMPTABLE_LEN COUNT(BED_TEMPTABLE)
225 #elif defined(HEATER_BED_USES_THERMISTOR)
226  #error "No bed thermistor table specified"
227 #else
228  #define BED_TEMPTABLE_LEN 0
229 #endif
230 
231 #ifdef THERMISTORCHAMBER
232  #define CHAMBER_TEMPTABLE TT_NAME(THERMISTORCHAMBER)
233  #define CHAMBER_TEMPTABLE_LEN COUNT(CHAMBER_TEMPTABLE)
234 #elif defined(HEATER_CHAMBER_USES_THERMISTOR)
235  #error "No chamber thermistor table specified"
236 #else
237  #define CHAMBER_TEMPTABLE_LEN 0
238 #endif
239 
240 // The SCAN_THERMISTOR_TABLE macro needs alteration?
241 static_assert(
245  && BED_TEMPTABLE_LEN < 256 && CHAMBER_TEMPTABLE_LEN < 256,
246  "Temperature conversion tables over 255 entries need special consideration."
247 );
248 
249 // Set the high and low raw values for the heaters
250 // For thermistors the highest temperature results in the lowest ADC value
251 // For thermocouples the highest temperature results in the highest ADC value
252 #ifndef HEATER_0_RAW_HI_TEMP
253  #if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_0_USES_THERMISTOR)
254  #define HEATER_0_RAW_HI_TEMP 16383
255  #define HEATER_0_RAW_LO_TEMP 0
256  #else
257  #define HEATER_0_RAW_HI_TEMP 0
258  #define HEATER_0_RAW_LO_TEMP 16383
259  #endif
260 #endif
261 #ifndef HEATER_1_RAW_HI_TEMP
262  #if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_1_USES_THERMISTOR)
263  #define HEATER_1_RAW_HI_TEMP 16383
264  #define HEATER_1_RAW_LO_TEMP 0
265  #else
266  #define HEATER_1_RAW_HI_TEMP 0
267  #define HEATER_1_RAW_LO_TEMP 16383
268  #endif
269 #endif
270 #ifndef HEATER_2_RAW_HI_TEMP
271  #if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_2_USES_THERMISTOR)
272  #define HEATER_2_RAW_HI_TEMP 16383
273  #define HEATER_2_RAW_LO_TEMP 0
274  #else
275  #define HEATER_2_RAW_HI_TEMP 0
276  #define HEATER_2_RAW_LO_TEMP 16383
277  #endif
278 #endif
279 #ifndef HEATER_3_RAW_HI_TEMP
280  #if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_3_USES_THERMISTOR)
281  #define HEATER_3_RAW_HI_TEMP 16383
282  #define HEATER_3_RAW_LO_TEMP 0
283  #else
284  #define HEATER_3_RAW_HI_TEMP 0
285  #define HEATER_3_RAW_LO_TEMP 16383
286  #endif
287 #endif
288 #ifndef HEATER_4_RAW_HI_TEMP
289  #if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_4_USES_THERMISTOR)
290  #define HEATER_4_RAW_HI_TEMP 16383
291  #define HEATER_4_RAW_LO_TEMP 0
292  #else
293  #define HEATER_4_RAW_HI_TEMP 0
294  #define HEATER_4_RAW_LO_TEMP 16383
295  #endif
296 #endif
297 #ifndef HEATER_5_RAW_HI_TEMP
298  #if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_5_USES_THERMISTOR)
299  #define HEATER_5_RAW_HI_TEMP 16383
300  #define HEATER_5_RAW_LO_TEMP 0
301  #else
302  #define HEATER_5_RAW_HI_TEMP 0
303  #define HEATER_5_RAW_LO_TEMP 16383
304  #endif
305 #endif
306 #ifndef HEATER_BED_RAW_HI_TEMP
307  #if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_BED_USES_THERMISTOR)
308  #define HEATER_BED_RAW_HI_TEMP 16383
309  #define HEATER_BED_RAW_LO_TEMP 0
310  #else
311  #define HEATER_BED_RAW_HI_TEMP 0
312  #define HEATER_BED_RAW_LO_TEMP 16383
313  #endif
314 #endif
315 #ifndef HEATER_CHAMBER_RAW_HI_TEMP
316  #if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_CHAMBER_USES_THERMISTOR)
317  #define HEATER_CHAMBER_RAW_HI_TEMP 16383
318  #define HEATER_CHAMBER_RAW_LO_TEMP 0
319  #else
320  #define HEATER_CHAMBER_RAW_HI_TEMP 0
321  #define HEATER_CHAMBER_RAW_LO_TEMP 16383
322  #endif
323 #endif
324 
325 #undef REVERSE_TEMP_SENSOR_RANGE
thermistor_8.h
thermistor_9.h
thermistor_67.h
thermistor_6.h
HEATER_2_TEMPTABLE_LEN
#define HEATER_2_TEMPTABLE_LEN
Definition: thermistors.h:189
thermistor_7.h
PROGMEM
#define PROGMEM
Definition: pgmspace.h:29
thermistor_1010.h
thermistor_18.h
thermistor_66.h
thermistor_331.h
thermistor_13.h
thermistor_999.h
thermistor_1.h
HEATER_0_TEMPTABLE_LEN
#define HEATER_0_TEMPTABLE_LEN
Definition: thermistors.h:169
HEATER_4_TEMPTABLE_LEN
#define HEATER_4_TEMPTABLE_LEN
Definition: thermistors.h:209
thermistor_55.h
thermistor_201.h
thermistor_12.h
thermistor_60.h
HEATER_3_TEMPTABLE_LEN
#define HEATER_3_TEMPTABLE_LEN
Definition: thermistors.h:199
thermistor_10.h
CHAMBER_TEMPTABLE_LEN
#define CHAMBER_TEMPTABLE_LEN
Definition: thermistors.h:237
thermistor_61.h
thermistor_512.h
thermistor_501.h
thermistor_11.h
thermistor_666.h
HEATER_1_TEMPTABLE_LEN
#define HEATER_1_TEMPTABLE_LEN
Definition: thermistors.h:179
thermistor_75.h
HEATER_5_TEMPTABLE_LEN
#define HEATER_5_TEMPTABLE_LEN
Definition: thermistors.h:219
thermistor_110.h
thermistor_147.h
thermistor_52.h
thermistor_51.h
thermistor_1047.h
thermistor_998.h
thermistor_4.h
thermistor_70.h
BED_TEMPTABLE_LEN
#define BED_TEMPTABLE_LEN
Definition: thermistors.h:228
thermistor_15.h
thermistor_5.h
thermistor_20.h
thermistor_2.h
thermistor_99.h
thermistor_3.h
thermistor_71.h