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.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 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 "../../Marlin.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. if ( (parser.volumetric_enabled = (parser.value_linear_units() != 0)) )
  40. planner.set_filament_size(target_extruder, parser.value_linear_units());
  41. }
  42. planner.calculate_volumetric_multipliers();
  43. }
  44. #endif // !NO_VOLUMETRICS
  45. /**
  46. * M201: Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000)
  47. *
  48. * With multiple extruders use T to specify which one.
  49. */
  50. void GcodeSuite::M201() {
  51. const int8_t target_extruder = get_target_extruder_from_command();
  52. if (target_extruder < 0) return;
  53. LOOP_XYZE(i) {
  54. if (parser.seen(axis_codes[i])) {
  55. const uint8_t a = (i == uint8_t(E_AXIS) ? E_AXIS_N(target_extruder) : i);
  56. planner.settings.max_acceleration_mm_per_s2[a] = parser.value_axis_units((AxisEnum)a);
  57. }
  58. }
  59. // steps per sq second need to be updated to agree with the units per sq second (as they are what is used in the planner)
  60. planner.reset_acceleration_rates();
  61. }
  62. /**
  63. * M203: Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in units/sec
  64. *
  65. * With multiple extruders use T to specify which one.
  66. */
  67. void GcodeSuite::M203() {
  68. const int8_t target_extruder = get_target_extruder_from_command();
  69. if (target_extruder < 0) return;
  70. LOOP_XYZE(i)
  71. if (parser.seen(axis_codes[i])) {
  72. const uint8_t a = (i == E_AXIS ? E_AXIS_N(target_extruder) : i);
  73. planner.settings.max_feedrate_mm_s[a] = parser.value_axis_units((AxisEnum)a);
  74. }
  75. }
  76. /**
  77. * M204: Set Accelerations in units/sec^2 (M204 P1200 R3000 T3000)
  78. *
  79. * P = Printing moves
  80. * R = Retract only (no X, Y, Z) moves
  81. * T = Travel (non printing) moves
  82. */
  83. void GcodeSuite::M204() {
  84. if (!parser.seen("PRST")) {
  85. SERIAL_ECHOPAIR("Acceleration: P", planner.settings.acceleration);
  86. SERIAL_ECHOPAIR(" R", planner.settings.retract_acceleration);
  87. SERIAL_ECHOLNPAIR(" T", planner.settings.travel_acceleration);
  88. }
  89. else {
  90. //planner.synchronize();
  91. // 'S' for legacy compatibility. Should NOT BE USED for new development
  92. if (parser.seenval('S')) planner.settings.travel_acceleration = planner.settings.acceleration = parser.value_linear_units();
  93. if (parser.seenval('P')) planner.settings.acceleration = parser.value_linear_units();
  94. if (parser.seenval('R')) planner.settings.retract_acceleration = parser.value_linear_units();
  95. if (parser.seenval('T')) planner.settings.travel_acceleration = parser.value_linear_units();
  96. }
  97. }
  98. /**
  99. * M205: Set Advanced Settings
  100. *
  101. * B = Min Segment Time (µs)
  102. * S = Min Feed Rate (units/s)
  103. * T = Min Travel Feed Rate (units/s)
  104. * X = Max X Jerk (units/sec^2)
  105. * Y = Max Y Jerk (units/sec^2)
  106. * Z = Max Z Jerk (units/sec^2)
  107. * E = Max E Jerk (units/sec^2)
  108. * J = Junction Deviation (mm) (Requires JUNCTION_DEVIATION)
  109. */
  110. void GcodeSuite::M205() {
  111. #if ENABLED(JUNCTION_DEVIATION)
  112. #define J_PARAM "J"
  113. #else
  114. #define J_PARAM
  115. #endif
  116. #if HAS_CLASSIC_JERK
  117. #define XYZE_PARAM "XYZE"
  118. #else
  119. #define XYZE_PARAM
  120. #endif
  121. if (!parser.seen("BST" J_PARAM XYZE_PARAM)) return;
  122. //planner.synchronize();
  123. if (parser.seen('B')) planner.settings.min_segment_time_us = parser.value_ulong();
  124. if (parser.seen('S')) planner.settings.min_feedrate_mm_s = parser.value_linear_units();
  125. if (parser.seen('T')) planner.settings.min_travel_feedrate_mm_s = parser.value_linear_units();
  126. #if ENABLED(JUNCTION_DEVIATION)
  127. if (parser.seen('J')) {
  128. const float junc_dev = parser.value_linear_units();
  129. if (WITHIN(junc_dev, 0.01f, 0.3f)) {
  130. planner.junction_deviation_mm = junc_dev;
  131. #if ENABLED(LIN_ADVANCE)
  132. planner.recalculate_max_e_jerk();
  133. #endif
  134. }
  135. else {
  136. SERIAL_ERROR_START();
  137. SERIAL_ERRORLNPGM("?J out of range (0.01 to 0.3)");
  138. }
  139. }
  140. #endif
  141. #if HAS_CLASSIC_JERK
  142. if (parser.seen('X')) planner.max_jerk[X_AXIS] = parser.value_linear_units();
  143. if (parser.seen('Y')) planner.max_jerk[Y_AXIS] = parser.value_linear_units();
  144. if (parser.seen('Z')) {
  145. planner.max_jerk[Z_AXIS] = parser.value_linear_units();
  146. #if HAS_MESH
  147. if (planner.max_jerk[Z_AXIS] <= 0.1f)
  148. SERIAL_ECHOLNPGM("WARNING! Low Z Jerk may lead to unwanted pauses.");
  149. #endif
  150. }
  151. #if DISABLED(JUNCTION_DEVIATION) || DISABLED(LIN_ADVANCE)
  152. if (parser.seen('E')) planner.max_jerk[E_AXIS] = parser.value_linear_units();
  153. #endif
  154. #endif
  155. }