My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

M305.cpp 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #include "../../inc/MarlinConfig.h"
  23. #if HAS_USER_THERMISTORS
  24. #include "../gcode.h"
  25. #include "../../module/temperature.h"
  26. /**
  27. * M305: Set (or report) custom thermistor parameters
  28. *
  29. * P[index] Thermistor table index
  30. * R[ohms] Pullup resistor value
  31. * T[ohms] Resistance at 25C
  32. * B[beta] Thermistor "beta" value
  33. * C[coeff] Steinhart-Hart Coefficient 'C'
  34. *
  35. * Format: M305 P[tbl_index] R[pullup_resistor_val] T[therm_25C_resistance] B[therm_beta] C[Steinhart_Hart_C_coeff]
  36. *
  37. * Examples: M305 P0 R4700 T100000 B3950 C0.0
  38. * M305 P0 R4700
  39. * M305 P0 T100000
  40. * M305 P0 B3950
  41. * M305 P0 C0.0
  42. */
  43. void GcodeSuite::M305() {
  44. const int8_t t_index = parser.intval('P', -1);
  45. const bool do_set = parser.seen("BCRT");
  46. // A valid P index is required
  47. if (t_index >= (USER_THERMISTORS) || (do_set && t_index < 0)) {
  48. SERIAL_ECHO_START();
  49. SERIAL_ECHOLNPAIR("!Invalid index. (0 <= P <= ", int(USER_THERMISTORS - 1), ")");
  50. }
  51. else if (do_set) {
  52. if (parser.seen('R')) // Pullup resistor value
  53. if (!thermalManager.set_pull_up_res(t_index, parser.value_float()))
  54. SERIAL_ECHO_MSG("!Invalid series resistance. (0 < R < 1000000)");
  55. if (parser.seen('T')) // Resistance at 25C
  56. if (!thermalManager.set_res25(t_index, parser.value_float()))
  57. SERIAL_ECHO_MSG("!Invalid 25C resistance. (0 < T < 10000000)");
  58. if (parser.seen('B')) // Beta value
  59. if (!thermalManager.set_beta(t_index, parser.value_float()))
  60. SERIAL_ECHO_MSG("!Invalid beta. (0 < B < 1000000)");
  61. if (parser.seen('C')) // Steinhart-Hart C coefficient
  62. if (!thermalManager.set_sh_coeff(t_index, parser.value_float()))
  63. SERIAL_ECHO_MSG("!Invalid Steinhart-Hart C coeff. (-0.01 < C < +0.01)");
  64. } // If not setting then report parameters
  65. else if (t_index < 0) { // ...all user thermistors
  66. LOOP_L_N(i, USER_THERMISTORS)
  67. thermalManager.log_user_thermistor(i);
  68. }
  69. else // ...one user thermistor
  70. thermalManager.log_user_thermistor(t_index);
  71. }
  72. #endif // HAS_USER_THERMISTORS