My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

temperature.cpp 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  1. /*
  2. temperature.c - temperature control
  3. Part of Marlin
  4. Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. /*
  17. This firmware is a mashup between Sprinter and grbl.
  18. (https://github.com/kliment/Sprinter)
  19. (https://github.com/simen/grbl/tree)
  20. It has preliminary support for Matthew Roberts advance algorithm
  21. http://reprap.org/pipermail/reprap-dev/2011-May/003323.html
  22. This firmware is optimized for gen6 electronics.
  23. */
  24. #include <avr/pgmspace.h>
  25. #include "fastio.h"
  26. #include "Configuration.h"
  27. #include "pins.h"
  28. #include "Marlin.h"
  29. #include "ultralcd.h"
  30. #include "temperature.h"
  31. #include "watchdog.h"
  32. //===========================================================================
  33. //=============================public variables============================
  34. //===========================================================================
  35. int target_raw[3] = {0, 0, 0};
  36. int current_raw[3] = {0, 0, 0};
  37. #ifdef PIDTEMP
  38. // probably used external
  39. float HeaterPower;
  40. float pid_setpoint = 0.0;
  41. float Kp=DEFAULT_Kp;
  42. float Ki=DEFAULT_Ki;
  43. float Kd=DEFAULT_Kd;
  44. #ifdef PID_ADD_EXTRUSION_RATE
  45. float Kc=DEFAULT_Kc;
  46. #endif
  47. #endif //PIDTEMP
  48. //===========================================================================
  49. //=============================private variables============================
  50. //===========================================================================
  51. static bool temp_meas_ready = false;
  52. static unsigned long previous_millis_heater, previous_millis_bed_heater;
  53. #ifdef PIDTEMP
  54. //static cannot be external:
  55. static float temp_iState = 0;
  56. static float temp_dState = 0;
  57. static float pTerm;
  58. static float iTerm;
  59. static float dTerm;
  60. //int output;
  61. static float pid_error;
  62. static float temp_iState_min;
  63. static float temp_iState_max;
  64. static float pid_input;
  65. static float pid_output;
  66. static bool pid_reset;
  67. #endif //PIDTEMP
  68. #ifdef WATCHPERIOD
  69. static int watch_raw[3] = {-1000,-1000,-1000};
  70. static unsigned long watchmillis = 0;
  71. #endif //WATCHPERIOD
  72. // Init min and max temp with extreme values to prevent false errors during startup
  73. #ifdef HEATER_0_MINTEMP
  74. #ifdef HEATER_0_USES_AD595
  75. static int minttemp_0 = 0;
  76. #else
  77. static int minttemp_0 = 16383;
  78. #endif
  79. #endif //MINTEMP
  80. #ifdef HEATER_0_MAXTEMP
  81. #ifdef HEATER_0_USES_AD595
  82. static int maxttemp_0 = 16383;
  83. #else
  84. static int maxttemp_0 = 0;
  85. #endif
  86. #endif //MAXTEMP
  87. #ifdef HEATER_1_MINTEMP
  88. #ifdef HEATER_1_USES_AD595
  89. static int minttemp_1 = 0;
  90. #else
  91. static int minttemp_1 = 16383;
  92. #endif
  93. #endif //MINTEMP
  94. #ifdef HEATER_1_MAXTEMP
  95. #ifdef HEATER_1_USES_AD595
  96. static int maxttemp_1 = 16383;
  97. #else
  98. static int maxttemp_1 = 0;
  99. #endif
  100. #endif //MAXTEMP
  101. #ifdef BED_MINTEMP
  102. #ifdef BED_USES_AD595
  103. static int bed_minttemp = 0;
  104. #else
  105. static int bed_minttemp = 16383;
  106. #endif
  107. #endif //BED_MINTEMP
  108. #ifdef BED_MAXTEMP
  109. #ifdef BED_USES_AD595
  110. static int bed_maxttemp = 16383;
  111. #else
  112. static int bed_maxttemp = 0;
  113. #endif
  114. #endif //BED_MAXTEMP
  115. //===========================================================================
  116. //=============================functions ============================
  117. //===========================================================================
  118. void updatePID()
  119. {
  120. #ifdef PIDTEMP
  121. temp_iState_max = PID_INTEGRAL_DRIVE_MAX / Ki;
  122. #endif
  123. }
  124. void manage_heater()
  125. {
  126. #ifdef USE_WATCHDOG
  127. wd_reset();
  128. #endif
  129. float pid_input;
  130. float pid_output;
  131. if(temp_meas_ready != true) //better readability
  132. return;
  133. CRITICAL_SECTION_START;
  134. temp_meas_ready = false;
  135. CRITICAL_SECTION_END;
  136. #ifdef PIDTEMP
  137. pid_input = analog2temp(current_raw[TEMPSENSOR_HOTEND_0]);
  138. #ifndef PID_OPENLOOP
  139. pid_error = pid_setpoint - pid_input;
  140. if(pid_error > 10){
  141. pid_output = PID_MAX;
  142. pid_reset = true;
  143. }
  144. else if(pid_error < -10) {
  145. pid_output = 0;
  146. pid_reset = true;
  147. }
  148. else {
  149. if(pid_reset == true) {
  150. temp_iState = 0.0;
  151. pid_reset = false;
  152. }
  153. pTerm = Kp * pid_error;
  154. temp_iState += pid_error;
  155. temp_iState = constrain(temp_iState, temp_iState_min, temp_iState_max);
  156. iTerm = Ki * temp_iState;
  157. //K1 defined in Configuration.h in the PID settings
  158. #define K2 (1.0-K1)
  159. dTerm = (Kd * (pid_input - temp_dState))*K2 + (K1 * dTerm);
  160. temp_dState = pid_input;
  161. // #ifdef PID_ADD_EXTRUSION_RATE
  162. // pTerm+=Kc*current_block->speed_e; //additional heating if extrusion speed is high
  163. // #endif
  164. pid_output = constrain(pTerm + iTerm - dTerm, 0, PID_MAX);
  165. }
  166. #endif //PID_OPENLOOP
  167. #ifdef PID_DEBUG
  168. //SERIAL_ECHOLN(" PIDDEBUG Input "<<pid_input<<" Output "<<pid_output" pTerm "<<pTerm<<" iTerm "<<iTerm<<" dTerm "<<dTerm);
  169. #endif //PID_DEBUG
  170. HeaterPower=pid_output;
  171. analogWrite(HEATER_0_PIN, pid_output);
  172. #endif //PIDTEMP
  173. #ifndef PIDTEMP
  174. if(current_raw[0] >= target_raw[0])
  175. {
  176. WRITE(HEATER_0_PIN,LOW);
  177. }
  178. else
  179. {
  180. WRITE(HEATER_0_PIN,HIGH);
  181. }
  182. #endif
  183. if(millis() - previous_millis_bed_heater < BED_CHECK_INTERVAL)
  184. return;
  185. previous_millis_bed_heater = millis();
  186. #if TEMP_1_PIN > -1
  187. if(current_raw[TEMPSENSOR_BED] >= target_raw[TEMPSENSOR_BED])
  188. {
  189. WRITE(HEATER_1_PIN,LOW);
  190. }
  191. else
  192. {
  193. WRITE(HEATER_1_PIN,HIGH);
  194. }
  195. #endif
  196. }
  197. #define PGM_RD_W(x) (short)pgm_read_word(&x)
  198. // Takes hot end temperature value as input and returns corresponding raw value.
  199. // For a thermistor, it uses the RepRap thermistor temp table.
  200. // This is needed because PID in hydra firmware hovers around a given analog value, not a temp value.
  201. // This function is derived from inversing the logic from a portion of getTemperature() in FiveD RepRap firmware.
  202. int temp2analog(int celsius) {
  203. #ifdef HEATER_0_USES_THERMISTOR
  204. int raw = 0;
  205. byte i;
  206. for (i=1; i<NUMTEMPS_HEATER_0; i++)
  207. {
  208. if (PGM_RD_W(heater_0_temptable[i][1]) < celsius)
  209. {
  210. raw = PGM_RD_W(heater_0_temptable[i-1][0]) +
  211. (celsius - PGM_RD_W(heater_0_temptable[i-1][1])) *
  212. (PGM_RD_W(heater_0_temptable[i][0]) - PGM_RD_W(heater_0_temptable[i-1][0])) /
  213. (PGM_RD_W(heater_0_temptable[i][1]) - PGM_RD_W(heater_0_temptable[i-1][1]));
  214. break;
  215. }
  216. }
  217. // Overflow: Set to last value in the table
  218. if (i == NUMTEMPS_HEATER_0) raw = PGM_RD_W(heater_0_temptable[i-1][0]);
  219. return (1023 * OVERSAMPLENR) - raw;
  220. #elif defined HEATER_0_USES_AD595
  221. return celsius * (1024.0 / (5.0 * 100.0) ) * OVERSAMPLENR;
  222. #endif
  223. }
  224. // Takes bed temperature value as input and returns corresponding raw value.
  225. // For a thermistor, it uses the RepRap thermistor temp table.
  226. // This is needed because PID in hydra firmware hovers around a given analog value, not a temp value.
  227. // This function is derived from inversing the logic from a portion of getTemperature() in FiveD RepRap firmware.
  228. int temp2analogBed(int celsius) {
  229. #ifdef BED_USES_THERMISTOR
  230. int raw = 0;
  231. byte i;
  232. for (i=1; i<BNUMTEMPS; i++)
  233. {
  234. if (PGM_RD_W(bedtemptable[i][1]) < celsius)
  235. {
  236. raw = PGM_RD_W(bedtemptable[i-1][0]) +
  237. (celsius - PGM_RD_W(bedtemptable[i-1][1])) *
  238. (PGM_RD_W(bedtemptable[i][0]) - PGM_RD_W(bedtemptable[i-1][0])) /
  239. (PGM_RD_W(bedtemptable[i][1]) - PGM_RD_W(bedtemptable[i-1][1]));
  240. break;
  241. }
  242. }
  243. // Overflow: Set to last value in the table
  244. if (i == BNUMTEMPS) raw = PGM_RD_W(bedtemptable[i-1][0]);
  245. return (1023 * OVERSAMPLENR) - raw;
  246. #elif defined BED_USES_AD595
  247. return lround(celsius * (1024.0 * OVERSAMPLENR/ (5.0 * 100.0) ) );
  248. #endif
  249. }
  250. // Derived from RepRap FiveD extruder::getTemperature()
  251. // For hot end temperature measurement.
  252. float analog2temp(int raw) {
  253. #ifdef HEATER_0_USES_THERMISTOR
  254. float celsius = 0;
  255. byte i;
  256. raw = (1023 * OVERSAMPLENR) - raw;
  257. for (i=1; i<NUMTEMPS_HEATER_0; i++)
  258. {
  259. if (PGM_RD_W(heater_0_temptable[i][0]) > raw)
  260. {
  261. celsius = PGM_RD_W(heater_0_temptable[i-1][1]) +
  262. (raw - PGM_RD_W(heater_0_temptable[i-1][0])) *
  263. (float)(PGM_RD_W(heater_0_temptable[i][1]) - PGM_RD_W(heater_0_temptable[i-1][1])) /
  264. (float)(PGM_RD_W(heater_0_temptable[i][0]) - PGM_RD_W(heater_0_temptable[i-1][0]));
  265. break;
  266. }
  267. }
  268. // Overflow: Set to last value in the table
  269. if (i == NUMTEMPS_HEATER_0) celsius = PGM_RD_W(heater_0_temptable[i-1][1]);
  270. return celsius;
  271. #elif defined HEATER_0_USES_AD595
  272. return raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR;
  273. #endif
  274. }
  275. // Derived from RepRap FiveD extruder::getTemperature()
  276. // For bed temperature measurement.
  277. float analog2tempBed(int raw) {
  278. #ifdef BED_USES_THERMISTOR
  279. int celsius = 0;
  280. byte i;
  281. raw = (1023 * OVERSAMPLENR) - raw;
  282. for (i=1; i<BNUMTEMPS; i++)
  283. {
  284. if (PGM_RD_W(bedtemptable[i][0]) > raw)
  285. {
  286. celsius = PGM_RD_W(bedtemptable[i-1][1]) +
  287. (raw - PGM_RD_W(bedtemptable[i-1][0])) *
  288. (PGM_RD_W(bedtemptable[i][1]) - PGM_RD_W(bedtemptable[i-1][1])) /
  289. (PGM_RD_W(bedtemptable[i][0]) - PGM_RD_W(bedtemptable[i-1][0]));
  290. break;
  291. }
  292. }
  293. // Overflow: Set to last value in the table
  294. if (i == BNUMTEMPS) celsius = PGM_RD_W(bedtemptable[i-1][1]);
  295. return celsius;
  296. #elif defined BED_USES_AD595
  297. return raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR;
  298. #endif
  299. }
  300. void tp_init()
  301. {
  302. #if (HEATER_0_PIN > -1)
  303. SET_OUTPUT(HEATER_0_PIN);
  304. #endif
  305. #if (HEATER_1_PIN > -1)
  306. SET_OUTPUT(HEATER_1_PIN);
  307. #endif
  308. #if (HEATER_2_PIN > -1)
  309. SET_OUTPUT(HEATER_2_PIN);
  310. #endif
  311. #ifdef PIDTEMP
  312. temp_iState_min = 0.0;
  313. temp_iState_max = PID_INTEGRAL_DRIVE_MAX / Ki;
  314. #endif //PIDTEMP
  315. // Set analog inputs
  316. ADCSRA = 1<<ADEN | 1<<ADSC | 1<<ADIF | 0x07;
  317. // Use timer0 for temperature measurement
  318. // Interleave temperature interrupt with millies interrupt
  319. OCR0B = 128;
  320. TIMSK0 |= (1<<OCIE0B);
  321. // Wait for temperature measurement to settle
  322. delay(200);
  323. #ifdef HEATER_0_MINTEMP
  324. minttemp_0 = temp2analog(HEATER_0_MINTEMP);
  325. #endif //MINTEMP
  326. #ifdef HEATER_0_MAXTEMP
  327. maxttemp_0 = temp2analog(HEATER_0_MAXTEMP);
  328. #endif //MAXTEMP
  329. #ifdef HEATER_1_MINTEMP
  330. minttemp_1 = temp2analog(HEATER_1_MINTEMP);
  331. #endif //MINTEMP
  332. #ifdef HEATER_1_MAXTEMP
  333. maxttemp_1 = temp2analog(HEATER_1_MAXTEMP);
  334. #endif //MAXTEMP
  335. #ifdef BED_MINTEMP
  336. bed_minttemp = temp2analog(BED_MINTEMP);
  337. #endif //BED_MINTEMP
  338. #ifdef BED_MAXTEMP
  339. bed_maxttemp = temp2analog(BED_MAXTEMP);
  340. #endif //BED_MAXTEMP
  341. }
  342. void setWatch()
  343. {
  344. #ifdef WATCHPERIOD
  345. if(isHeatingHotend0())
  346. {
  347. watchmillis = max(1,millis());
  348. watch_raw[TEMPSENSOR_HOTEND_0] = current_raw[TEMPSENSOR_HOTEND_0];
  349. }
  350. else
  351. {
  352. watchmillis = 0;
  353. }
  354. #endif
  355. }
  356. void disable_heater()
  357. {
  358. #if TEMP_0_PIN > -1
  359. target_raw[0]=0;
  360. #if HEATER_0_PIN > -1
  361. WRITE(HEATER_0_PIN,LOW);
  362. #endif
  363. #endif
  364. #if TEMP_1_PIN > -1
  365. target_raw[1]=0;
  366. #if HEATER_1_PIN > -1
  367. WRITE(HEATER_1_PIN,LOW);
  368. #endif
  369. #endif
  370. #if TEMP_2_PIN > -1
  371. target_raw[2]=0;
  372. #if HEATER_2_PIN > -1
  373. WRITE(HEATER_2_PIN,LOW);
  374. #endif
  375. #endif
  376. }
  377. // Timer 0 is shared with millies
  378. ISR(TIMER0_COMPB_vect)
  379. {
  380. //these variables are only accesible from the ISR, but static, so they don't loose their value
  381. static unsigned char temp_count = 0;
  382. static unsigned long raw_temp_0_value = 0;
  383. static unsigned long raw_temp_1_value = 0;
  384. static unsigned long raw_temp_2_value = 0;
  385. static unsigned char temp_state = 0;
  386. switch(temp_state) {
  387. case 0: // Prepare TEMP_0
  388. #if (TEMP_0_PIN > -1)
  389. #if TEMP_0_PIN < 8
  390. DIDR0 = 1 << TEMP_0_PIN;
  391. #else
  392. DIDR2 = 1<<(TEMP_0_PIN - 8);
  393. ADCSRB = 1<<MUX5;
  394. #endif
  395. ADMUX = ((1 << REFS0) | (TEMP_0_PIN & 0x07));
  396. ADCSRA |= 1<<ADSC; // Start conversion
  397. #endif
  398. #ifdef ULTIPANEL
  399. buttons_check();
  400. #endif
  401. temp_state = 1;
  402. break;
  403. case 1: // Measure TEMP_0
  404. #if (TEMP_0_PIN > -1)
  405. raw_temp_0_value += ADC;
  406. #endif
  407. temp_state = 2;
  408. break;
  409. case 2: // Prepare TEMP_1
  410. #if (TEMP_1_PIN > -1)
  411. #if TEMP_1_PIN < 7
  412. DIDR0 = 1<<TEMP_1_PIN;
  413. #else
  414. DIDR2 = 1<<(TEMP_1_PIN - 8);
  415. ADCSRB = 1<<MUX5;
  416. #endif
  417. ADMUX = ((1 << REFS0) | (TEMP_1_PIN & 0x07));
  418. ADCSRA |= 1<<ADSC; // Start conversion
  419. #endif
  420. #ifdef ULTIPANEL
  421. buttons_check();
  422. #endif
  423. temp_state = 3;
  424. break;
  425. case 3: // Measure TEMP_1
  426. #if (TEMP_1_PIN > -1)
  427. raw_temp_1_value += ADC;
  428. #endif
  429. temp_state = 4;
  430. break;
  431. case 4: // Prepare TEMP_2
  432. #if (TEMP_2_PIN > -1)
  433. #if TEMP_2_PIN < 7
  434. DIDR0 = 1 << TEMP_2_PIN;
  435. #else
  436. DIDR2 = 1<<(TEMP_2_PIN - 8);
  437. ADCSRB = 1<<MUX5;
  438. #endif
  439. ADMUX = ((1 << REFS0) | (TEMP_2_PIN & 0x07));
  440. ADCSRA |= 1<<ADSC; // Start conversion
  441. #endif
  442. #ifdef ULTIPANEL
  443. buttons_check();
  444. #endif
  445. temp_state = 5;
  446. break;
  447. case 5: // Measure TEMP_2
  448. #if (TEMP_2_PIN > -1)
  449. raw_temp_2_value += ADC;
  450. #endif
  451. temp_state = 0;
  452. temp_count++;
  453. break;
  454. default:
  455. SERIAL_ERROR_START;
  456. SERIAL_ERRORLNPGM("Temp measurement error!");
  457. break;
  458. }
  459. if(temp_count >= 16) // 6 ms * 16 = 96ms.
  460. {
  461. #ifdef HEATER_0_USES_AD595
  462. current_raw[0] = raw_temp_0_value;
  463. #else
  464. current_raw[0] = 16383 - raw_temp_0_value;
  465. #endif
  466. #ifdef HEATER_1_USES_AD595
  467. current_raw[2] = raw_temp_2_value;
  468. #else
  469. current_raw[2] = 16383 - raw_temp_2_value;
  470. #endif
  471. #ifdef BED_USES_AD595
  472. current_raw[1] = raw_temp_1_value;
  473. #else
  474. current_raw[1] = 16383 - raw_temp_1_value;
  475. #endif
  476. temp_meas_ready = true;
  477. temp_count = 0;
  478. raw_temp_0_value = 0;
  479. raw_temp_1_value = 0;
  480. raw_temp_2_value = 0;
  481. #ifdef HEATER_0_MAXTEMP
  482. #if (HEATER_0_PIN > -1)
  483. if(current_raw[TEMPSENSOR_HOTEND_0] >= maxttemp_0) {
  484. target_raw[TEMPSENSOR_HOTEND_0] = 0;
  485. analogWrite(HEATER_0_PIN, 0);
  486. SERIAL_ERROR_START;
  487. SERIAL_ERRORLNPGM("Temperature extruder 0 switched off. MAXTEMP triggered !!");
  488. kill();
  489. }
  490. #endif
  491. #endif
  492. #ifdef HEATER_1_MAXTEMP
  493. #if (HEATER_1_PIN > -1)
  494. if(current_raw[TEMPSENSOR_HOTEND_1] >= maxttemp_1) {
  495. target_raw[TEMPSENSOR_HOTEND_1] = 0;
  496. if(current_raw[2] >= maxttemp_1) {
  497. analogWrite(HEATER_2_PIN, 0);
  498. SERIAL_ERROR_START;
  499. SERIAL_ERRORLNPGM("Temperature extruder 1 switched off. MAXTEMP triggered !!");
  500. kill()
  501. }
  502. #endif
  503. #endif //MAXTEMP
  504. #ifdef HEATER_0_MINTEMP
  505. #if (HEATER_0_PIN > -1)
  506. if(current_raw[TEMPSENSOR_HOTEND_0] <= minttemp_0) {
  507. target_raw[TEMPSENSOR_HOTEND_0] = 0;
  508. analogWrite(HEATER_0_PIN, 0);
  509. SERIAL_ERROR_START;
  510. SERIAL_ERRORLNPGM("Temperature extruder 0 switched off. MINTEMP triggered !!");
  511. kill();
  512. }
  513. #endif
  514. #endif
  515. #ifdef HEATER_1_MINTEMP
  516. #if (HEATER_2_PIN > -1)
  517. if(current_raw[TEMPSENSOR_HOTEND_1] <= minttemp_1) {
  518. target_raw[TEMPSENSOR_HOTEND_1] = 0;
  519. analogWrite(HEATER_2_PIN, 0);
  520. SERIAL_ERROR_START;
  521. SERIAL_ERRORLNPGM("Temperature extruder 1 switched off. MINTEMP triggered !!");
  522. kill();
  523. }
  524. #endif
  525. #endif //MAXTEMP
  526. #ifdef BED_MINTEMP
  527. #if (HEATER_1_PIN > -1)
  528. if(current_raw[1] <= bed_minttemp) {
  529. target_raw[1] = 0;
  530. WRITE(HEATER_1_PIN, 0);
  531. SERIAL_ERROR_START;
  532. SERIAL_ERRORLNPGM("Temperatur heated bed switched off. MINTEMP triggered !!");
  533. kill();
  534. }
  535. #endif
  536. #endif
  537. #ifdef BED_MAXTEMP
  538. #if (HEATER_1_PIN > -1)
  539. if(current_raw[1] >= bed_maxttemp) {
  540. target_raw[1] = 0;
  541. WRITE(HEATER_1_PIN, 0);
  542. SERIAL_ERROR_START;
  543. SERIAL_ERRORLNPGM("Temperature heated bed switched off. MAXTEMP triggered !!");
  544. kill();
  545. }
  546. #endif
  547. #endif
  548. }
  549. }