2017-09-06 06:28:31 -05:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
2019-02-12 15:06:53 -06:00
|
|
|
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2017-09-06 06:28:31 -05:00
|
|
|
*
|
|
|
|
* 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 <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2018-11-14 17:33:04 -06:00
|
|
|
#include "../../inc/MarlinConfig.h"
|
|
|
|
|
|
|
|
#if HAS_PID_HEATING
|
|
|
|
|
2017-09-07 22:33:16 -05:00
|
|
|
#include "../gcode.h"
|
|
|
|
#include "../../module/temperature.h"
|
|
|
|
|
2017-09-06 06:28:31 -05:00
|
|
|
/**
|
|
|
|
* M303: PID relay autotune
|
|
|
|
*
|
2018-01-03 21:30:45 -06:00
|
|
|
* S<temperature> sets the target temperature. (default 150C / 70C)
|
2017-09-06 06:28:31 -05:00
|
|
|
* E<extruder> (-1 for the bed) (default 0)
|
2019-02-10 03:54:45 -06:00
|
|
|
* C<cycles> Minimum 3. Default 5.
|
2017-09-06 06:28:31 -05:00
|
|
|
* U<bool> with a non-zero value will apply the result to current settings
|
|
|
|
*/
|
2017-09-07 22:33:16 -05:00
|
|
|
void GcodeSuite::M303() {
|
2017-09-06 06:28:31 -05:00
|
|
|
|
2018-11-18 18:04:51 -06:00
|
|
|
const int8_t e = parser.intval('E');
|
2017-09-06 06:28:31 -05:00
|
|
|
|
2018-11-14 17:33:04 -06:00
|
|
|
if (!WITHIN(e, 0
|
|
|
|
#if ENABLED(PIDTEMPBED)
|
|
|
|
-1
|
2017-09-06 06:28:31 -05:00
|
|
|
#endif
|
2018-11-14 17:33:04 -06:00
|
|
|
,
|
|
|
|
#if ENABLED(PIDTEMP)
|
|
|
|
HOTENDS
|
|
|
|
#endif
|
|
|
|
-1
|
|
|
|
)) {
|
|
|
|
SERIAL_ECHOLNPGM(MSG_PID_BAD_EXTRUDER_NUM);
|
|
|
|
return;
|
|
|
|
}
|
2017-09-06 06:28:31 -05:00
|
|
|
|
2018-11-14 17:33:04 -06: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 06:28:31 -05:00
|
|
|
|
2018-11-14 17:33:04 -06:00
|
|
|
#if DISABLED(BUSY_WHILE_HEATING)
|
|
|
|
KEEPALIVE_STATE(NOT_BUSY);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
thermalManager.PID_autotune(temp, e, c, u);
|
|
|
|
|
|
|
|
#if DISABLED(BUSY_WHILE_HEATING)
|
|
|
|
KEEPALIVE_STATE(IN_HANDLER);
|
2017-09-06 06:28:31 -05:00
|
|
|
#endif
|
|
|
|
}
|
2018-11-14 17:33:04 -06:00
|
|
|
|
|
|
|
#endif // HAS_PID_HEATING
|