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.

M306.cpp 3.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2022 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(MPCTEMP)
  24. #include "../gcode.h"
  25. #include "../../module/temperature.h"
  26. /**
  27. * M306: MPC settings and autotune
  28. *
  29. * T Autotune the active extruder.
  30. *
  31. * A<watts/kelvin> Ambient heat transfer coefficient (no fan).
  32. * C<joules/kelvin> Block heat capacity.
  33. * E<extruder> Extruder number to set. (Default: E0)
  34. * F<watts/kelvin> Ambient heat transfer coefficient (fan on full).
  35. * P<watts> Heater power.
  36. * R<kelvin/second/kelvin> Sensor responsiveness (= transfer coefficient / heat capcity).
  37. */
  38. void GcodeSuite::M306() {
  39. if (parser.seen_test('T')) { thermalManager.MPC_autotune(); return; }
  40. if (parser.seen("ACFPR")) {
  41. const heater_id_t hid = (heater_id_t)parser.intval('E', 0);
  42. MPC_t &constants = thermalManager.temp_hotend[hid].constants;
  43. if (parser.seenval('P')) constants.heater_power = parser.value_float();
  44. if (parser.seenval('C')) constants.block_heat_capacity = parser.value_float();
  45. if (parser.seenval('R')) constants.sensor_responsiveness = parser.value_float();
  46. if (parser.seenval('A')) constants.ambient_xfer_coeff_fan0 = parser.value_float();
  47. #if ENABLED(MPC_INCLUDE_FAN)
  48. if (parser.seenval('F')) constants.fan255_adjustment = parser.value_float() - constants.ambient_xfer_coeff_fan0;
  49. #endif
  50. return;
  51. }
  52. HOTEND_LOOP() {
  53. SERIAL_ECHOLNPGM("MPC constants for hotend ", e);
  54. MPC_t& constants = thermalManager.temp_hotend[e].constants;
  55. SERIAL_ECHOLNPGM("Heater power: ", constants.heater_power);
  56. SERIAL_ECHOLNPGM("Heatblock heat capacity: ", constants.block_heat_capacity);
  57. SERIAL_ECHOLNPAIR_F("Sensor responsivness: ", constants.sensor_responsiveness, 4);
  58. SERIAL_ECHOLNPAIR_F("Ambient heat transfer coeff. (no fan): ", constants.ambient_xfer_coeff_fan0, 4);
  59. #if ENABLED(MPC_INCLUDE_FAN)
  60. SERIAL_ECHOLNPAIR_F("Ambient heat transfer coeff. (full fan): ", constants.ambient_xfer_coeff_fan0 + constants.fan255_adjustment, 4);
  61. #endif
  62. }
  63. }
  64. void GcodeSuite::M306_report(const bool forReplay/*=true*/) {
  65. report_heading(forReplay, F("Model predictive control"));
  66. HOTEND_LOOP() {
  67. report_echo_start(forReplay);
  68. MPC_t& constants = thermalManager.temp_hotend[e].constants;
  69. SERIAL_ECHOPGM(" M306 E", e);
  70. SERIAL_ECHOPAIR_F(" P", constants.heater_power, 2);
  71. SERIAL_ECHOPAIR_F(" C", constants.block_heat_capacity, 2);
  72. SERIAL_ECHOPAIR_F(" R", constants.sensor_responsiveness, 4);
  73. SERIAL_ECHOPAIR_F(" A", constants.ambient_xfer_coeff_fan0, 4);
  74. SERIAL_ECHOLNPAIR_F(" F", constants.ambient_xfer_coeff_fan0 + constants.fan255_adjustment, 4);
  75. }
  76. }
  77. #endif // MPCTEMP