My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. int8_t e = E_TERN0(parser.byteval('E', -1)); // extruder being updated
  48. if (!parser.seen("PID" TERN_(PID_EXTRUSION_SCALING, "CL") TERN_(PID_FAN_SCALING, "F")))
  49. return M301_report(true E_OPTARG(e));
  50. if (e == -1) e = 0;
  51. if (e < HOTENDS) { // catch bad input value
  52. if (parser.seenval('P')) SET_HOTEND_PID(Kp, e, parser.value_float());
  53. if (parser.seenval('I')) SET_HOTEND_PID(Ki, e, parser.value_float());
  54. if (parser.seenval('D')) SET_HOTEND_PID(Kd, e, parser.value_float());
  55. #if ENABLED(PID_EXTRUSION_SCALING)
  56. if (parser.seenval('C')) SET_HOTEND_PID(Kc, e, parser.value_float());
  57. if (parser.seenval('L')) thermalManager.lpq_len = parser.value_int();
  58. LIMIT(thermalManager.lpq_len, 0, LPQ_MAX_LEN);
  59. #endif
  60. #if ENABLED(PID_FAN_SCALING)
  61. if (parser.seenval('F')) SET_HOTEND_PID(Kf, e, parser.value_float());
  62. #endif
  63. thermalManager.updatePID();
  64. }
  65. else
  66. SERIAL_ERROR_MSG(STR_INVALID_EXTRUDER);
  67. }
  68. void GcodeSuite::M301_report(const bool forReplay/*=true*/ E_OPTARG(const int8_t eindex/*=-1*/)) {
  69. report_heading(forReplay, F(STR_HOTEND_PID));
  70. IF_DISABLED(HAS_MULTI_EXTRUDER, constexpr int8_t eindex = -1);
  71. HOTEND_LOOP() {
  72. if (e == eindex || eindex == -1) {
  73. const hotend_pid_t &pid = thermalManager.temp_hotend[e].pid;
  74. report_echo_start(forReplay);
  75. SERIAL_ECHOPGM_P(
  76. #if ENABLED(PID_PARAMS_PER_HOTEND)
  77. PSTR(" M301 E"), e, SP_P_STR
  78. #else
  79. PSTR(" M301 P")
  80. #endif
  81. , pid.p(), PSTR(" I"), pid.i(), PSTR(" D"), pid.d()
  82. );
  83. #if ENABLED(PID_EXTRUSION_SCALING)
  84. SERIAL_ECHOPGM_P(SP_C_STR, pid.c());
  85. if (e == 0) SERIAL_ECHOPGM(" L", thermalManager.lpq_len);
  86. #endif
  87. #if ENABLED(PID_FAN_SCALING)
  88. SERIAL_ECHOPGM(" F", pid.f());
  89. #endif
  90. SERIAL_EOL();
  91. }
  92. }
  93. }
  94. #endif // PIDTEMP