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.

M92.cpp 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #include "../gcode.h"
  23. #include "../../module/planner.h"
  24. /**
  25. * M92: Set axis steps-per-unit for one or more axes, X, Y, Z, [I, [J, [K, [U, [V, [W,]]]]]] and E.
  26. * (Follows the same syntax as G92)
  27. *
  28. * With multiple extruders use T to specify which one.
  29. *
  30. * If no argument is given print the current values.
  31. *
  32. * With MAGIC_NUMBERS_GCODE:
  33. *
  34. * Use 'H' and/or 'L' to get ideal layer-height information.
  35. * H<microsteps> - Specify micro-steps to use. Best guess if not supplied.
  36. * L<linear> - Desired layer height in current units. Nearest good heights are shown.
  37. */
  38. void GcodeSuite::M92() {
  39. const int8_t target_extruder = get_target_extruder_from_command();
  40. if (target_extruder < 0) return;
  41. // No arguments? Show M92 report.
  42. if (!parser.seen(STR_AXES_LOGICAL TERN_(MAGIC_NUMBERS_GCODE, "HL")))
  43. return M92_report(true, target_extruder);
  44. LOOP_LOGICAL_AXES(i) {
  45. if (parser.seenval(AXIS_CHAR(i))) {
  46. if (TERN1(HAS_EXTRUDERS, i != E_AXIS))
  47. planner.settings.axis_steps_per_mm[i] = parser.value_per_axis_units((AxisEnum)i);
  48. else {
  49. #if HAS_EXTRUDERS
  50. const float value = parser.value_per_axis_units((AxisEnum)(E_AXIS_N(target_extruder)));
  51. if (value < 20) {
  52. float factor = planner.settings.axis_steps_per_mm[E_AXIS_N(target_extruder)] / value; // increase e constants if M92 E14 is given for netfab.
  53. #if HAS_CLASSIC_JERK && HAS_CLASSIC_E_JERK
  54. planner.max_jerk.e *= factor;
  55. #endif
  56. planner.settings.max_feedrate_mm_s[E_AXIS_N(target_extruder)] *= factor;
  57. planner.max_acceleration_steps_per_s2[E_AXIS_N(target_extruder)] *= factor;
  58. }
  59. planner.settings.axis_steps_per_mm[E_AXIS_N(target_extruder)] = value;
  60. #endif
  61. }
  62. }
  63. }
  64. planner.refresh_positioning();
  65. #if ENABLED(MAGIC_NUMBERS_GCODE)
  66. #ifndef Z_MICROSTEPS
  67. #define Z_MICROSTEPS 16
  68. #endif
  69. const float wanted = parser.linearval('L');
  70. if (parser.seen('H') || wanted) {
  71. const uint16_t argH = parser.ushortval('H'),
  72. micro_steps = argH ?: Z_MICROSTEPS;
  73. const float z_full_step_mm = micro_steps * planner.mm_per_step[Z_AXIS];
  74. SERIAL_ECHO_START();
  75. SERIAL_ECHOPGM("{ micro_steps:", micro_steps, ", z_full_step_mm:", z_full_step_mm);
  76. if (wanted) {
  77. const float best = uint16_t(wanted / z_full_step_mm) * z_full_step_mm;
  78. SERIAL_ECHOPGM(", best:[", best);
  79. if (best != wanted) { SERIAL_CHAR(','); SERIAL_DECIMAL(best + z_full_step_mm); }
  80. SERIAL_CHAR(']');
  81. }
  82. SERIAL_ECHOLNPGM(" }");
  83. }
  84. #endif
  85. }
  86. void GcodeSuite::M92_report(const bool forReplay/*=true*/, const int8_t e/*=-1*/) {
  87. report_heading_etc(forReplay, F(STR_STEPS_PER_UNIT));
  88. SERIAL_ECHOPGM_P(LIST_N(DOUBLE(NUM_AXES),
  89. PSTR(" M92 X"), LINEAR_UNIT(planner.settings.axis_steps_per_mm[X_AXIS]),
  90. SP_Y_STR, LINEAR_UNIT(planner.settings.axis_steps_per_mm[Y_AXIS]),
  91. SP_Z_STR, LINEAR_UNIT(planner.settings.axis_steps_per_mm[Z_AXIS]),
  92. SP_I_STR, I_AXIS_UNIT(planner.settings.axis_steps_per_mm[I_AXIS]),
  93. SP_J_STR, J_AXIS_UNIT(planner.settings.axis_steps_per_mm[J_AXIS]),
  94. SP_K_STR, K_AXIS_UNIT(planner.settings.axis_steps_per_mm[K_AXIS]),
  95. SP_U_STR, U_AXIS_UNIT(planner.settings.axis_steps_per_mm[U_AXIS]),
  96. SP_V_STR, V_AXIS_UNIT(planner.settings.axis_steps_per_mm[V_AXIS]),
  97. SP_W_STR, W_AXIS_UNIT(planner.settings.axis_steps_per_mm[W_AXIS])
  98. ));
  99. #if HAS_EXTRUDERS && DISABLED(DISTINCT_E_FACTORS)
  100. SERIAL_ECHOPGM_P(SP_E_STR, VOLUMETRIC_UNIT(planner.settings.axis_steps_per_mm[E_AXIS]));
  101. #endif
  102. SERIAL_EOL();
  103. #if ENABLED(DISTINCT_E_FACTORS)
  104. LOOP_L_N(i, E_STEPPERS) {
  105. if (e >= 0 && i != e) continue;
  106. report_echo_start(forReplay);
  107. SERIAL_ECHOLNPGM_P(
  108. PSTR(" M92 T"), i,
  109. SP_E_STR, VOLUMETRIC_UNIT(planner.settings.axis_steps_per_mm[E_AXIS_N(i)])
  110. );
  111. }
  112. #else
  113. UNUSED(e);
  114. #endif
  115. }