forked from MarlinFirmware/Marlin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⚗️ Temperature Model Predictive Control (MarlinFirmware#23751)
- Loading branch information
1 parent
8fb6521
commit 72b2e2b
Showing
13 changed files
with
566 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/** | ||
* Marlin 3D Printer Firmware | ||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] | ||
* | ||
* Based on Sprinter and grbl. | ||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
#include "../../inc/MarlinConfig.h" | ||
|
||
#if ENABLED(MPCTEMP) | ||
|
||
#include "../gcode.h" | ||
#include "../../module/temperature.h" | ||
|
||
/** | ||
* M306: MPC settings and autotune | ||
* | ||
* T Autotune the active extruder. | ||
* | ||
* A<watts/kelvin> Ambient heat transfer coefficient (no fan). | ||
* C<joules/kelvin> Block heat capacity. | ||
* E<extruder> Extruder number to set. (Default: E0) | ||
* F<watts/kelvin> Ambient heat transfer coefficient (fan on full). | ||
* P<watts> Heater power. | ||
* R<kelvin/second/kelvin> Sensor responsiveness (= transfer coefficient / heat capcity). | ||
*/ | ||
|
||
void GcodeSuite::M306() { | ||
if (parser.seen_test('T')) { thermalManager.MPC_autotune(); return; } | ||
|
||
if (parser.seen("ACFPR")) { | ||
const heater_id_t hid = (heater_id_t)parser.intval('E', 0); | ||
MPC_t &constants = thermalManager.temp_hotend[hid].constants; | ||
if (parser.seenval('P')) constants.heater_power = parser.value_float(); | ||
if (parser.seenval('C')) constants.block_heat_capacity = parser.value_float(); | ||
if (parser.seenval('R')) constants.sensor_responsiveness = parser.value_float(); | ||
if (parser.seenval('A')) constants.ambient_xfer_coeff_fan0 = parser.value_float(); | ||
#if ENABLED(MPC_INCLUDE_FAN) | ||
if (parser.seenval('F')) constants.fan255_adjustment = parser.value_float() - constants.ambient_xfer_coeff_fan0; | ||
#endif | ||
return; | ||
} | ||
|
||
HOTEND_LOOP() { | ||
SERIAL_ECHOLNPGM("MPC constants for hotend ", e); | ||
MPC_t& constants = thermalManager.temp_hotend[e].constants; | ||
SERIAL_ECHOLNPGM("Heater power: ", constants.heater_power); | ||
SERIAL_ECHOLNPGM("Heatblock heat capacity: ", constants.block_heat_capacity); | ||
SERIAL_ECHOLNPAIR_F("Sensor responsivness: ", constants.sensor_responsiveness, 4); | ||
SERIAL_ECHOLNPAIR_F("Ambient heat transfer coeff. (no fan): ", constants.ambient_xfer_coeff_fan0, 4); | ||
#if ENABLED(MPC_INCLUDE_FAN) | ||
SERIAL_ECHOLNPAIR_F("Ambient heat transfer coeff. (full fan): ", constants.ambient_xfer_coeff_fan0 + constants.fan255_adjustment, 4); | ||
#endif | ||
} | ||
} | ||
|
||
void GcodeSuite::M306_report(const bool forReplay/*=true*/) { | ||
report_heading(forReplay, F("Model predictive control")); | ||
HOTEND_LOOP() { | ||
report_echo_start(forReplay); | ||
MPC_t& constants = thermalManager.temp_hotend[e].constants; | ||
SERIAL_ECHOPGM(" M306 E", e); | ||
SERIAL_ECHOPAIR_F(" P", constants.heater_power, 2); | ||
SERIAL_ECHOPAIR_F(" C", constants.block_heat_capacity, 2); | ||
SERIAL_ECHOPAIR_F(" R", constants.sensor_responsiveness, 4); | ||
SERIAL_ECHOPAIR_F(" A", constants.ambient_xfer_coeff_fan0, 4); | ||
SERIAL_ECHOLNPAIR_F(" F", constants.ambient_xfer_coeff_fan0 + constants.fan255_adjustment, 4); | ||
} | ||
} | ||
|
||
#endif // MPCTEMP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.