Configurable Thermistor (#13888)

This commit is contained in:
doggyfan
2019-05-07 00:51:06 +01:00
committed by Scott Lahteine
parent 172abc305b
commit 23a8707ef1
183 changed files with 4575 additions and 151 deletions

View File

@ -0,0 +1,81 @@
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2019 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 <http://www.gnu.org/licenses/>.
*
*/
#include "../../inc/MarlinConfig.h"
#if HAS_USER_THERMISTORS
#include "../gcode.h"
#include "../../module/temperature.h"
/**
* M305: Set (or report) custom thermistor parameters
*
* P[index] Thermistor table index
* R[ohms] Pullup resistor value
* T[ohms] Resistance at 25C
* B[beta] Thermistor "beta" value
* C[coeff] Steinhart-Hart Coefficient 'C'
*
* Format: M305 P[tbl_index] R[pullup_resistor_val] T[therm_25C_resistance] B[therm_beta] C[Steinhart_Hart_C_coeff]
*
* Examples: M305 P0 R4700 T100000 B3950 C0.0
* M305 P0 R4700
* M305 P0 T100000
* M305 P0 B3950
* M305 P0 C0.0
*/
void GcodeSuite::M305() {
const int8_t t_index = parser.intval('P', -1);
const bool do_set = parser.seen("BCRT");
// A valid P index is required
if (t_index >= (USER_THERMISTORS) || (do_set && t_index < 0)) {
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR("!Invalid index. (0 <= P <= ", int(USER_THERMISTORS - 1), ")");
}
else if (do_set) {
if (parser.seen('R')) // Pullup resistor value
if (!thermalManager.set_pull_up_res(t_index, parser.value_float()))
SERIAL_ECHO_MSG("!Invalid series resistance. (0 < R < 1000000)");
if (parser.seen('T')) // Resistance at 25C
if (!thermalManager.set_res25(t_index, parser.value_float()))
SERIAL_ECHO_MSG("!Invalid 25C resistance. (0 < T < 10000000)");
if (parser.seen('B')) // Beta value
if (!thermalManager.set_beta(t_index, parser.value_float()))
SERIAL_ECHO_MSG("!Invalid beta. (0 < B < 1000000)");
if (parser.seen('C')) // Steinhart-Hart C coefficient
if (!thermalManager.set_sh_coeff(t_index, parser.value_float()))
SERIAL_ECHO_MSG("!Invalid Steinhart-Hart C coeff. (-0.01 < C < +0.01)");
} // If not setting then report parameters
else if (t_index < 0) { // ...all user thermistors
for (uint8_t i = 0; i < USER_THERMISTORS; i++)
thermalManager.log_user_thermistor(i);
}
else // ...one user thermistor
thermalManager.log_user_thermistor(t_index);
}
#endif // HAS_USER_THERMISTORS

View File

@ -589,6 +589,10 @@ void GcodeSuite::process_parsed_command(
case 303: M303(); break; // M303: PID autotune
#endif
#if HAS_USER_THERMISTORS
case 305: M305(); break; // M305: Set user thermistor parameters
#endif
#if ENABLED(MORGAN_SCARA)
case 360: if (M360()) return; break; // M360: SCARA Theta pos1
case 361: if (M361()) return; break; // M361: SCARA Theta pos2

View File

@ -184,6 +184,7 @@
* M302 - Allow cold extrudes, or set the minimum extrude S<temperature>. (Requires PREVENT_COLD_EXTRUSION)
* M303 - PID relay autotune S<temperature> sets the target temperature. Default 150C. (Requires PIDTEMP)
* M304 - Set bed PID parameters P I and D. (Requires PIDTEMPBED)
* M305 - Set user thermistor parameters R T and P. (Requires TEMP_SENSOR_x 1000)
* M350 - Set microstepping mode. (Requires digital microstepping pins.)
* M351 - Toggle MS1 MS2 pins directly. (Requires digital microstepping pins.)
* M355 - Set Case Light on/off and set brightness. (Requires CASE_LIGHT_PIN)
@ -686,6 +687,10 @@ private:
static void M304();
#endif
#if HAS_USER_THERMISTORS
static void M305();
#endif
#if HAS_MICROSTEPS
static void M350();
static void M351();