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.

M301.cpp 2.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 ENABLED(PIDTEMP)
  24. #include "../gcode.h"
  25. #include "../../module/temperature.h"
  26. /**
  27. * M301: Set PID parameters P I D (and optionally C, L)
  28. *
  29. * E[extruder] Default: 0
  30. *
  31. * P[float] Kp term
  32. * I[float] Ki term (unscaled)
  33. * D[float] Kd term (unscaled)
  34. *
  35. * With PID_EXTRUSION_SCALING:
  36. *
  37. * C[float] Kc term
  38. * L[int] LPQ length
  39. *
  40. * With PID_FAN_SCALING:
  41. *
  42. * F[float] Kf term
  43. */
  44. void GcodeSuite::M301() {
  45. // multi-extruder PID patch: M301 updates or prints a single extruder's PID values
  46. // default behavior (omitting E parameter) is to update for extruder 0 only
  47. const uint8_t e = parser.byteval('E'); // extruder being updated
  48. if (e < HOTENDS) { // catch bad input value
  49. if (parser.seen('P')) PID_PARAM(Kp, e) = parser.value_float();
  50. if (parser.seen('I')) PID_PARAM(Ki, e) = scalePID_i(parser.value_float());
  51. if (parser.seen('D')) PID_PARAM(Kd, e) = scalePID_d(parser.value_float());
  52. #if ENABLED(PID_EXTRUSION_SCALING)
  53. if (parser.seen('C')) PID_PARAM(Kc, e) = parser.value_float();
  54. if (parser.seenval('L')) thermalManager.lpq_len = parser.value_int();
  55. NOMORE(thermalManager.lpq_len, LPQ_MAX_LEN);
  56. NOLESS(thermalManager.lpq_len, 0);
  57. #endif
  58. #if ENABLED(PID_FAN_SCALING)
  59. if (parser.seen('F')) PID_PARAM(Kf, e) = parser.value_float();
  60. #endif
  61. thermalManager.updatePID();
  62. SERIAL_ECHO_START();
  63. #if ENABLED(PID_PARAMS_PER_HOTEND)
  64. SERIAL_ECHOPAIR(" e:", e); // specify extruder in serial output
  65. #endif
  66. SERIAL_ECHOPAIR(" p:", PID_PARAM(Kp, e),
  67. " i:", unscalePID_i(PID_PARAM(Ki, e)),
  68. " d:", unscalePID_d(PID_PARAM(Kd, e)));
  69. #if ENABLED(PID_EXTRUSION_SCALING)
  70. SERIAL_ECHOPAIR(" c:", PID_PARAM(Kc, e));
  71. #endif
  72. #if ENABLED(PID_FAN_SCALING)
  73. SERIAL_ECHOPAIR(" f:", PID_PARAM(Kf, e));
  74. #endif
  75. SERIAL_EOL();
  76. }
  77. else
  78. SERIAL_ERROR_MSG(STR_INVALID_EXTRUDER);
  79. }
  80. #endif // PIDTEMP