thermistortables.h 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 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. #ifndef THERMISTORTABLES_H_
  23. #define THERMISTORTABLES_H_
  24. #include "Marlin.h"
  25. #include "macros.h"
  26. #define OVERSAMPLENR 16
  27. #define OV(N) int16_t((N)*(OVERSAMPLENR))
  28. #define ANY_THERMISTOR_IS(n) (THERMISTORHEATER_0 == n || THERMISTORHEATER_1 == n || THERMISTORHEATER_2 == n || THERMISTORHEATER_3 == n || THERMISTORHEATER_4 == n || THERMISTORBED == n || THERMISTORCHAMBER == n)
  29. // Pt1000 and Pt100 handling
  30. //
  31. // Rt=R0*(1+a*T+b*T*T) [for T>0]
  32. // a=3.9083E-3, b=-5.775E-7
  33. #define PtA 3.9083E-3
  34. #define PtB -5.775E-7
  35. #define PtRt(T,R0) ((R0)*(1.0+(PtA)*(T)+(PtB)*(T)*(T)))
  36. #define PtAdVal(T,R0,Rup) (short)(1024/(Rup/PtRt(T,R0)+1))
  37. #define PtLine(T,R0,Rup) { OV(PtAdVal(T,R0,Rup)), T },
  38. #if ANY_THERMISTOR_IS(1) // 100k bed thermistor
  39. #include "thermistortable_1.h"
  40. #endif
  41. #if ANY_THERMISTOR_IS(2) // 200k bed thermistor
  42. #include "thermistortable_2.h"
  43. #endif
  44. #if ANY_THERMISTOR_IS(3) // mendel-parts
  45. #include "thermistortable_3.h"
  46. #endif
  47. #if ANY_THERMISTOR_IS(4) // 10k thermistor
  48. #include "thermistortable_4.h"
  49. #endif
  50. #if ANY_THERMISTOR_IS(5) // 100k ParCan thermistor (104GT-2)
  51. #include "thermistortable_5.h"
  52. #endif
  53. #if ANY_THERMISTOR_IS(501) // 100k Zonestar thermistor
  54. #include "thermistortable_501.h"
  55. #endif
  56. #if ANY_THERMISTOR_IS(6) // 100k Epcos thermistor
  57. #include "thermistortable_6.h"
  58. #endif
  59. #if ANY_THERMISTOR_IS(7) // 100k Honeywell 135-104LAG-J01
  60. #include "thermistortable_7.h"
  61. #endif
  62. #if ANY_THERMISTOR_IS(71) // 100k Honeywell 135-104LAF-J01
  63. #include "thermistortable_71.h"
  64. #endif
  65. #if ANY_THERMISTOR_IS(8) // 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup)
  66. #include "thermistortable_8.h"
  67. #endif
  68. #if ANY_THERMISTOR_IS(9) // 100k GE Sensing AL03006-58.2K-97-G1 (4.7k pullup)
  69. #include "thermistortable_9.h"
  70. #endif
  71. #if ANY_THERMISTOR_IS(10) // 100k RS thermistor 198-961 (4.7k pullup)
  72. #include "thermistortable_10.h"
  73. #endif
  74. #if ANY_THERMISTOR_IS(11) // QU-BD silicone bed QWG-104F-3950 thermistor
  75. #include "thermistortable_11.h"
  76. #endif
  77. #if ANY_THERMISTOR_IS(13) // Hisens thermistor B25/50 =3950 +/-1%
  78. #include "thermistortable_13.h"
  79. #endif
  80. #if ANY_THERMISTOR_IS(15) // JGAurora A5 thermistor calibration
  81. #include "thermistortable_15.h"
  82. #endif
  83. #if ANY_THERMISTOR_IS(20) // PT100 with INA826 amp on Ultimaker v2.0 electronics
  84. #include "thermistortable_20.h"
  85. #endif
  86. #if ANY_THERMISTOR_IS(51) // 100k EPCOS (WITH 1kohm RESISTOR FOR PULLUP, R9 ON SANGUINOLOLU! NOT FOR 4.7kohm PULLUP! THIS IS NOT NORMAL!)
  87. #include "thermistortable_51.h"
  88. #endif
  89. #if ANY_THERMISTOR_IS(52) // 200k ATC Semitec 204GT-2 (WITH 1kohm RESISTOR FOR PULLUP, R9 ON SANGUINOLOLU! NOT FOR 4.7kohm PULLUP! THIS IS NOT NORMAL!)
  90. #include "thermistortable_52.h"
  91. #endif
  92. #if ANY_THERMISTOR_IS(55) // 100k ATC Semitec 104GT-2 (Used on ParCan) (WITH 1kohm RESISTOR FOR PULLUP, R9 ON SANGUINOLOLU! NOT FOR 4.7kohm PULLUP! THIS IS NOT NORMAL!)
  93. #include "thermistortable_55.h"
  94. #endif
  95. #if ANY_THERMISTOR_IS(60) // Maker's Tool Works Kapton Bed Thermistor
  96. #include "thermistortable_60.h"
  97. #endif
  98. #if ANY_THERMISTOR_IS(66) // DyzeDesign 500°C Thermistor
  99. #include "thermistortable_66.h"
  100. #endif
  101. #if ANY_THERMISTOR_IS(12) // 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed)
  102. #include "thermistortable_12.h"
  103. #endif
  104. #if ANY_THERMISTOR_IS(70) // bqh2 stock thermistor
  105. #include "thermistortable_70.h"
  106. #endif
  107. #if ANY_THERMISTOR_IS(75) // Many of the generic silicon heat pads use the MGB18-104F39050L32 Thermistor
  108. #include "thermistortable_75.h"
  109. #endif
  110. #if ANY_THERMISTOR_IS(110) // Pt100 with 1k0 pullup
  111. #include "thermistortable_110.h"
  112. #endif
  113. #if ANY_THERMISTOR_IS(147) // Pt100 with 4k7 pullup
  114. #include "thermistortable_147.h"
  115. #endif
  116. #if ANY_THERMISTOR_IS(1010) // Pt1000 with 1k0 pullup
  117. #include "thermistortable_1010.h"
  118. #endif
  119. #if ANY_THERMISTOR_IS(1047) // Pt1000 with 4k7 pullup
  120. #include "thermistortable_1047.h"
  121. #endif
  122. #if ANY_THERMISTOR_IS(998) // User-defined table 1
  123. #include "thermistortable_998.h"
  124. #endif
  125. #if ANY_THERMISTOR_IS(999) // User-defined table 2
  126. #include "thermistortable_999.h"
  127. #endif
  128. #define _TT_NAME(_N) temptable_ ## _N
  129. #define TT_NAME(_N) _TT_NAME(_N)
  130. #if THERMISTORHEATER_0
  131. #define HEATER_0_TEMPTABLE TT_NAME(THERMISTORHEATER_0)
  132. #define HEATER_0_TEMPTABLE_LEN COUNT(HEATER_0_TEMPTABLE)
  133. #elif defined(HEATER_0_USES_THERMISTOR)
  134. #error "No heater 0 thermistor table specified"
  135. #else
  136. #define HEATER_0_TEMPTABLE NULL
  137. #define HEATER_0_TEMPTABLE_LEN 0
  138. #endif
  139. #if THERMISTORHEATER_1
  140. #define HEATER_1_TEMPTABLE TT_NAME(THERMISTORHEATER_1)
  141. #define HEATER_1_TEMPTABLE_LEN COUNT(HEATER_1_TEMPTABLE)
  142. #elif defined(HEATER_1_USES_THERMISTOR)
  143. #error "No heater 1 thermistor table specified"
  144. #else
  145. #define HEATER_1_TEMPTABLE NULL
  146. #define HEATER_1_TEMPTABLE_LEN 0
  147. #endif
  148. #if THERMISTORHEATER_2
  149. #define HEATER_2_TEMPTABLE TT_NAME(THERMISTORHEATER_2)
  150. #define HEATER_2_TEMPTABLE_LEN COUNT(HEATER_2_TEMPTABLE)
  151. #elif defined(HEATER_2_USES_THERMISTOR)
  152. #error "No heater 2 thermistor table specified"
  153. #else
  154. #define HEATER_2_TEMPTABLE NULL
  155. #define HEATER_2_TEMPTABLE_LEN 0
  156. #endif
  157. #if THERMISTORHEATER_3
  158. #define HEATER_3_TEMPTABLE TT_NAME(THERMISTORHEATER_3)
  159. #define HEATER_3_TEMPTABLE_LEN COUNT(HEATER_3_TEMPTABLE)
  160. #elif defined(HEATER_3_USES_THERMISTOR)
  161. #error "No heater 3 thermistor table specified"
  162. #else
  163. #define HEATER_3_TEMPTABLE NULL
  164. #define HEATER_3_TEMPTABLE_LEN 0
  165. #endif
  166. #if THERMISTORHEATER_4
  167. #define HEATER_4_TEMPTABLE TT_NAME(THERMISTORHEATER_4)
  168. #define HEATER_4_TEMPTABLE_LEN COUNT(HEATER_4_TEMPTABLE)
  169. #elif defined(HEATER_4_USES_THERMISTOR)
  170. #error "No heater 4 thermistor table specified"
  171. #else
  172. #define HEATER_4_TEMPTABLE NULL
  173. #define HEATER_4_TEMPTABLE_LEN 0
  174. #endif
  175. #ifdef THERMISTORBED
  176. #define BEDTEMPTABLE TT_NAME(THERMISTORBED)
  177. #define BEDTEMPTABLE_LEN COUNT(BEDTEMPTABLE)
  178. #elif defined(HEATER_BED_USES_THERMISTOR)
  179. #error "No bed thermistor table specified"
  180. #else
  181. #define BEDTEMPTABLE_LEN 0
  182. #endif
  183. #ifdef THERMISTORCHAMBER
  184. #define CHAMBERTEMPTABLE TT_NAME(THERMISTORCHAMBER)
  185. #define CHAMBERTEMPTABLE_LEN COUNT(CHAMBERTEMPTABLE)
  186. #elif defined(HEATER_CHAMBER_USES_THERMISTOR)
  187. #error "No chamber thermistor table specified"
  188. #else
  189. #define CHAMBERTEMPTABLE_LEN 0
  190. #endif
  191. // The SCAN_THERMISTOR_TABLE macro needs alteration?
  192. static_assert(HEATER_0_TEMPTABLE_LEN < 256 && HEATER_1_TEMPTABLE_LEN < 256 && HEATER_2_TEMPTABLE_LEN < 256 && HEATER_3_TEMPTABLE_LEN < 256 && HEATER_4_TEMPTABLE_LEN < 256 && BEDTEMPTABLE_LEN < 256 && CHAMBERTEMPTABLE_LEN < 256,
  193. "Temperature conversion tables over 255 entries need special consideration."
  194. );
  195. // Set the high and low raw values for the heaters
  196. // For thermistors the highest temperature results in the lowest ADC value
  197. // For thermocouples the highest temperature results in the highest ADC value
  198. #ifndef HEATER_0_RAW_HI_TEMP
  199. #ifdef HEATER_0_USES_THERMISTOR
  200. #define HEATER_0_RAW_HI_TEMP 0
  201. #define HEATER_0_RAW_LO_TEMP 16383
  202. #else
  203. #define HEATER_0_RAW_HI_TEMP 16383
  204. #define HEATER_0_RAW_LO_TEMP 0
  205. #endif
  206. #endif
  207. #ifndef HEATER_1_RAW_HI_TEMP
  208. #ifdef HEATER_1_USES_THERMISTOR
  209. #define HEATER_1_RAW_HI_TEMP 0
  210. #define HEATER_1_RAW_LO_TEMP 16383
  211. #else
  212. #define HEATER_1_RAW_HI_TEMP 16383
  213. #define HEATER_1_RAW_LO_TEMP 0
  214. #endif
  215. #endif
  216. #ifndef HEATER_2_RAW_HI_TEMP
  217. #ifdef HEATER_2_USES_THERMISTOR
  218. #define HEATER_2_RAW_HI_TEMP 0
  219. #define HEATER_2_RAW_LO_TEMP 16383
  220. #else
  221. #define HEATER_2_RAW_HI_TEMP 16383
  222. #define HEATER_2_RAW_LO_TEMP 0
  223. #endif
  224. #endif
  225. #ifndef HEATER_3_RAW_HI_TEMP
  226. #ifdef HEATER_3_USES_THERMISTOR
  227. #define HEATER_3_RAW_HI_TEMP 0
  228. #define HEATER_3_RAW_LO_TEMP 16383
  229. #else
  230. #define HEATER_3_RAW_HI_TEMP 16383
  231. #define HEATER_3_RAW_LO_TEMP 0
  232. #endif
  233. #endif
  234. #ifndef HEATER_4_RAW_HI_TEMP
  235. #ifdef HEATER_4_USES_THERMISTOR
  236. #define HEATER_4_RAW_HI_TEMP 0
  237. #define HEATER_4_RAW_LO_TEMP 16383
  238. #else
  239. #define HEATER_4_RAW_HI_TEMP 16383
  240. #define HEATER_4_RAW_LO_TEMP 0
  241. #endif
  242. #endif
  243. #ifndef HEATER_BED_RAW_HI_TEMP
  244. #ifdef HEATER_BED_USES_THERMISTOR
  245. #define HEATER_BED_RAW_HI_TEMP 0
  246. #define HEATER_BED_RAW_LO_TEMP 16383
  247. #else
  248. #define HEATER_BED_RAW_HI_TEMP 16383
  249. #define HEATER_BED_RAW_LO_TEMP 0
  250. #endif
  251. #endif
  252. #ifndef HEATER_CHAMBER_RAW_HI_TEMP
  253. #ifdef HEATER_CHAMBER_USES_THERMISTOR
  254. #define HEATER_CHAMBER_RAW_HI_TEMP 0
  255. #define HEATER_CHAMBER_RAW_LO_TEMP 16383
  256. #else
  257. #define HEATER_CHAMBER_RAW_HI_TEMP 16383
  258. #define HEATER_CHAMBER_RAW_LO_TEMP 0
  259. #endif
  260. #endif
  261. #endif // THERMISTORTABLES_H_