2017-09-06 13:28:31 +02:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
2020-02-03 15:00:57 +01:00
|
|
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2017-09-06 13:28:31 +02:00
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
2019-06-28 06:57:50 +02:00
|
|
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
2017-09-06 13:28:31 +02:00
|
|
|
*
|
|
|
|
* 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
|
2020-07-23 05:20:14 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2017-09-06 13:28:31 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2018-11-15 00:33:04 +01:00
|
|
|
#include "../../inc/MarlinConfig.h"
|
|
|
|
|
|
|
|
#if HAS_PID_HEATING
|
|
|
|
|
2017-09-08 05:33:16 +02:00
|
|
|
#include "../gcode.h"
|
2020-10-17 02:36:25 +02:00
|
|
|
#include "../../lcd/marlinui.h"
|
2017-09-08 05:33:16 +02:00
|
|
|
#include "../../module/temperature.h"
|
|
|
|
|
2020-01-04 04:00:44 +01:00
|
|
|
#if ENABLED(EXTENSIBLE_UI)
|
2020-03-13 22:29:29 +01:00
|
|
|
#include "../../lcd/extui/ui_api.h"
|
2022-03-11 05:07:47 +01:00
|
|
|
#elif ENABLED(DWIN_LCD_PROUI)
|
2022-02-05 17:30:17 +01:00
|
|
|
#include "../../lcd/e3v2/proui/dwin.h"
|
2020-01-04 04:00:44 +01:00
|
|
|
#endif
|
|
|
|
|
2017-09-06 13:28:31 +02:00
|
|
|
/**
|
|
|
|
* M303: PID relay autotune
|
|
|
|
*
|
2020-03-25 21:07:58 +01:00
|
|
|
* S<temperature> Set the target temperature. (Default: 150C / 70C)
|
|
|
|
* E<extruder> Extruder number to tune, or -1 for the bed. (Default: E0)
|
|
|
|
* C<cycles> Number of times to repeat the procedure. (Minimum: 3, Default: 5)
|
|
|
|
* U<bool> Flag to apply the result to the current PID values
|
|
|
|
*
|
2021-02-25 01:26:51 +01:00
|
|
|
* With PID_DEBUG, PID_BED_DEBUG, or PID_CHAMBER_DEBUG:
|
2020-03-25 21:07:58 +01:00
|
|
|
* D Toggle PID debugging and EXIT without further action.
|
2017-09-06 13:28:31 +02:00
|
|
|
*/
|
2020-03-25 01:38:09 +01:00
|
|
|
|
2017-09-08 05:33:16 +02:00
|
|
|
void GcodeSuite::M303() {
|
2020-03-25 21:07:58 +01:00
|
|
|
|
2022-08-04 09:38:15 +02:00
|
|
|
#if HAS_PID_DEBUG
|
2021-05-09 10:50:51 +02:00
|
|
|
if (parser.seen_test('D')) {
|
2021-02-25 01:26:51 +01:00
|
|
|
thermalManager.pid_debug_flag ^= true;
|
2020-03-25 21:07:58 +01:00
|
|
|
SERIAL_ECHO_START();
|
|
|
|
SERIAL_ECHOPGM("PID Debug ");
|
2021-03-08 05:06:33 +01:00
|
|
|
serialprintln_onoff(thermalManager.pid_debug_flag);
|
2020-03-25 21:07:58 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-02-25 01:26:51 +01:00
|
|
|
const heater_id_t hid = (heater_id_t)parser.intval('E');
|
2021-04-24 02:14:49 +02:00
|
|
|
celsius_t default_temp;
|
2021-02-25 01:26:51 +01:00
|
|
|
switch (hid) {
|
|
|
|
#if ENABLED(PIDTEMP)
|
|
|
|
case 0 ... HOTENDS - 1: default_temp = PREHEAT_1_TEMP_HOTEND; break;
|
|
|
|
#endif
|
|
|
|
#if ENABLED(PIDTEMPBED)
|
|
|
|
case H_BED: default_temp = PREHEAT_1_TEMP_BED; break;
|
|
|
|
#endif
|
|
|
|
#if ENABLED(PIDTEMPCHAMBER)
|
|
|
|
case H_CHAMBER: default_temp = PREHEAT_1_TEMP_CHAMBER; break;
|
|
|
|
#endif
|
|
|
|
default:
|
2022-04-04 01:44:45 +02:00
|
|
|
SERIAL_ECHOPGM(STR_PID_AUTOTUNE);
|
2021-02-25 01:26:51 +01:00
|
|
|
SERIAL_ECHOLNPGM(STR_PID_BAD_HEATER_ID);
|
|
|
|
TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_BAD_EXTRUDER_NUM));
|
2022-03-11 05:07:47 +01:00
|
|
|
TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_BAD_EXTRUDER_NUM));
|
2021-02-25 01:26:51 +01:00
|
|
|
return;
|
2018-11-15 00:33:04 +01:00
|
|
|
}
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2021-12-28 06:23:50 +01:00
|
|
|
const bool seenC = parser.seenval('C');
|
|
|
|
const int c = seenC ? parser.value_int() : 5;
|
|
|
|
const bool seenS = parser.seenval('S');
|
|
|
|
const celsius_t temp = seenS ? parser.value_celsius() : default_temp;
|
2018-11-15 00:33:04 +01:00
|
|
|
const bool u = parser.boolval('U');
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2022-03-11 05:07:47 +01:00
|
|
|
#if ENABLED(DWIN_LCD_PROUI)
|
2021-12-28 06:23:50 +01:00
|
|
|
if (seenC) HMI_data.PidCycles = c;
|
|
|
|
if (seenS) { if (hid == H_BED) HMI_data.BedPidT = temp; else HMI_data.HotendPidT = temp; }
|
|
|
|
#endif
|
|
|
|
|
2018-11-15 00:33:04 +01:00
|
|
|
#if DISABLED(BUSY_WHILE_HEATING)
|
|
|
|
KEEPALIVE_STATE(NOT_BUSY);
|
|
|
|
#endif
|
|
|
|
|
2021-09-26 00:05:11 +02:00
|
|
|
LCD_MESSAGE(MSG_PID_AUTOTUNE);
|
2021-02-25 01:26:51 +01:00
|
|
|
thermalManager.PID_autotune(temp, hid, c, u);
|
2020-06-24 22:04:39 +02:00
|
|
|
ui.reset_status();
|
2017-09-06 13:28:31 +02:00
|
|
|
}
|
2018-11-15 00:33:04 +01:00
|
|
|
|
|
|
|
#endif // HAS_PID_HEATING
|