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.

M200-M205.cpp 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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 "../gcode.h"
  23. #include "../../MarlinCore.h"
  24. #include "../../module/planner.h"
  25. #if DISABLED(NO_VOLUMETRICS)
  26. /**
  27. * M200: Set filament diameter and set E axis units to cubic units
  28. *
  29. * T<extruder> - Optional extruder number. Current extruder if omitted.
  30. * D<linear> - Diameter of the filament. Use "D0" to switch back to linear units on the E axis.
  31. */
  32. void GcodeSuite::M200() {
  33. const int8_t target_extruder = get_target_extruder_from_command();
  34. if (target_extruder < 0) return;
  35. if (parser.seen('D')) {
  36. // setting any extruder filament size disables volumetric on the assumption that
  37. // slicers either generate in extruder values as cubic mm or as as filament feeds
  38. // for all extruders
  39. const float dval = parser.value_linear_units();
  40. if ( (parser.volumetric_enabled = (dval != 0)) )
  41. planner.set_filament_size(target_extruder, dval);
  42. }
  43. planner.calculate_volumetric_multipliers();
  44. }
  45. #endif // !NO_VOLUMETRICS
  46. /**
  47. * M201: Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000)
  48. *
  49. * With multiple extruders use T to specify which one.
  50. */
  51. void GcodeSuite::M201() {
  52. const int8_t target_extruder = get_target_extruder_from_command();
  53. if (target_extruder < 0) return;
  54. LOOP_XYZE(i) {
  55. if (parser.seen(axis_codes[i])) {
  56. const uint8_t a = (i == E_AXIS ? uint8_t(E_AXIS_N(target_extruder)) : i);
  57. planner.set_max_acceleration(a, parser.value_axis_units((AxisEnum)a));
  58. }
  59. }
  60. }
  61. /**
  62. * M203: Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in units/sec
  63. *
  64. * With multiple extruders use T to specify which one.
  65. */
  66. void GcodeSuite::M203() {
  67. const int8_t target_extruder = get_target_extruder_from_command();
  68. if (target_extruder < 0) return;
  69. LOOP_XYZE(i)
  70. if (parser.seen(axis_codes[i])) {
  71. const uint8_t a = (i == E_AXIS ? uint8_t(E_AXIS_N(target_extruder)) : i);
  72. planner.set_max_feedrate(a, parser.value_axis_units((AxisEnum)a));
  73. }
  74. }
  75. /**
  76. * M204: Set Accelerations in units/sec^2 (M204 P1200 R3000 T3000)
  77. *
  78. * P = Printing moves
  79. * R = Retract only (no X, Y, Z) moves
  80. * T = Travel (non printing) moves
  81. */
  82. void GcodeSuite::M204() {
  83. if (!parser.seen("PRST")) {
  84. SERIAL_ECHOPAIR("Acceleration: P", planner.settings.acceleration);
  85. SERIAL_ECHOPAIR(" R", planner.settings.retract_acceleration);
  86. SERIAL_ECHOLNPAIR_P(SP_T_STR, planner.settings.travel_acceleration);
  87. }
  88. else {
  89. //planner.synchronize();
  90. // 'S' for legacy compatibility. Should NOT BE USED for new development
  91. if (parser.seenval('S')) planner.settings.travel_acceleration = planner.settings.acceleration = parser.value_linear_units();
  92. if (parser.seenval('P')) planner.settings.acceleration = parser.value_linear_units();
  93. if (parser.seenval('R')) planner.settings.retract_acceleration = parser.value_linear_units();
  94. if (parser.seenval('T')) planner.settings.travel_acceleration = parser.value_linear_units();
  95. }
  96. }
  97. /**
  98. * M205: Set Advanced Settings
  99. *
  100. * B = Min Segment Time (µs)
  101. * S = Min Feed Rate (units/s)
  102. * T = Min Travel Feed Rate (units/s)
  103. * X = Max X Jerk (units/sec^2)
  104. * Y = Max Y Jerk (units/sec^2)
  105. * Z = Max Z Jerk (units/sec^2)
  106. * E = Max E Jerk (units/sec^2)
  107. * J = Junction Deviation (mm) (If not using CLASSIC_JERK)
  108. */
  109. void GcodeSuite::M205() {
  110. #if DISABLED(CLASSIC_JERK)
  111. #define J_PARAM "J"
  112. #else
  113. #define J_PARAM
  114. #endif
  115. #if HAS_CLASSIC_JERK
  116. #define XYZE_PARAM "XYZE"
  117. #else
  118. #define XYZE_PARAM
  119. #endif
  120. if (!parser.seen("BST" J_PARAM XYZE_PARAM)) return;
  121. //planner.synchronize();
  122. if (parser.seen('B')) planner.settings.min_segment_time_us = parser.value_ulong();
  123. if (parser.seen('S')) planner.settings.min_feedrate_mm_s = parser.value_linear_units();
  124. if (parser.seen('T')) planner.settings.min_travel_feedrate_mm_s = parser.value_linear_units();
  125. #if DISABLED(CLASSIC_JERK)
  126. if (parser.seen('J')) {
  127. const float junc_dev = parser.value_linear_units();
  128. if (WITHIN(junc_dev, 0.01f, 0.3f)) {
  129. planner.junction_deviation_mm = junc_dev;
  130. TERN_(LIN_ADVANCE, planner.recalculate_max_e_jerk());
  131. }
  132. else
  133. SERIAL_ERROR_MSG("?J out of range (0.01 to 0.3)");
  134. }
  135. #endif
  136. #if HAS_CLASSIC_JERK
  137. if (parser.seen('X')) planner.set_max_jerk(X_AXIS, parser.value_linear_units());
  138. if (parser.seen('Y')) planner.set_max_jerk(Y_AXIS, parser.value_linear_units());
  139. if (parser.seen('Z')) {
  140. planner.set_max_jerk(Z_AXIS, parser.value_linear_units());
  141. #if HAS_MESH && DISABLED(LIMITED_JERK_EDITING)
  142. if (planner.max_jerk.z <= 0.1f)
  143. SERIAL_ECHOLNPGM("WARNING! Low Z Jerk may lead to unwanted pauses.");
  144. #endif
  145. }
  146. #if HAS_CLASSIC_E_JERK
  147. if (parser.seen('E')) planner.set_max_jerk(E_AXIS, parser.value_linear_units());
  148. #endif
  149. #endif
  150. }