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 6.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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 "../../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> - Set filament diameter and enable. D0 disables volumetric.
  31. * S<bool> - Turn volumetric ON or OFF.
  32. * L<float> - Volumetric extruder limit (in mm^3/sec). L0 disables the limit.
  33. */
  34. void GcodeSuite::M200() {
  35. const int8_t target_extruder = get_target_extruder_from_command();
  36. if (target_extruder < 0) return;
  37. bool vol_enable = parser.volumetric_enabled,
  38. can_enable = true;
  39. if (parser.seenval('D')) {
  40. const float dval = parser.value_linear_units();
  41. if (dval) { // Set filament size for volumetric calculation
  42. planner.set_filament_size(target_extruder, dval);
  43. vol_enable = true; // Dn = enable for compatibility
  44. }
  45. else
  46. can_enable = false; // D0 = disable for compatibility
  47. }
  48. // Enable or disable with S1 / S0
  49. parser.volumetric_enabled = can_enable && parser.boolval('S', vol_enable);
  50. #if ENABLED(VOLUMETRIC_EXTRUDER_LIMIT)
  51. if (parser.seenval('L')) {
  52. // Set volumetric limit (in mm^3/sec)
  53. const float lval = parser.value_float();
  54. if (WITHIN(lval, 0, 20))
  55. planner.set_volumetric_extruder_limit(target_extruder, lval);
  56. else
  57. SERIAL_ECHOLNPGM("?L value out of range (0-20).");
  58. }
  59. #endif
  60. planner.calculate_volumetric_multipliers();
  61. }
  62. #endif // !NO_VOLUMETRICS
  63. /**
  64. * M201: Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000)
  65. *
  66. * With multiple extruders use T to specify which one.
  67. */
  68. void GcodeSuite::M201() {
  69. const int8_t target_extruder = get_target_extruder_from_command();
  70. if (target_extruder < 0) return;
  71. #ifdef XY_FREQUENCY_LIMIT
  72. if (parser.seenval('F')) planner.set_frequency_limit(parser.value_byte());
  73. if (parser.seenval('G')) planner.xy_freq_min_speed_factor = constrain(parser.value_float(), 1, 100) / 100;
  74. #endif
  75. LOOP_XYZE(i) {
  76. if (parser.seen(axis_codes[i])) {
  77. const uint8_t a = (i == E_AXIS ? uint8_t(E_AXIS_N(target_extruder)) : i);
  78. planner.set_max_acceleration(a, parser.value_axis_units((AxisEnum)a));
  79. }
  80. }
  81. }
  82. /**
  83. * M203: Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in units/sec
  84. *
  85. * With multiple extruders use T to specify which one.
  86. */
  87. void GcodeSuite::M203() {
  88. const int8_t target_extruder = get_target_extruder_from_command();
  89. if (target_extruder < 0) return;
  90. LOOP_XYZE(i)
  91. if (parser.seen(axis_codes[i])) {
  92. const uint8_t a = (i == E_AXIS ? uint8_t(E_AXIS_N(target_extruder)) : i);
  93. planner.set_max_feedrate(a, parser.value_axis_units((AxisEnum)a));
  94. }
  95. }
  96. /**
  97. * M204: Set Accelerations in units/sec^2 (M204 P1200 R3000 T3000)
  98. *
  99. * P = Printing moves
  100. * R = Retract only (no X, Y, Z) moves
  101. * T = Travel (non printing) moves
  102. */
  103. void GcodeSuite::M204() {
  104. if (!parser.seen("PRST")) {
  105. SERIAL_ECHOPAIR("Acceleration: P", planner.settings.acceleration);
  106. SERIAL_ECHOPAIR(" R", planner.settings.retract_acceleration);
  107. SERIAL_ECHOLNPAIR_P(SP_T_STR, planner.settings.travel_acceleration);
  108. }
  109. else {
  110. //planner.synchronize();
  111. // 'S' for legacy compatibility. Should NOT BE USED for new development
  112. if (parser.seenval('S')) planner.settings.travel_acceleration = planner.settings.acceleration = parser.value_linear_units();
  113. if (parser.seenval('P')) planner.settings.acceleration = parser.value_linear_units();
  114. if (parser.seenval('R')) planner.settings.retract_acceleration = parser.value_linear_units();
  115. if (parser.seenval('T')) planner.settings.travel_acceleration = parser.value_linear_units();
  116. }
  117. }
  118. /**
  119. * M205: Set Advanced Settings
  120. *
  121. * B = Min Segment Time (µs)
  122. * S = Min Feed Rate (units/s)
  123. * T = Min Travel Feed Rate (units/s)
  124. * X = Max X Jerk (units/sec^2)
  125. * Y = Max Y Jerk (units/sec^2)
  126. * Z = Max Z Jerk (units/sec^2)
  127. * E = Max E Jerk (units/sec^2)
  128. * J = Junction Deviation (mm) (If not using CLASSIC_JERK)
  129. */
  130. void GcodeSuite::M205() {
  131. #if HAS_JUNCTION_DEVIATION
  132. #define J_PARAM "J"
  133. #else
  134. #define J_PARAM
  135. #endif
  136. #if HAS_CLASSIC_JERK
  137. #define XYZE_PARAM "XYZE"
  138. #else
  139. #define XYZE_PARAM
  140. #endif
  141. if (!parser.seen("BST" J_PARAM XYZE_PARAM)) return;
  142. //planner.synchronize();
  143. if (parser.seen('B')) planner.settings.min_segment_time_us = parser.value_ulong();
  144. if (parser.seen('S')) planner.settings.min_feedrate_mm_s = parser.value_linear_units();
  145. if (parser.seen('T')) planner.settings.min_travel_feedrate_mm_s = parser.value_linear_units();
  146. #if HAS_JUNCTION_DEVIATION
  147. if (parser.seen('J')) {
  148. const float junc_dev = parser.value_linear_units();
  149. if (WITHIN(junc_dev, 0.01f, 0.3f)) {
  150. planner.junction_deviation_mm = junc_dev;
  151. TERN_(LIN_ADVANCE, planner.recalculate_max_e_jerk());
  152. }
  153. else
  154. SERIAL_ERROR_MSG("?J out of range (0.01 to 0.3)");
  155. }
  156. #endif
  157. #if HAS_CLASSIC_JERK
  158. if (parser.seen('X')) planner.set_max_jerk(X_AXIS, parser.value_linear_units());
  159. if (parser.seen('Y')) planner.set_max_jerk(Y_AXIS, parser.value_linear_units());
  160. if (parser.seen('Z')) {
  161. planner.set_max_jerk(Z_AXIS, parser.value_linear_units());
  162. #if HAS_MESH && DISABLED(LIMITED_JERK_EDITING)
  163. if (planner.max_jerk.z <= 0.1f)
  164. SERIAL_ECHOLNPGM("WARNING! Low Z Jerk may lead to unwanted pauses.");
  165. #endif
  166. }
  167. #if HAS_CLASSIC_E_JERK
  168. if (parser.seen('E')) planner.set_max_jerk(E_AXIS, parser.value_linear_units());
  169. #endif
  170. #endif
  171. }