My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

temperature.cpp 17KB

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