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.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 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. void GcodeSuite::M301() {
  39. // multi-extruder PID patch: M301 updates or prints a single extruder's PID values
  40. // default behaviour (omitting E parameter) is to update for extruder 0 only
  41. const uint8_t e = parser.byteval('E'); // extruder being updated
  42. if (e < HOTENDS) { // catch bad input value
  43. if (parser.seen('P')) PID_PARAM(Kp, e) = parser.value_float();
  44. if (parser.seen('I')) PID_PARAM(Ki, e) = scalePID_i(parser.value_float());
  45. if (parser.seen('D')) PID_PARAM(Kd, e) = scalePID_d(parser.value_float());
  46. #if ENABLED(PID_EXTRUSION_SCALING)
  47. if (parser.seen('C')) PID_PARAM(Kc, e) = parser.value_float();
  48. if (parser.seenval('L')) thermalManager.lpq_len = parser.value_int();
  49. NOMORE(thermalManager.lpq_len, LPQ_MAX_LEN);
  50. NOLESS(thermalManager.lpq_len, 0);
  51. #endif
  52. thermalManager.updatePID();
  53. SERIAL_ECHO_START();
  54. #if ENABLED(PID_PARAMS_PER_HOTEND)
  55. SERIAL_ECHOPAIR(" e:", e); // specify extruder in serial output
  56. #endif // PID_PARAMS_PER_HOTEND
  57. SERIAL_ECHOPAIR(" p:", PID_PARAM(Kp, e));
  58. SERIAL_ECHOPAIR(" i:", unscalePID_i(PID_PARAM(Ki, e)));
  59. SERIAL_ECHOPAIR(" d:", unscalePID_d(PID_PARAM(Kd, e)));
  60. #if ENABLED(PID_EXTRUSION_SCALING)
  61. //Kc does not have scaling applied above, or in resetting defaults
  62. SERIAL_ECHOPAIR(" c:", PID_PARAM(Kc, e));
  63. #endif
  64. SERIAL_EOL();
  65. }
  66. else {
  67. SERIAL_ERROR_START();
  68. SERIAL_ERRORLNPGM(MSG_INVALID_EXTRUDER);
  69. }
  70. }
  71. #endif // PIDTEMP