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

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