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.

M303.cpp 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 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 <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #include "../../inc/MarlinConfig.h"
  23. #if HAS_PID_HEATING
  24. #include "../gcode.h"
  25. #include "../../lcd/ultralcd.h"
  26. #include "../../module/temperature.h"
  27. #if ENABLED(EXTENSIBLE_UI)
  28. #include "../../lcd/extui/ui_api.h"
  29. #endif
  30. /**
  31. * M303: PID relay autotune
  32. *
  33. * S<temperature> Set the target temperature. (Default: 150C / 70C)
  34. * E<extruder> Extruder number to tune, or -1 for the bed. (Default: E0)
  35. * C<cycles> Number of times to repeat the procedure. (Minimum: 3, Default: 5)
  36. * U<bool> Flag to apply the result to the current PID values
  37. *
  38. * With PID_DEBUG:
  39. * D Toggle PID debugging and EXIT without further action.
  40. */
  41. #if ENABLED(PID_DEBUG)
  42. bool pid_debug_flag = 0;
  43. #endif
  44. void GcodeSuite::M303() {
  45. #if ENABLED(PID_DEBUG)
  46. if (parser.seen('D')) {
  47. pid_debug_flag = !pid_debug_flag;
  48. SERIAL_ECHO_START();
  49. SERIAL_ECHOPGM("PID Debug ");
  50. serialprintln_onoff(pid_debug_flag);
  51. return;
  52. }
  53. #endif
  54. #define SI TERN(PIDTEMPBED, H_BED, H_E0)
  55. #define EI TERN(PIDTEMP, HOTENDS - 1, H_BED)
  56. const heater_id_t e = (heater_id_t)parser.intval('E');
  57. if (!WITHIN(e, SI, EI)) {
  58. SERIAL_ECHOLNPGM(STR_PID_BAD_EXTRUDER_NUM);
  59. TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_BAD_EXTRUDER_NUM));
  60. return;
  61. }
  62. const int c = parser.intval('C', 5);
  63. const bool u = parser.boolval('U');
  64. const int16_t temp = parser.celsiusval('S', e < 0 ? PREHEAT_1_TEMP_BED : PREHEAT_1_TEMP_HOTEND);
  65. #if DISABLED(BUSY_WHILE_HEATING)
  66. KEEPALIVE_STATE(NOT_BUSY);
  67. #endif
  68. ui.set_status(GET_TEXT(MSG_PID_AUTOTUNE));
  69. thermalManager.PID_autotune(temp, e, c, u);
  70. ui.reset_status();
  71. }
  72. #endif // HAS_PID_HEATING