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
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
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"
|
|
|
|
#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"
|
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
|
|
|
|
*
|
|
|
|
* With PID_DEBUG:
|
|
|
|
* 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
|
|
|
|
|
|
|
#if ENABLED(PID_DEBUG)
|
2020-03-25 21:07:58 +01:00
|
|
|
bool pid_debug_flag = 0;
|
2020-03-25 01:38:09 +01:00
|
|
|
#endif
|
|
|
|
|
2017-09-08 05:33:16 +02:00
|
|
|
void GcodeSuite::M303() {
|
2020-03-25 21:07:58 +01:00
|
|
|
|
|
|
|
#if ENABLED(PID_DEBUG)
|
|
|
|
if (parser.seen('D')) {
|
|
|
|
pid_debug_flag = !pid_debug_flag;
|
|
|
|
SERIAL_ECHO_START();
|
|
|
|
SERIAL_ECHOPGM("PID Debug ");
|
|
|
|
serialprintln_onoff(pid_debug_flag);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-07-02 15:39:55 +02:00
|
|
|
#if ENABLED(PIDTEMPBED)
|
|
|
|
#define SI H_BED
|
|
|
|
#else
|
|
|
|
#define SI H_E0
|
|
|
|
#endif
|
|
|
|
#if ENABLED(PIDTEMP)
|
|
|
|
#define EI HOTENDS - 1
|
|
|
|
#else
|
|
|
|
#define EI H_BED
|
|
|
|
#endif
|
|
|
|
const heater_ind_t e = (heater_ind_t)parser.intval('E');
|
|
|
|
if (!WITHIN(e, SI, EI)) {
|
2020-02-26 10:02:03 +01:00
|
|
|
SERIAL_ECHOLNPGM(STR_PID_BAD_EXTRUDER_NUM);
|
2020-01-04 04:00:44 +01:00
|
|
|
#if ENABLED(EXTENSIBLE_UI)
|
|
|
|
ExtUI::OnPidTuning(ExtUI::result_t::PID_BAD_EXTRUDER_NUM);
|
|
|
|
#endif
|
2018-11-15 00:33:04 +01:00
|
|
|
return;
|
|
|
|
}
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2018-11-15 00:33:04 +01:00
|
|
|
const int c = parser.intval('C', 5);
|
|
|
|
const bool u = parser.boolval('U');
|
|
|
|
const int16_t temp = parser.celsiusval('S', e < 0 ? 70 : 150);
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2018-11-15 00:33:04 +01:00
|
|
|
#if DISABLED(BUSY_WHILE_HEATING)
|
|
|
|
KEEPALIVE_STATE(NOT_BUSY);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
thermalManager.PID_autotune(temp, e, c, u);
|
2017-09-06 13:28:31 +02:00
|
|
|
}
|
2018-11-15 00:33:04 +01:00
|
|
|
|
|
|
|
#endif // HAS_PID_HEATING
|