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

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